Best way to use Thread for display

Hi everybody,

I have a little issue to raise…

Let’s suppose we have a world map displayed (2D) with some moving object on it. We want to show the geographic coordinates (lat/long) when cursor moves on the map.
The easiest way to do this is to use glUnproject (and then cartographical unprojections).
The problem is : we must be in a good state to use GLU methodes. So we use a trick shown is the forum : set a flag and ask for a redisplay… Then in the display check the flag, do the unprojection and …PB

Choice 1. Exit the display without drawing the map -> good perf but if the mouse is always moving we don’t redraw the moving objects.

Choice 2. Redraw the map -> poor perf
???

I used the FPSAnimator then to limit the redraw / unproject
rate and i may used a king of timer to limit the mouse position refresh rate but …

Do anybody as experience to tell me if it’s worth to try a thread attaching / detaching procedure or if i should go on with the flag / fps timer / redisplay method? Because I may miss a little trick that makes a better life.

Thanks in advance for any Help.


Failing to plan is planning to fail

couldnt you have the thread that calls the mouse events handle to push the x, y positon onto a queue. The display method thread would then compute the unprojected values by pull data off the queue, do the glu call and then send them to wherever they have to go (just make sure things are all syncronized)

That trick thing seems like a messy solution.

Yes I can do what you say. But it seems to me that the display method may become a little messy with all the flags to do a lot of things…

But well, it’s a kind of main loop and it’s its purpose so i will go on like this.