Support OpenGL ES 1 & 2?

I want to develop a game on iphone.

But it looks like iphone3G only support ES 1 and iphone4 can support ES 2,

It's perfect if I can switch to ES 1 for iphone3G and ES 2 for iphone4 so that iphone4 can benifit from ES 2. So my question is that is it possible?

How to support both ES 1 and ES 2 in one game?

To identify a device or group of devices create an Open GL project in XCode go to the supporting files directory and look at the .pch file:

#ifndef __IPHONE_3_2
#warning "This project uses features only available in iPhone SDK 3.2 and later."
#endif

The availability header has a set of preprocessor definitions and macros, if you right click the availability header and select jump to definition you can view them all. I assume 3.2 is 3GS but don't quote me on that check the apple developer library.

It is indeed possible to support both, I recommend you look up the open
source "Oolong Engine" which has samples capable of using both you can
read through some of their source and figure out how they do it. It my just be a matter of including two differing EagleViews (one setup for either GL version) based on the preprocessor value defined and then maybe defining a constant in each of these you can refer to in the rest of your code so you can use if statements to separate out graphics logic.

On a side note 3GS can support Open GL ES2 so iPhone4 and iPad are not
the only targets to worry about using the additional capabilities there is a list of what can use GLES2 on the apple developer library here: http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/OpenGLESPlatforms/OpenGLESPlatforms.html#//apple_ref/doc/uid/TP40008793-CH106-SW1 don't underestimate that libraries value. If you get a moment go to it and look at "OpenGL ES Programming Guide for iOS".

Hope that helps!

EnlightenedOne2011-07-12 19:16:13

It helps!

Thanks a lot!