Open GL ES 1.1 and iPhone games - iphone

Will iPhone games that draw 2D textures like this:
glPushMatrix();
glTranslatef(xLoc, yLoc, 0);
[myTexturePointer drawAtPoint:CGPointZero];
glPopMatrix();
work with newer iPhones (that support OpenGL ES 2.0)? I'm asking because I just learned OpenGL ES 2.0 doesn't support glPushMatrix etc.
Cheers!

The newer phones still support the older OpenGL ES 1.1, so this code should run fine, as long as you're running it in a 1.1 context.

Newer iphones do support both standards. So your code should work.
To maintain compatibility with the
OpenGL ES 1.1 used in existing iPhone
and iPod touch devices, "the graphics
driver for the PowerVR SGX also
implements OpenGL ES 1.1 by
efficiently implementing the
fixed-function pipeline using
shaders," sources report. This
indicates that games and other
applications unique to the iPhone 3G S
and other future models of the iPhone
and iPod touch are likely to arrive
that will either be exclusive to the
new model, or more likely, will
support improved 3D graphics on the
new device while still working on
previous models using the older
fixed-function 3D pipeline.
Source

Related

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.
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 2.0:
Hopefully, you can see the payoff of replacing some of the built-in functions with shaders.
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.
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

OpenGL benchmark on iPhone

I'm looking for a comparison of iPhone 3G / 3GS graphical systems (opengl) to the ones on a PC / MAC.
Google didn't help. Perhaps anybody here?
While this might be more of a hardware question, there is enough that might influence the design of an OpenGL-based application here that I'll bite.
Using my Molecules application as a template, I benchmarked the rendering throughput of that running on iPhone 3G, iPad, and a 2nd generation MacBook Air (Nvidia GeForce 9400M). For the MacBook, the numbers were generated from running the application in the Simulator with nothing else executing on the system:
iPhone 3G: 423,000 triangles / s
iPad: 1,830,000 triangles / s
MacBook Air: 2,150,000 triangles / s
You can grab the code for the application and try this yourself by enabling the RUN_OPENGL_BENCHMARKS define in SLSMoleculeGLViewController. This causes structures to be rendered for 100 frames, then the total time measured and the rendering rate figured from the complexity of the model being shown.
Note that this is an OpenGL ES 1.1 application which is geometry-limited in its current state. A fill-rate-limited application might have completely different performance characteristics, same as with one that uses OpenGL / OpenGL ES 2.0 shaders.
Aside from performance differences, the OpenGL command set differs between iOS and the Mac. OpenGL ES cuts out a lot of the cruft that's built up in OpenGL over the years (immediate mode, etc.). In general, OpenGL ES is a subset of OpenGL, so you can pretty much port something written for OpenGL ES to OpenGL without a lot of trouble. OpenGL on the desktop also uses a newer version of GLSL for its shaders (1.4, I believe), so some of the commands supported there will not work on iOS devices.
Apple has more about platform-specific differences in their Platform Notes section in the OpenGL ES Programming Guide for iOS.

iPhone cost vs. benefit - OpenGL ES 1.x vs 2.0

I'm not sure if this question has been asked already, my stackoverflow-fu has failed me.
So I'm building an OpenGL-ES-based iPhone game and pretty much all of the examples I've found out in the wild are on OpenGL ES 1.x. Which is fine because at least I'm (re)learning a lot about OpenGL in general.
Now that newer devices support OpenGL-ES 2.0, I'm wondering if anyone has ported their OpenGL-ES 1.x app to 2.0 and if so were there any performance or efficiency gains? For instance, I can setup my lighting (in 1.x) with glLightf(blahblah) and I'm done with lighting...but apparently that function doesn't exist in 2.0 so I'm forced to write it myself? So, how can somebody with no experience "programming the pipeline" accomplish this? Is there a default lighting implementation in 2.0?
I'm probably speaking out of ignorance as I haven't really found any solid iPhone-specific OpenGL-ES 2.0 information.
Any help in this space will be greatly appreciated.
From what I've read, and from my limited time working with it, going to OpenGL ES 2.0 from 1.1 isn't so much a matter of performance as it is about capabilities. If you watch the Mastering OpenGL ES for iPhone videos (part of the iPhone Getting Started Videos available through the iPhone Developer Program site), Apple even states that if you can do what you need to under OpenGL ES 1.1, you don't need to step up to 2.0.
OpenGL ES 2.0's fully programmable pipeline can make simple actions much harder than doing the same thing in 1.1, because you need to write code for parts of the pipeline that were handled for you before. However, 2.0 makes practical many stunning effects that you just couldn't do in 1.1. For example, I recommend watching the WWDC 2010 session video 417 - OpenGL ES Shading and Advanced Rendering and the Graphics and Media State of the Union to see what's possible using OpenGL ES 2.0.
To date, few applications have used OpenGL ES 2.0, given the limited subset of iPhone devices that had compatible GPUs and the lack of documentation and examples. I think we'll see this start to change as the pre-iPhone 3G S devices are phased out. In particular, the iPad has had OpenGL ES 2.0 from launch, so if you are designing an application for it you can rely on these capabilities to be there. More code examples and documentation are sure to appear in the near future.

How to get started with implementing my own VGP code for iPhone OpenGL ES development?

How do I get started with implementing my own Vertex Geometry Processor code for iPhone OpenGL ES development, in order to fully benefit from its VGP Lite chip?
The iPhone chip can only be used for fixed-function processing as part of the normal transform and lighting pipeline. There's no way to run custom vertex programs.

OpenGL ES 1.x Shaders

I am trying to find examples of how to implement a simple shader for OpenGL ES 1.x (specifically for the iPhone). I have never worked with shaders before, but I do understand what they are used for. I think that once I am able to load a simple shader in the simulator I will be able to take it from there and do what I need to do.
Thanks for the help,
~Eric
The iPhone currently uses OpenGL ES 1.1 which doesn't support a programmable pipeline. OpenGL ES 2.0 does seem to have them though and also be not compatible with 1.1 .
From this post:
The pixel shader of the iP* platform is programmed via texture combiners.
My understanding is that the hardware shaders on the iPhone are already being used by the OS for its features in CoreAnimation and OpenGL ES. This means they are not available to you.
Are you looking for a software shader? Try http://unity3d.com/unity/features/shaders