To main page | 3dengine.org

Debugging (OpenGL)


Debugging (in OpenGL) is often very tough topic, since if something isn't drawn - you can't really see it, i.e. if point if off screen - you can't see what's wrong with it, since there's nothing to see.

Tips

Start with developing good spectator code, which would allow you to look around correctly. This should be the first and most important item.

Use grids draw some colored grids in your world, like green flat XZ surface, red XY surface and others - that way you have some point of reference.

Use big angle-of-view - the bigger your angle-of-view - the more you see. Things like 75 degress are normal, if you really want to see more - increase it temporarily to 100 or maybe even 150-170 degrees. The distortion will be afwul, but you'll see all around. Angle-of-view is set in gluPerspective call.

Change things slowly if you still can't understand what's wrong - try to find command that screws everything out (by commenting out suspected lines) and then make it change the value SLOWLY, i.e. adding only 0.0001 every millisecond instead of setting it to 1. right at start - you can see where everything is going wrong.