I'm creating a cuboid in OpenGL using Vertex arrays but my texture seems to have gone a bit wrong.
Heres my code:
float halfW = getW() / 2;
float halfH = getH() / 2;
GLubyte myIndices[]={
1, 0, 2, //front
2, 0, 3,
4, 5, 7, //back
7, 5, 6,
0, 4, 3, //left
3, 4, 7,
5, 1, 6, //right
6, 1, 2,
7, 6, 3, //up
3, 6, 2,
1, 0, 5, //down
5, 0, 4
};
float myVertices[] = {
-halfW, -halfH, -halfW, // Vertex #0
halfW, -halfH, -halfW, // Vertex #1
halfW, halfH, -halfW, // Vertex #2
-halfW, halfH, -halfW, // Vertex #3
-halfW, -halfH, halfW, // Vertex #4
halfW, -halfH, halfW, // Vertex #5
halfW, halfH, halfW, // Vertex #6
-halfW, halfH, halfW // Vertex #7
};
float myTexCoords[]= {
1.0, 1.0, //0
0.0, 1.0, //1
0.0, 0.0, //2
1.0, 0.0, //3
0.0, 0.0, //4
1.0, 0.0, //5
1.0, 1.0, //6
0.0, 1.0 //7
};
Heres the problem:
The front and back are rendering fine but top, bottom, left and right are skewed.
Where am I going wrong?