Eyes, JAPAN Blog > Few words about OpenGLES

Few words about OpenGLES

denvazh

この記事は1年以上前に書かれたもので、内容が古い可能性がありますのでご注意ください。

This time I have an interest in some computer graphics driven development for an iPhone.
As we probably all know, iPhone uses OpenGL ES, a subset of OpenGL, designed specifically to satisfy hardware requirements of small hand-held devices like mobile phones, electronic books, PDA and etc.

What is the difference between these two monsters?

According to the overview on wikipedia page about OpenGLES the difference as follows:

OpenGL ES 1.0 had much functionality stripped from the original OpenGL API and a little bit added. Two of the more significant differences between OpenGL ES and OpenGL are the removal of the glBegin … glEnd calling semantics for primitive rendering (in favor of vertex arrays) and the introduction of fixed-point data types for vertex coordinates and attributes to better support the computational abilities of embedded processors, which often lack an FPU. Many other areas of functionality have been removed in version 1.0 to produce a lightweight interface: for example, quad and polygon primitive rendering, texgen, line and polygon stipple, polygon mode, antialiased polygon rendering (with alpha border fragments, not multisample), ARB_Image class pixel operation functionality, bitmaps, 3D texture, drawing to the frontbuffer, accumulation buffer, copy pixels, evaluators, selection, feedback, display lists, push and pop state attributes, two-sided lighting, and user defined clip planes.

OpenGL ES 1.1 adds to the OpenGL ES 1.0 functionality by introducing additional features such as mandatory support for multitexture, better multitexture support (with combiners and dot product texture operations), automatic mipmap generation, vertex buffer objects, state queries, user clip planes, and greater control over point rendering.

OpenGL ES 2.0, publicly released in March 2007, eliminates most of the fixed-function rendering pipeline in favor of a programmable one. Almost all rendering features of the transform and lighting pipelines, such as the specification of materials and light parameters formerly specified by the fixed-function API, are replaced by shaders written by the graphics programmer. As a result, OpenGL ES 2.0 is not backwards compatible with OpenGL ES 1.1.

OpenGL ES 2.1, while not yet publicly released, will add royalty-free texture compression scheme with 4 bits per pixel to offer enhanced quality compared to S3TC. This is an optional extension in 2.0 and will be made part of the core for OpenGL ES 2.1.

For a complete list of supported functions it always good idea to refer to the standard of the framework you use, here

What practical difference it has?

As it was pointed out above, there is no glVertex function, so if you want to draw something you should use GL_VERTEX_ARRAY.

For example this code in OpenGL:

glBegin(GL_TRIANGLES);

glVertex3f( 0.0f, 1.0f, 0.0f);

glVertex3f(-1.0f,-1.0f, 0.0f);

glVertex3f( 1.0f,-1.0f, 0.0f);

glEnd();

What these lines do is create a triangle with the vertices specified through the glVertex3f function (3 dimensional locations).

However, in OpenGL ES the glBegin and glEnd, and glVertex functions do not exist, so the above lines would be rewritten using a vertex array:

const GLfloat triangleVertices[] =
0.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f
};

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, triangleVertices);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);

You can use same approach to draw rectangle. So, normally you would end up with something like this:

If you are interested enough to make something interesting for iPhone, here is a list links, which might be interesting:

http://embedded.org.ua/opengles/lessons.html
http://maniacdev.com/2010/01/incredible-iphone-game-programming-tutorials-with-video/
http://maniacdev.com/2009/04/8-great-resources-for-learning-iphone-opengl-es/

And as a small surprise for those who still remember Wolfenstein. Head of the id software, John Carmack was porting this game (appeared in 1991) to iPhone. You can obtain it in App Store, but for those who has developers license from Apple, a source code is available:
http://www.geeks3d.com/20090325/source-code-of-wolfenstein-3d-for-the-iphone-available/
Happy digging!

Denis
  • このエントリーをはてなブックマークに追加

Comments are closed.