Game Development Reference
In-Depth Information
self.view.bounds.size.height;
float fieldOfViewDegrees = 60.0;
GLKMatrix4 projectionMatrix =
GLKMatrix4MakePerspective(GLKMathDegreesToRadians(fieldOfViewDegrees),aspectRatio,
0.1, 10.0);
_squareEffect.transform.projectionMatrix =
projectionMatrix;
16. Now, we need to provide a model view matrix. The model view matrix controls
the position of the object, relative to the camera:
GLKMatrix4 modelViewMatrix =
GLKMatrix4MakeTranslation(0.0f, 0.0f, -6.0f);
_squareEffect.transform.modelviewMatrix =
modelViewMatrix;
//Set the constant color red for the effects.
_squareEffect.useConstantColor = YES;
_squareEffect.constantColor = GLKVector4Make(1.0,
0.0, 0.0, 1.0);
17. Create the drawInRect method after the viewDidLoad method:
- (void)glkView:(GLKView *)view
drawInRect:(CGRect)rect {
}
18. The actual work of rendering is done in the glkView:drawInRect method.
The first thing that happens in this is that the view is cleared, by filling the screen
with black:
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
19. Now call prepareToDraw . It configures OpenGL in such a way that anything
we draw will use the effect's setting:
[_squareEffect prepareToDraw];
20. We first tell OpenGL that we're going to be working with positions, and then tell
OpenGL where to find the position information in the vertex data:
Search WWH ::




Custom Search