O'Reilly logo

iOS Game Programming Cookbook by Bhanu Birani, Chhavi Vaishnav

Stay ahead with the world's most comprehensive technology and business learning platform.

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

Start Free Trial

No credit card required

Building a mini 3D animation game using OpenGL

In this recipe, we will load a texture and apply it to the square. Later, we will make a cube, and finally we will learn how to implement three-dimensional animation by rotating our cube in three-dimensions.

How to do it

Now we will start from the place we have left before and will load all the textures. To load the textures, follow the following steps:

  1. First, in our vertex structure, we need to include texture coordinate information:
    typedef struct { GLKVector3 position; // the location of each vertex in space GLKVector2 textureCoordinates; // the texture coordinates for each vertex } Vertex; const Vertex SquareVertices[] = { {{-1, -1 , 0}, {0,0}}, // bottom left {{1, -1 , 0}, {1,0}}, // bottom right ...

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

Start Free Trial

No credit card required