## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## Creating a Cube

For our next task, we’re going to create a new cube object for our skybox, and we’ll also create our first index array. A cube is a good candidate for indexing because it only has 8 unique vertices. With 3 position components per vertex, we’ll need 24 floats to store these vertices.

Let’s say that we decide to draw the cube with 2 triangles per face, so we have 12 triangles in all. With 3 vertices per triangle, if we were drawing the cube with a vertex array alone, we’d need 36 vertices or 108 floats, with a lot of the data duplicated. With an index array, we don’t need to repeat all of the vertex data. Instead, we only need to repeat the indices. This allows us to reduce the overall size of the data.

Let’s create a new class ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required