Page 1 of 1

Help with rendering images in cocos2d v2

Posted: Mon Feb 18, 2013 2:17 am
by hawd60
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:

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);
}
to work with GLES 2 and ended up with this:

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);
    
}
If anyone has done this previously themselves could they please help me? thanks

Re: Help with rendering images in cocos2d v2

Posted: Mon Feb 18, 2013 11:34 am
by iforce2d
I don't know enough about GLES2 to help much, but perhaps there is some extra state that you need to set up before this function happens. You could try sprinkling some glGetError calls in there, it could help to find out if some other problem is occurring.

Re: Help with rendering images in cocos2d v2

Posted: Mon Feb 18, 2013 3:57 pm
by hawd60
ok thanks, the reason I stopped using the sample ios loader was because I was getting a lot of memory leaks but I have since cleared them up and will use that instead as it is working nicely now.

Re: Help with rendering images in cocos2d v2

Posted: Mon Mar 04, 2013 4:56 am
by qq200600
hawd60 wrote:ok thanks, the reason I stopped using the sample ios loader was because I was getting a lot of memory leaks but I have since cleared them up and will use that instead as it is working nicely now.
can you give me your project code?thanks ...i want to use this software for level editor ....email:634416025@qq.com