Does openGL ES have a better performance than Core Animation and UIKit when it comes to highly animated user interfaces?

后端 未结 3 796
时光说笑
时光说笑 2021-02-06 08:53

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

相关标签:
3条回答
  • 2021-02-06 09:25

    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.

    0 讨论(0)
  • 2021-02-06 09:35

    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.)

    0 讨论(0)
  • 2021-02-06 09:37

    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.

    0 讨论(0)
提交回复
热议问题