In Review

In this tutorial, you have learned about the following:

Further Study

Try doing these things with the given programs.

  • In all of the perspective tutorials, we only ever had a frustum scale of 1.0. Adjust the frustum scale and see how it affects the scene.

  • Adjust the zNear distance, so that it intersects with the prism. See how this affects the rendering. Adjust the zFar distance similarly and see what happens.

  • We made some simplifying assumptions in our perspective transformation algorithm. In particular, we fixed the eye point at (0, 0, 0). and the plane at (0, 0, 1). However, this was not strictly necessary; we could have altered our perspective transform algorithm to use a variable eye point. Adjust the ShaderPerspective to implement an arbitrary perspective plane location (the size remains fixed at [-1, 1]). You will need to offset the X, Y camera-space positions of the vertices by Ex and Ey respectively, but only after the scaling (for aspect ratio). And you will need to divide the camera-space Z term by -Ez instead of just -1.

  • Do the above, but in matrix form. Remember that any terms placed in the fourth column will be added to that component, due to the multiplication by Wcamera (which is always 1.0).

OpenGL Functions of Note

glEnable/glDisable

These functions activate or inactivate certain features of OpenGL. There is a large list of possible features that can be enabled or disabled. In this tutorial, GL_CULL_FACE was used to enable/disable face culling.

glCullFace/glFrontFace

These two functions control how face culling works. glFrontFace defines which triangle winding order is considered the front. glCullFace defines which faces get culled. This function can also cull all faces, though this is not useful if you want to get rendering done.

These functions only do something useful if GL_CULL_FACE is currently enabled. They still set the values internally even if GL_CULL_FACE is not enabled, so enabling it later will use the up-to-date settings.

Fork me on GitHub