Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transitioning from OpenGL ES 1.1 to OpenGL ES 2.0

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.

like image 348
kamziro Avatar asked May 03 '11 07:05

kamziro


People also ask

Is OpenGL the same as OpenGL ES?

OpenGL is a cross-platform graphics API that specifies a standard software interface for 3D graphics processing hardware. OpenGL ES is a subset of the OpenGL specification for embedded devices. To be Android compatible, devices need to provide drivers for EGL, OpenGL ES 1.

Is OpenGL ES better than OpenGL?

OpenGL runs on desktops/laptops etc. OpenGLES runs on embedded systems (duh, ES stands for embedded systems). So.. if you have a very good GPU on your embedded system (like a phone) and a very old GPU on your desktop, then OpenGL ES would run faster, as it would be running on a faster GPU.

What is OpenGL es2?

What is OpenGL ES 2.0? Edit. OpenGL for Embedded Systems (OpenGL ES) is a subset of the OpenGL 3D graphics API. It is designed for embedded devices such as mobile phones, PDAs, and video game consoles. Notable platforms supporting OpenGL ES 2.0 include the iPhone 3GS and later, Android 2.2 and later, and WebGL.


2 Answers

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.

like image 105
Brad Larson Avatar answered Oct 21 '22 05:10

Brad Larson


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.

like image 41
jer Avatar answered Oct 21 '22 05:10

jer