View Full Version : forcing a display redraw using signals

08-02-2002, 11:50 AM
I have a multi-threaded app in which one thread handles the openGL display, and the other handles the GUI to the user. When the user changes something in the GUI, I need the openGL thread to regen the display. Is there a way to signal GLX that I want to regen the screen? Right now I'm using a clunky method of using a timer func to check a flag set by the GUI thread. The method works, but it's not very efficient.

08-04-2002, 07:29 AM

I would implement an interface function between the OGL thread and the GUI thread. The GUI sets the flag and invokes a redraw.
Actually pretty simple, have a look at semaphores. I assume you are coding Linux right?


08-04-2002, 10:31 AM
I donīt know what you are writing.
If you are writing an editor, or so, than i understand, that you donīt want many redraws. In this case you should just make a while loop, that checks for a boolean variable (inside your draw-thread). If it is true, redraw your scene, and set the variable to false.
In your app-thread (GUI-thread) just set the variable to true, when you want a redraw.
(In the while-loop you should use "Sleep (50);" so that the thread doesnīt use too much processingtime.)

If you are programming a game, or some other realtimeapplication, you should just draw your scene as often as possible (at least 30 times a second). You have to do this to get the "realtime" and animations, etc. And as a sideeffect you never have to bother about redraws ;-)


08-04-2002, 06:00 PM
If you go for the while loop is a condition variable much to prefer because it let you wait without any delay or wasted CPU cycles. Here is some information http://users.actcom.co.il/~choo/lupg/tutorials/multi-thread/multi-thread.html#thread_condvar