Help with rendering images in cocos2d v2
Posted: Mon Feb 18, 2013 2:17 am
Hi I have copied over the b2dJson classes from the sample ios loader project into a new cocos2d v2 template project. The scene is loading up fine but I am having trouble getting the images to render. I updated the following method:
to work with GLES 2 and ended up with this:
If anyone has done this previously themselves could they please help me? thanks
Code: Select all
void b2dJsonImage_OpenGL::renderUsingArrays()
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, uvCoords);
glVertexPointer(2, GL_FLOAT, 0, points);
glDrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, indices);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
Code: Select all
void b2dJsonImage_OpenGL::renderUsingArrays()
{
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords );
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, points);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, uvCoords);
glDrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, indices);
}