Timers and OpenGL


in my application I have two rendering contexts. One context is used for normal rendering, and the other context is used for dynamically creating textures in a pbuffer.

Now I would like to use a timer to switch from the pbuffer context to the normal rendering context at constant time intervals, in order to achieve a constant frame rate.

Unfortunately, using the linux system timer ( setitimer(ITIMER_REAL, …) ) causes segmentation faults or even total system crashes. However, there are no crashes when I block the timer while OpenGL functions are being executed. In the callback function invoked by the timer’s SIGALRM signal, other OpenGL functions are called - so might the reason for these crashes be that OpenGL functions are not reentrant?

Any ideas are welcome!

[This message has been edited by andy1 (edited 05-06-2002).]

Can you just post a flag somewhere when your timer goes off. Then, the next time you get a free second, check the flag and if it is set go do your interrupt.
This way you guarantee you are not trying to do several opengl things at once.

But since I have two rendering contexts, shouldn’t it actually be possible to do several opengl things at once?

So when the timer expires, I would like to change the context, do some opengl rendering, and then switch back to the other context.

I don’t directly know the answer to your question. I had a flight simulator with a separate thread that loaded textures from a file. Whenever I tried to create Opengl textures in this second thread I had serious issues. I ended up just doing it in the main thread.
Good luck.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.