PDA

View Full Version : Optimizing graph drawing



enunes
09-17-2008, 11:09 PM
Hi,

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:
http://img84.imageshack.us/img84/2886/project1ga7.png

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,

enunes

Simon Mihevc
09-18-2008, 04:23 AM
You can use display lists. In your main loop just render the display list, if the user modifies something, rebuild it.

dletozeun
09-18-2008, 05:01 AM
remove glutPostRedisplay() from your drawing routine and idle function and call it in the functions that are likely to modify your scene.

enunes
09-18-2008, 02:12 PM
You can use display lists. In your main loop just render the display list, if the user modifies something, rebuild it.


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

I will do that by now.

Thanks,

enunes.