R – What’s the best way of drawing layered OpenGL ES content

2ddrawingiphoneopengl-es

Anyone know what the best practices are for drawing multiple layers of 2D OpenGL ES content on the iPhone?

For example, let's say I want to draw a complex fullscreen background texture, followed by a rotating texture, followed by another alpha blended texture on top.

Is there a way to draw the background texture only ONCE, and only draw changes to the upper layers when necessary?

Everything I've found so far indicates that you should always glClear(), then draw everything, every frame, every tick, in the proper order. But there's no sense in drawing something 60 times a second if it doesn't change…

Thanks!

Best Answer

You don't have to glClear() if your drawing is going to cover every pixel (and you aren't alpha blending with the clear color). (You don't have to draw what you can't see.)

However in most cases you'll need to draw the background every frame. If your animation takes place only in a smaller rectangle than the screen (and the rest stays static) you could perhaps only redraw that rectangle, but that's probably more trouble than it's worth.

What makes your background texture, complex? Is it just large (512x512)?

Related Topic