Cocos2D: Upgrading from OpenGL 1.1 to 2.0

Posted by Alex on Game Development See other posts from Game Development or by Alex
Published on 2012-07-05T06:22:47Z Indexed on 2012/07/05 9:23 UTC
Read the original article Hit count: 221

Filed under:
|
|

I have recently starting upgrading my ios game to the latest Cocos2D (2.0 rc), and I am having some difficulties upgrading my texture generation code to OpenGL 2.0.

In the old version I generated images with this code:

CCRenderTexture *rt = 
[CCRenderTexture renderTextureWithWidth:WIDTH height:HEIGHT];

[rt beginWithClear:bgColor.r g:bgColor.g b:bgColor.b a:bgColor.a];

glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

glVertexPointer(2, GL_FLOAT, 0, verts);
glColorPointer(4, GL_FLOAT, 0, colors);
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVerts);

glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);

[rt end];

But since OpenGL 2.0 works differently this code won't work. What is the best way to use the new OpenGL?

© Game Development or respective owner

Related posts about opengl

Related posts about cocos2d-iphone