Help with rendering images in cocos2d v2

General discussion about the R.U.B.E editor
Post Reply
hawd60
Posts: 2
Joined: Mon Feb 18, 2013 2:08 am

Help with rendering images in cocos2d v2

Post 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
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Help with rendering images in cocos2d v2

Post 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.
hawd60
Posts: 2
Joined: Mon Feb 18, 2013 2:08 am

Re: Help with rendering images in cocos2d v2

Post 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.
qq200600
Posts: 29
Joined: Fri Dec 28, 2012 9:27 am

Re: Help with rendering images in cocos2d v2

Post 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
Post Reply