Pro OpenGL ES for iOS

(singke) #1

CHAPTER 3: Building a 3D World (^77)
Figure 3-15. The back faces are now visible, while the front ones are culled.


Building a Solar System

With these basic tools in our 3D arsenal, we can actually start in the main project,
building a small example solar system. What makes a solar system so ideal is that it has
a very basic simple shape, several objects that must all move around each other in a
hierarchical fashion, and a single light source. The reason why the cube example was
used at first is that the shape is about as elementary as you can get for 3D, ensuring that
the code was not full of extraneous geometry. When you get to something such as a
sphere, most of the code will go to creating just the object, as you will see.


Although OpenGL is a great low-level platform, it still leaves a lot to be desired when it
comes to anything remotely high level. As you saw in Chapter 1, when it comes to
modeling tools, many available third-party frameworks could ultimately be used to do
the job, but for now we’re just going to be sticking with basic OpenGL ES.


Note Besides OpenGL itself, a popular helper toolkit called GL Utility Toolkit (GLUT) is
available. GLUT provides a portable API support for basic windowing UI tasks and management
functions. It can construct some basic primitives, including a sphere, so it can be very handy
when doing small projects. Unfortunately, as of this writing, there is no official GLUT library for
iOS, although a couple of efforts are currently in the works.
Free download pdf