2010-12-03 86 views
0

构建3D环境,到目前为止,我已经完全构建了立方体和彩色立方体。我想要做的就是添加一个纹理的彩色立方体的一个面iPhone OpenGL-ES:将纹理添加到立方体的一个面

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, &colourCubeVertexFaces[0]); 

glColor4ub(colourCubeFaceColors[colorIndex], colourCubeFaceColors[colorIndex+1], colourCubeFaceColors[colorIndex+2], colourCubeFaceColors[colorIndex+3]);glColor4ub(colourCubeFaceColors[colorIndex], colourCubeFaceColors[colorIndex+1], colourCubeFaceColors[colorIndex+2], colourCubeFaceColors[colorIndex+3]); 
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, &colourCubeVertexFaces[6]); 
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, &colourCubeVertexFaces[12]); 
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, &colourCubeVertexFaces[18]); 
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, &colourCubeVertexFaces[24]); 

我认为这将是为打开(或关闭)

glEnableClientState(GL_TEXTURE_COORD_ARRAY); 

然后绑定纹理一样简单

glBindTexture(GL_TEXTURE_2D, ([[coordsArray objectAtIndex:4] floatValue])); 

,然后绘制它

glTexCoordPointer(2, GL_FLOAT, 0, texturedCubeCoord); 

但它似乎只是减慢了很多,并没有显示任何东西。我其他充分纹理的立方体都很好。

回答

1

您需要glEnable(GL_TEXTURE_2D)