Optimizing graph drawing


I am developing an application which draws an internal graph structure onscreen and offers some edit capatibilities. The current version uses GLUT. This screenshot should make it more clear:

In this run, I put a print on my drawing function to print the i’th time it is drawn. By this i can see it keeps drawing it everytime! Even if i dont move/press anything it will redraw it. It runs fast now, but i realize that my drawing function is somewhat ‘expensive’. It runs trought a list-based graph with lots of recursive calls and evaluations. The graph is read from a binary file and allocated in. The problem is that the user should be able to edit that at any time. This makes it not static.

Also, i’m not sure i skipped some part but does OpenGL automatically redraw the scene as fast as it can? Or maybe it’s just some flaw of my program.

I wonder if there is a way to optimize this. I guess display lists won’t do as they are static. Maybe vertex arrays, but if so, i don’t see how i would be using them. I would like to know if there are any options to optimize that.

Thanks in advance,


You can use display lists. In your main loop just render the display list, if the user modifies something, rebuild it.

remove glutPostRedisplay() from your drawing routine and idle function and call it in the functions that are likely to modify your scene.

Hadnt’t really thought of it. Seems like it will be a good improvement.

I will do that by now.