Appendix B Source Code Index

GlView.zip

This code demonstrates use of OpenGL and MFC. OpenGL is rendered into a CStatic form control. For more information on using OpenGL with MFC, see questions 5.150, 5.160, 5.170, and 5.180.

lookat.cpp

Many new OpenGL programmers are also new to linear algebra, and manipulating matrices can present a challenge. This code shows how to create a transformation matrix that will make an object point in a given direction. Section 9 on transformations may also be helpful.

mirror.c

Stencil planes can be used to render mirrors in OpenGL, but because many low-end graphics devices do not support them efficiently, using stencil planes is not practical. This code demonstrates how to use the depth buffer to render mirrors. An overview of the technique can be found in question 9.170.

pgonoff.c

OpenGL provides the polygon offset feature to allow rendering of coplanar primitives, and especially coplanar lines or edges over polygons. This code demonstrates correct use of the OpenGL 1.1 polygon offset interface, as well as the OpenGL 1.0 polygon offset extension interface. See section 13 on polygon offset, and section 23 on extensions for more information.

twopass.cpp

Since GL_MODULATE texture environment mode multiplies color values, obtaining white specular highlights on texture mapped objects requires special techniques. This code demonstrates a portable two-pass method, and also shows use of HP's pre-specular extension on platforms that support it. Question 21.040 discusses the issues involved in specular highlights on texture mapped objects.

viewcull.c

OpenGL clips geometry to the view volume a single vertex at a time. For optimum performance, an application must "bulk cull" large amounts of geometry. This code demonstrates how to obtain object space plane equations for the view volume, and how to clip test bounding boxes against them. Section 10 on clipping contains more information.