Chapter 8. 3D Graphics

Using 3D graphics is the most popular approach for games these days. However, 3D is complicated. It’s so complicated, in fact, that we’re going to dedicate three whole chapters to it. The first chapter (this one) covers introductory 3D—setup, basic drawing, and understanding how 3D works overall. The next two chapters cover more intermediate and advanced topics in 3D rendering on the iPhone and iPad. After that, in Chapter 11, we cover SceneKit, Apple’s newest framework for building games (and apps) in 3D.

When you work in 3D, you use a library called OpenGL ES. OpenGL ES is the “embedded” version of OpenGL, the industry-standard library for computer graphics. OpenGL is everywhere—you’ll find it in desktop computers, in games consoles, in industrial hardware, and in mobile computers like iOS devices.

Because OpenGL is designed to be cross-platform, it doesn’t have the same nice API as you might be used to from working with other tools on iOS. Apple’s put quite a bit of effort into making things as easy as possible for developers, introducing a framework called GLKit that helps with the setup and integration of OpenGL in your game. However, you’ll still need to get used to how OpenGL works.


You’ll notice that this chapter, and the two chapters that follow it, are written in Objective-C rather than Swift. The reason for this is that GLKit, as it currently exists in iOS, doesn’t play terribly well with Swift. This will change as the Swift language evolves, but ...

Get iOS Swift Game Development Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.