0

I am a bit confused about OpenGL ES and GameKit.

So far I have always used OpenGL ES 1.x which I think is dubbed "fixed-function pipeline". GameKit works with OpenGL ES 2.x which seems to be much more complex and seems to lack all the handy drawing functions.

In OpenGL ES 1.x I draw a triangle or strip of triangles with an interleaved vertex array like this:

glVertexPointer(2, GL_FLOAT, sizeof(Vertex), &va[0].coord);
glColorPointer(4, GL_FLOAT, sizeof(Vertex), &va[0].col);
glDrawArrays(GL_TRIANGLE_STRIP, 0, numVerts);

If this is "fixed function pipeline" and OpenGL ES 2.0 doesn't have it, how would you draw a simple triangle in OpenGL ES 2.0 or GameKit then? Is each triangle or strip of triangles a "shader"?

openfrog
  • 40,201
  • 65
  • 225
  • 373

1 Answers1

0

I think you have your frameworks confused.

Game Kit has nothing to do with your game's graphics; it's about social integration for games, including Game Center, local multiplayer, and voice chat.

GLKit is a framework that includes four major areas of functionality, all related to rendering hardware-accelerated graphics with OpenGL ES:

  • GLKView and GLKViewController provide an abstraction for the setup necessary to get OpenGL ES content on the screen (and animating). You can use it with OpenGL ES 1.1, 2.0, or 3.0.
  • GLKTextureLoader is a simplified interface for loading image data into OpenGL ES texture objects. It too can be used with any OpenGL ES version.
  • GLKMath is a set of data types and functions for high-performance vector and matrix arithmetic. Since OpenGL ES 2.0 and later don't include the matrix transform facilities associated with the OpenGL ES 1.1 fixed function pipeline, you have to do your own math -- GLKMath lets you avoid reinventing the wheel (and it runs fast, too).
  • GLKEffects (e.g. GLKBaseEffect) makes use of GLKMath and replicates the OpenGL ES 1.1 fixed-function pipeline using OpenGL ES 2.0/3.0 shaders.

The code you posted is equally valid in OpenGL ES 1.1 and 2.0/3.0(*) -- those lines specify vertex data and draw it. The parts of OpenGL ES 1.1 that are gone in 2.0 (and later) are the additional setup code that comes before you draw -- model-view and projection transformations, lighting and texturing.

In OpenGL ES 2.0 and later, these parts of the rendering process are handled by shaders -- little programs you write that run on the GPU. GLKBaseEffect implements shaders for simple tasks, or you can write your own for custom effects.

You can learn more about these by following some OpenGL ES tutorials. Here's one that includes GLKit. You might also do well to check out Apple's OpenGL ES Programming Guide.


(*) Specifying geometry that way works in OpenGL ES 2.0+ but is not recommended. Look into vertex buffer objects (and vertex array objects) instead.

rickster
  • 124,678
  • 26
  • 272
  • 326
  • I don't think that the code he posted will work in GLES 2.0. -- glVertexPointer and colorPointer don't appear anywhere in the GLES 2.0 reference pages. – Ben Pious Nov 14 '13 at 01:51
  • Ah, you're right... mistook them for `glVertexAttribPointer`. Definitely use VBOs then! – rickster Nov 14 '13 at 06:26