Pro OpenGL ES for iOS

(singke) #1

CHAPTER 4: Turning On the Lights (^97)
Figure 4-3. Simulated lighting from below (left) and a higher polygon count to simulate shading (right)



  1. Create a new header to hold some of the systemwide values, and call it
    OpenGLSolarSystem.h. For now, it should contain just the following two
    lines:
    #import <OpenGLES/ES1/gl.h>
    #define SS_SUNLIGHT GL_LIGHT0 //GL uses GL_LIGHTx

  2. Add #import "OpenGLSolarSystem.h" to the top of the solar-system view
    controller.

  3. Add the code in Listing 4-1, and call it from your viewDidLoad() method
    in the viewcontroller where all of the other initializers reside. And make
    sure to set the current context; otherwise, you’ll not see a thing.

Free download pdf