Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL vs Cocos2d: What to choose?

I understand that cocos2d it's really simple API, and that I can use it to do simple and huge 2D or even sometimes 3D games/applications. As well I understand that OpenGL it's more complicated, it's lower level API etc.

Question:
What is better for implementing 2D/3D games?
Why do we need to learn OpenGL if we have simple frameworks like cocos2d?
What you can do with OpenGL that you can't do with cocos2d?

Thanks in advance!

like image 661
Anatoliy Gatt Avatar asked Mar 19 '12 09:03

Anatoliy Gatt


2 Answers

What is better for implementing 2D/3D games?

  • Hard to tell, but a higher level API is always there to make things easier for you. For example you are writing a 2D shootem up. You will likely use a game loop, you will want to use sprites and make those move on the screen. You may want animations like explosions taking place. You'll end up writing your own higher level API to do those things. Cocos2D has solved those problems for you already. Any other frameworld should have solved it.

Why do we need to learn OpenGL if we have simple frameworks like cocos2d?

  • In case you like to cusomize the standard behaviour of a framework, especially the drawing part, you should get into openGL. If there is something you like to have which doesn't come out of the box you may find yourself reimplementing a base framework class. For example, look at the shaders used in Cocos2D 2.0. If you like some special blending mode, like a tinting effect, you won't get it for free. There is a colour attribute for a CCSprite but this may not be the result you're expecting. So you'll have to write your own shader and plug it into the sprite you like to be displayed in a different way.

What you can do with OpenGL that you can't do with cocos2d?

  • This comparison doesn't really work out, since cocos2d facilitates opengGL for the drawing part to build up that higher level api and make your life easier as a game developer.
like image 149
Nick Weaver Avatar answered Nov 11 '22 02:11

Nick Weaver


Cocos2d is a wrapper around the 2D features of OpenGL (as of this: http://www.cocos2d-iphone.org/about) . Under the hood it itself uses OpenGL ES to implement its features. This is good because it means that there will be minimal performance overhead so you can start using its simpler API without having to get immersed to the definitely bigger learning path of OpenGL.

It has however only strong 2D support and if you plan to write later 3d games you loose all benefits of Cocos2d: why would you rewrite a 3d rendering engine with a 2d framework that under the hood uses a very strong 3d engine? You loose performance for a lot of unnecessary work.

So the simpler answer is: for 2d Cocos2d, for 3d OpenGL.

If you want to start OpenGL ES, this is a very good tutorial for beginners: http://iphonedevelopment.blogspot.it/2009/05/opengl-es-from-ground-up-table-of.html

like image 13
MrTJ Avatar answered Nov 11 '22 01:11

MrTJ