9

It's been a while since iPhone 3GS came out, and now there might be enough market share of OpenGL ES 2.0 supporting devices to warrant developing in it.

But the situation is a lot of developers probably already have huge code bases in OpenGL ES 1.1

How does one transitionf rom ES 1.1 to ES 2.0? I suppose the matrices need to be taken care of, as well as stuff like GL_FOG, GL_CULL maybe?

Is it possible to write "substitutes" for these functions, e.g your own glTranslatef, glPushmatrix etc? Will this mean performance hit?

What other considerations are there for transitioning to ES 2.0? What advantages and disadvantages (besides the obvious device support issue) comes with using either of these?

Looking at the amount of es 2.0 tags compared to standard es tags in stackoverflow, it looks like it's not the time for 2.0 yet though.

3 Answers 3

17

Don't just go by activity in the tags on Stack Overflow when trying to determine whether or not to use OpenGL ES 2.0. For one thing, not every 2.0 or shader-related question is tagged as such. Also, a lot of information was present about OpenGL ES 1.1 at or soon after the launch of the iPhone SDK, so people are much more familiar with that API. There clearly is a lot of interest in OpenGL ES 2.0, as evidenced by the fact that my one class session on the subject is by far the most popular of all of my course videos.

For the most part, the way you handle your geometry will be the same between 1.1 and 2.0, as well as things like your framebuffers, but everything else shifts from being determined by built-in functions to your own shaders. You will have to write some code to replicate simple functions like using the model view matrix or texturing, but those tend to only require a few lines in a shader. For example, using the model view matrix to adjust your vertices is as simple as placing a line like this in your vertex shader:

vec4 transformedPosition = modelViewProjMatrix * position;

Personally, I replaced the glRotate(), etc. functions a long while ago using the Core Animation helper functions to manipulate what effectively is a model view matrix. This made it trivial to move that code across to OpenGL ES 2.0.

Jeff LaMarche also has an extremely useful helper class for wrapping most of your shader program setup code in his article here.

For a great guide on making the transition to OpenGL ES 1.1, see the "Migration from OpenGL ES 1.0 to OpenGL ES 2.0" article which is a chapter in the book GPU Pro and can be found within the documentation that accompanies the free PowerVR SDK.

I've explained what OpenGL ES 2.0 can be good for in my previous answers here and here, but perhaps it would be useful to demonstrate a before-and-after in regards to what the new API can give you.

OpenGL ES 1.1:

OpenGL ES 1.1

OpenGL ES 2.0:

OpenGL ES 2.0

Hopefully, you can see the payoff of replacing some of the built-in functions with shaders.

2
  • Excellent illustration of your points. Are you the guy who made the molecules app? I'm assuming for that example in the pics, the performance toll is right about the same?
    – kamziro
    May 4, 2011 at 10:05
  • @kamziro - Yes, that's me. The above screenshot is from the 2.0 version that should be in review by the end of the week. I'm not saying that you won't see a performance difference between simply shaded geometry like in my 1.1 example and the procedurally generated smooth spheres in my 2.0 one, just that you'll be able to pull off more advanced effects. My 2.0 renderer is significantly slower than the 1.1 one, but that's comparing apples to oranges because the latter one does far more. The size of geometry required to get anywhere near the second image in 1.1 would cripple the GPU.
    – Brad Larson
    May 4, 2011 at 17:57
1

If you have existing projects, I wouldn't recommend moving to 2.0, considering the effort required is very likely more than it'd be worth. That said, for any new projects, there's no reason to even bother to consider 1.1 anymore in my opinion. Most of the devices that have been sold are 3GS' or 4s, both of which are more than capable of handling 2.0.

1

OpenGL ES 2.0 has a few common things with OpenGL ES 1.1 (in rendering i mean). For each rendering you'll need a shader. For example, FOG also is created with shader. But you will have more power.

+1 to @jer his answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.