Progress ... huff

Been busy enabling my toolkit to work with OpenGL ES 2. The goal is, if the program detects OpenGL ES 2, then viola you have shaders. I figure many a developer are going down this path. Its a good bridge to iPad and back to the Mac -- especially iPad because the hardware from the get go is going to be ES 2 enabled.

I've been down this road with OpenGL 2.x but going from ES 1 to ES 2 is a much more rocky proposition. Yet, its more rewarding, if you can pull it off. It feels like going from OpenGL 1.x to OpenGL 3.x.

The two difficult parts seem to be replacing the matrix stack operations ( glPushMatrix etc. ) and then integrating vbo with the shaders. uniforms are pretty obvious. Though, attributes need to be set before the program link.

The matrix stuff is straight forward unless you run into a math issue. Math is unforgiving. But its a good review. In the long run, it would appear spinning your own matrix stack operations might lead to some nice optimizations. One thing to look out for is all the man pages are column major when they show matricies. So, you have to do a transpose, if you pass your 4x4 matrix to OpenGL. eg. glLoadMatrixf ( matrix[0] ) ...

The curve with the vbo stuff is glNormalPointer, glVertexPointer and glTexCoordPointer go away and are replaced with glVertexAttribPointer. That is different from OpenGL 2.x.  Also, I was not packing my structure right under gcc which created all sorts of fun with attribute buffer offsets. gcc does not recognize pragma pack apparently.

I like to standardize on uniform names. In the long run, I'll build up a library of shaders. So, picking consistent names is an action item early on. Another interesting thing is that shaders can be made binary. A rule of  thumb on shaders is to limit setting uniforms as much as possible. So, I plan not to generalize my shaders. That is hardcode the colors and as much stuff into shaders as possible -- or just set the uniform once right after the compile. This can be a big issue on the Mac because you want to avoid the cpu talking to card as much as possible.

Not sure OpenGL Shader Builder in the development tools works consistently with essl ( the OpenGL ES equivalent to OpenGL glsl ). Though, I hear Apple is doing a major upgrade to OpenGL 3.x. I bet this will make things work better with OpenGL ES 2 -- Mac desktop simulator and tools. Maybe the next  OpenGL Shader Builder will work. Shader tools on the Mac have always been lacking. No Render Monkey etc. Maybe with iPhone so prominent its time for people to get serious about shader related tools on the Mac.

Looks like you cannot have floating point fbos according to books I've been reading on ES 2. But you can have render to depth which is going to be important for shadowmaps. Since there is no floating point fbo, then ping pongs are going to be limited and you'll get aliasing.

Another difference appears that in ES 2 you have to use shaders. Where as, in Opengl 2.x you could switch between the old fixed pipeline stuff and the shader stuff. So, fixed pipeline really is gone in ES 2.

Much more to do .... all disclaimers apply. Fortunately, there are many similarities between OpenGL ES 2 and plain old OpenGL 2.x.

Not quite enough for any screenshots yet. But good progress so far. Think the most difficult goals in this process have been achieved.

©2009-2010 Reliabit,LLC. All rights reserved.