Next | Prev | Up | Top | Contents | Index
Using Geometry Operations Effectively
If your application seems transform limited, you can improve it by considering the tips in this section. The section starts with some general points, then discusses optimizing line drawing and using triangles and polygons effectively.
To improve performance in the geometry subsystem, follow these guidelines:
- Use single-precision floating point parameters for vertices, normals, and colors.
- Transform paths use single-precision floats--it's fastest to use glVertex3fv() and glVertex2fv().
- Use glOrtho() and a modelview matrix without rotation for best performance.
- Perspective transforms that require multiplication by 1/W or division by W are much slower.
- To minimize the time used for floating point conversion, use floating point coordinates where possible, except where memory size is critical.
- Don't enable normalizing of normals if the modelview matrix doesn't include scaling and if you have unit-length normals.
Optimizing Line-Drawing
Even on low-end systems, lines can provide real-time interactivity. Consider these guidelines:
- Use line drawing while the scene is changing and solid rendering when the scene becomes static.
- Shaded lines and antialiased lines that are one pixel wide are supported by the hardware. Patterned lines are as fast as solid lines.
- Wide lines are drawn as multiple parallel offset lines.
- Depth-queued lines are about as fast as shaded lines.
- The hardware can usually draw lines faster than the software can produce commands, though long or antialiased lines can cause a backup in the graphics pipeline.
- Avoid depth buffering for lines; incorrect depth-sorting artifacts are usually not noticeable.
Optimizing Triangles and Polygons
When rendering triangles and polygons, keep in mind the following:
- Maximize the number of vertices between glBegin() and glEnd().
- Decompose quads and polygons into triangle strips. The GL_TRIANGLE_STRIP primitive has the fastest path.
- Use connected primitives (triangle, quad, and line strips). Use triangle strips wherever possible and draw as many triangles as possible per glBegin()/glEnd() pair.
- When rendering solid triangles, consider the following:
- Color shading and alpha blending are performed in hardware on Indy and Indigo2 XL systems. Consult system-specific documentation for information on other low-end systems.
- Larger triangles have a better overall fill rate than smaller ones because CPU setup per triangle is independent of triangle size.
Next | Prev | Up | Top | Contents | Index