Special Rendering Modes in OpenGL Games Programming

Sections

Rasterisation Only

2D Rendering

256 Colour Screen Modes

Rasterisation Only

To disable the OpenGL geometry pipeline and send vertices to the driver in screen space, you need to set the appropriate transformation matrices to identity to signal to the driver that transformation is unnecessary. Here are samples of how to do this in screen space and clip space, from Michael Gold. Note that current OpenGL drivers, if the geometry pipeline is used, not only accelerate transforms on cards with appropriate hardware, but also use advanced CPU instructions such as 3DNow! and Katmai to transform geometry, where available.

2D Rendering

glDrawPixels is poorly optimised on many drivers as of December 1999, especially in 32 bit, and in any case probably maps to a slower path on most hardware than texture draws. It is probably best to approach the display of 2D menu and user interface elements by setting an identity GL_MODELVIEW matrix, a GL_PROJECTION matrix and glViewport corresponding to an orthographic projection of the width and height of the current screen with z ranging from -1.0f to +1.0f, and then using textured quads. An example can be found in this document about OpenGL coding errors from Mark Kilgard, in section 13, "Setting Your Raster Position to a Pixel Location". This link describes the alignment rules which should be followed when doing 2d rendering.

Fonts are usually handled in OpenGL games by downloading textures which contain a font brush and then rendering text as a sequence of textured quads with the modelling matrices described above. Sample font handling code from Mark Kilgard is available, and Steve Baker has written a FAQ on font rendering with OpenGL.

256 colour screen modes

OpenGL was not designed to render to a palettised screen, and the normal interface does not handle this well. SGI's OpenGL for Windows (see the Windows support section) includes special extensions which make effective 256 colour rendering on top of the SGI software renderer possible.

Back to main