Pro OpenGL ES for iOS

(singke) #1

88 CHAPTER 3: Building a 3D World^


If you want to look at the actual wireframe structure of the sphere, in Planet.m, change
GL_TRIANGLE_STRIP in the execute method to GL_LINE_STRIP. And you may want to
change the background color to a medium gray to make the lines stand out better
(Figure 3-20, left). As an exercise, see what it takes to get Figure 3-20 (right). Now ask
yourself why we’re not seeing triangles there instead of that funky spiral pattern. It is
simply the way OpenGL draws and connects line strips. We could have it render triangle
outlines by specifying a connectivity array. But for our ultimate goal, that is not
necessary.

Figure 3-20. The planet In wireframe mode

On your own, change GL_LINE_STRIP to GL_POINTS. There you’ll see each of the vertices
rendered as a single dot.
Then try the frustum again. Set zNear from .1 to 2.15. (Why not 3? The distance of the
object?) And you’ll get Figure 3-21.
Free download pdf