CHAPTER 3: Building a 3D World (^85)
Listing 3-9 shows the master execute method. As with the cube, we translate the earth
on the Z-axis and rotate it around the y-axis.
Listing 3-9. Master execute method
-(void)execute
{
static GLfloat angle=0;
glLoadIdentity();
glTranslatef(0.0, -0.0, -3.0);
glRotatef(angle,0.0,1.0,0.0);
[m_Earth execute];
angle+=.5;
}
For the final steps, go to the window’s viewcontroller and change viewDidLoad() to
Listing 3-10.
Listing 3-10. The new viewDidLoad() method
- (void)viewDidLoad
{
[super viewDidLoad];
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
if (!self.context)
{
NSLog(@"Failed to create ES context");
}
GLKView view = (GLKView )self.view;
view.context = self.context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
m_SolarSystem=[[ OpenGLSolarSystemController alloc] init];
[EAGLContext setCurrentContext:self.context];
[self setClipping];
}
Now change the drawInRect() method to the one in Listing 3-11.