Appendix B Source Code Index
This code snippet from Ron Fosner shows how to pick a pixel format based on a weighting scheme, and more importantly, how to force selection of a software pixel format. For discussion on selecting a software-only pixel format, see question 5.030.
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.
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.
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.
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.
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.
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.