Game Development Reference
In-Depth Information
_squareEffect.transform.modelviewMatrix =
modelViewMatrix;
Replace them with the following:
GLKMatrix4 modelViewMatrix =
GLKMatrix4MakeTranslation(0.0f, 0.0f, -6.0f);
modelViewMatrix =
GLKMatrix4RotateX(modelViewMatrix,GLKMathDegreesToRadians(45));
modelViewMatrix =
GLKMatrix4RotateY(modelViewMatrix,GLKMathDegreesToRadians(45));
_squareEffect.transform.modelviewMatrix =
modelViewMatrix;
However, to draw our cube, a depth buffer needs to be added and enabled. The
depth buffer is needed to provide a three-dimensional and more realistic look to
the object.
7. Add the following code immediately after the call to EAGLContext's setCur-
rentContext method:
view.drawableDepthFormat =
GLKViewDrawableDepthFormat24;
glEnable(GL_DEPTH_TEST);
8. Finally, replace the glClear(GL_COLOR_BUFFER_BIT); line with the
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); line.
9. Compile and run the project to see the cube in three-dimensions, as shown in the
following screenshot:
Search WWH ::




Custom Search