ioscocos2d-iphoneopengl-es-2.0kobold2d

Can i mix normal OpenGL ES 2.0 with Kobol2D / cocos2d on iOS?


I am making a 2D game for iOS using Kobold2D/cocos2D. Now i've decided to try and add some 3d buildings as well (think GTA1/2 everything is 2D except the buildings).

I know how OpenGL works but im getting all sorts of errors when try to implement this.

My questions is: Does cocos2d prevent me from using normal OpenGL calls ?,or should this work fine if its done correctly? Every tutorial/example i've found uses some cocos2d wrapper for mixing opengl and cocos..

If you have done this before (mix your own OpenGL ES 2.0 code with cocos2d) could you point me in the right direction?


Solution

  • As long as you're using cocos2d/Kobold2D v2.x you can use OpenGL ES 2.0. You can override/implement any CCNode class' -(void) draw method and hack away.

    There's only one caveat: you should prefer to use the cocos2d provided "ccStuffStuff" methods (for example ccDrawColor) instead of the OpenGL ES methods because they wrap some behind the scenes stuff for performance reasons and compatibility. Check any existing cocos2d drawing code for examples. One such example would be the GLES-Render.cpp from cocos2d+Box2D projects, or the ccDrawingPrimitives.m file.