Working through some OpenGL-ES tutorials, using the Android emulator. I've gotten up to texture mapping and am having some trouble mapping to a cube. Is it possible to map a texture to all faces of a cube that has 8 vertices and 12 triangles for the 6 faces as described below?
// Use half as we are going for a 0,0,0 centre.
width /= 2;
height /= 2;
depth /= 2;
float vertices[] = { -width, -height, depth, // 0
width, -height, depth, // 1
width, height, depth, // 2
-width, height, depth, // 3
-width, -height, -depth, // 4
width, -height, -depth, // 5
width, height, -depth, // 6
-width, height, -depth, // 7
};
short indices[] = {
// Front
0,1,2,
0,2,3,
// Back
5,4,7,
5,7,6,
// Left
4,0,3,
4,3,7,
// Right
1,5,6,
1,6,2,
// Top
3,2,6,
3,6,7,
// Bottom
4,5,1,
4,1,0,
};
float texCoords[] = {
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
};
I have gotten the front and back faces working correctly, however, none of the other faces are showing the texture.