views:

766

answers:

3

Currently I have an user interface that makes incredible heavy use of core animation. I wonder if it is worth to spent another 2 months for learning openGL ES? Does that really improve drawing performance for 2D surfaces? I have no 3D objects, but highly animated 2D stuff. Sometimes with 3D distortions, a lot of rotations and scaling.

In particular I made a whole game with lots of sprites just using CA. Performance is ok but not perfect.

+2  A: 

It depends on what you are doing and what device you are targeting. If you are doing things that would benefit from a programmable graphics pipeline and targeting the iPhone 3GS then you might be able to see some benefit, simply because that functionality is not exposed through CoreAnimation so you have to do it in sort of weird ways (manipulating images, etc). The iPhone 3G hardware doesn't have programmable shaders, so even if your effects can be expressed in terms of shaders moving to OpenGL will not provide that benefit on older phones.

If all you are doing is moving, rotating, and scaling 2D surfaces then CoreAnimation is going to give very similiar performance to OpenGL, slightly better or worse depending on how your data is getting into the layers, etc.

Louis Gerbarg
+2  A: 

In theory OpenGL should be the fastest API on the device, simply because it’s closest to hardware. (Somebody please correct me if I am wrong on this.) In OpenGL you can do some clever tricks that will help your performance quite a bit – you can draw the sprites in batches, you can use point sprites, you can try compressing the textures, etc.

On the other hand you get very close to the hardware and there is not much abstraction left, at least when comparing to Core Animation. You have to deal with non-power-of-two textures, projections, matrices, you have to write the animation code yourself, etc. There is a lot of places you can go wrong and seriously kill the performance instead of making it better.

What I like about OpenGL is that it’s cross-platform. There are lots of resources about OpenGL, there is a lot of space for improvement. If you want to write games and have the time to learn OpenGL, do it. Wrapping the OpenGL basics into an OOP design is not that hard and eventually you’ll get more space for performance improvements. A good place to start is the Cocos 2D engine for iPhone.


(Disclaimer: I know just a little bit about OpenGL and nothing much about Core Animation. I’ve written two 2D games for iPhone using OpenGL.)

zoul
+2  A: 

I asked the same questions of people at WWDC last month and the answer was definitely yes - if you take the time to use OpenGL at a low level you will get better performance for 2D.

Andy Dent