Game Development Reference
In-Depth Information
5. Now we will make it as a cube. The cube is made up of eight vertices, so we need
to provide information for each vertex, including its position and texture coordin-
ates. From now on, rename SquareVertices to CubeVertices to follow a
better naming convention.
const Vertex CubeVertices[] = {
{{-1, -1, 1}, {0,0}}, // bottom left front
{{1, -1, 1}, {1,0}}, // bottom right front
{{1, 1, 1}, {1,1}}, // top right front
{{-1, 1, 1}, {0,1}}, // top left front
{{-1, -1, -1}, {1,0}}, // bottom left back
{{1, -1, -1}, {0,0}}, // bottom right back
{{1, 1, -1}, {0,1}}, // top right back
{{-1, 1, -1}, {1,1}}, // top left back
};
const GLubyte CubeTriangles[] = {
0, 1, 2, // front face 1
2, 3, 0, // front face 2
4, 5, 6, // back face 1
6, 7, 4, // back face 2
7, 4, 0, // left face 1
0, 3, 7, // left face 2
2, 1, 5, // right face 1
5, 6, 2, // right face 2
7, 3, 6, // top face 1
6, 2, 3, // top face 2
4, 0, 5, // bottom face 1
5, 1, 0, // bottom face 2
};
6. The next step is a purely aesthetic one: the cube will be rotated, in order to illus-
trate that it is in fact a three-dimensional object.
Select the following lines:
GLKMatrix4 modelViewMatrix =
GLKMatrix4MakeTranslation(0.0f, 0.0f, -6.0f);
Search WWH ::




Custom Search