I have created a opengl cube with a texture, but it only draws the back faces of the cube.
It also draws over CCNodes that should be drawn over the cube.
this is the current draw method i am using
-(void)draw
{
posX = 0;
posY = 0;
width = 64;
height = 50;
depth = 16;
GLfloat cubeVerticesTemp[] = {
posX, posY+depth, height,
width+posX, posY+depth, 0.0f,
width+posX, posY+depth, height,
posX, posY+depth, height,
posX, posY+depth, 0.0f,
width+posX, posY+depth, 0.0f,
posX, depth+posY, height,
width+posX, posY, height,
width+posX, depth+posY, height,
posX, depth+posY, height,
posX, posY, height,
width+posX, posY, height,
posX, posY, height,
width+posX, posY, 0.0f,
width+posX, posY, height,
posX, posY, height,
posX, posY, 0.0f,
width+posX, posY, 0.0f,
posX, posY,0.0f,
width+posX, depth+posY, 0.0f,
width+posX, posY, 0.0f,
posX, posY, 0.0f,
posX, depth+posY, 0.0f,
width+posX, depth+posY, 0.0f,
posX, depth+posY, height,
posX, posY, 0.0f,
posX, depth+posY, 0.0f,
posX, depth+posY, height,
posX, posY, height,
posX, posY, 0.0f,
width+posX, depth+posY, height,
width+posX, posY, 0.0f,
width+posX, depth+posY, 0.0f,
width+posX, depth+posY, height,
width+posX, posY, height,
width+posX, posY, 0.0f,
};
GLfloat cubeTextureCoords[] = {
0.0f, 0.5f, // bottom-upper-right
1.5f, 1.0f,
1.0f, 0.5f,
0.0f, 0.5f, // bottom-lower-left
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f, // front-upper-right
1.0f, 0.5f,
1.0f, 0.0f,
0.0f, 0.0f, // front-lower-left
0.0f, 0.5f,
1.0f, 0.5f,
0.0f, 0.5f, // bottom-upper-right
1.0f, 1.0f,
1.0f, 0.5f,
0.0f, 0.5f, // bottom-lower-left
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 1.0f, // back-upper-right
1.0f, 0.5f,
0.0f, 0.5f,
0.0f, 1.0f, // back-lower-left
1.0f, 1.0f,
1.0f, 0.5f,
1.0f, 0.5f, // right-upper-right
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.5f, // right-lower-left
0.0f, 0.5f,
0.0f, 1.0f,
1.0f, 0.5f, // right-upper-right
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.5f, // right-lower-left
0.0f, 0.5f,
0.0f, 1.0f,
};
glColor4f(1,1,1,1);
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glVertexPointer(3, GL_FLOAT, 0, cubeVerticesTemp);
glTexCoordPointer(2, GL_FLOAT, 0, cubeTextureCoords);
glDrawArrays(GL_TRIANGLES, 0, 36);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}