对不起,重复了,但我已经谷歌搜索了几个小时没有任何结果。
我有一个从转换器导出的简单立方体的(优化的)数据:
// 8 Verticies
// 4 Texture Coordinates
// 6 Normals
// 12 Triangles
static GLshort cubeFace_indicies[12][9] = {
// Box001
{2,0,3 ,0,0,0 ,0,1,2 }, {1,3,0 ,0,0,0 ,3,2,1 }, {5,4,7 ,1,1,1 ,1,3,0 },
{6,7,4 ,1,1,1 ,2,0,3 }, {1,0,5 ,2,2,2 ,1,3,0 }, {4,5,0 ,2,2,2 ,2,0,3 },
{3,1,7 ,3,3,3 ,1,3,0 }, {5,7,1 ,3,3,3 ,2,0,3 }, {2,3,6 ,4,4,4 ,1,3,0 },
{7,6,3 ,4,4,4 ,2,0,3 }, {0,2,4 ,5,5,5 ,1,3,0 }, {6,4,2 ,5,5,5 ,2,0,3 }
};
static GLfloat cubeVertices [8][3] = {
{-100.0f,-100.0f,-100.0f},{100.0f,-100.0f,-100.0f},{-100.0f,100.0f,-100.0f},
{100.0f,100.0f,-100.0f},{-100.0f,-100.0f,100.0f},{100.0f,-100.0f,100.0f},
{-100.0f,100.0f,100.0f},{100.0f,100.0f,100.0f}
};
static GLfloat cubeNormals [6][3] = {
{0.0f,0.0f,1.0f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},
{-1.0f,0.0f,0.0f},{0.0f,-1.0f,0.0f},{1.0f,0.0f,0.0f}
};
static GLfloat cubeTextures [4][2] = {
{1.0f,2.0f},{1.0f,1.0f},{0.0f,2.0f},
{0.0f,1.0f}
};
我设置了纹理,我想在屏幕上看到一些东西。我最近的绘图代码如下:
glTexCoordPointer(2, GL_FLOAT, 0, cubeTextures);
glVertexPointer(3, GL_FLOAT, 0, cubeVertices);
glNormalPointer(GL_FLOAT, 0, cubeNormals);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glDrawElements(GL_TRIANGLES , 12, GL_SHORT, cubeFace_indicies);