Archived

This topic is now archived and is closed to further replies.

MrFreeze

Two threads rendering to same window...

Recommended Posts

MrFreeze    122
Hi, How can I solve the following problem: I create an OpenGL rendering window within a thread A and render a scene from that thread constantly (inside a loop). Inside of thread A I also handle messages for the rendering window (mouse movements, etc.). Now I have the possibility from another thread (thread B) to turn of the automatic rendering of thread A (thread A is still active, just the rendering is turned off) and to call from withing thread B the rendering routine. But... it doesn''t work! When I call the rendering routine from thread B, OpenGL commands are simply ignored. Do I have another rendering context from thread B? How can I simply and quickly fix this problem? Thanks

Share this post


Link to post
Share on other sites
navigator    122
I suppose you first deselect the context in thread A, then select it in thread B. Check return codes - are both these operations successful?

If the context selection call in thread B fails, or sometimes fails and sometimes not, you may have bug in thread synchronization - ensure that the context is really deselected from thread A when you are trying to select it from the thread B.

Hope this helps...

Have a nice day,


---
Never trust a Troglotroll.

Share this post


Link to post
Share on other sites
sbennett    124
to select a context(in Windows):

wglMakeCurrent(hdc, hrc);

where hdc is windoze DC, hrc is your GL rendering context.

to deselect:

wglMakeCurrent(NULL, NULL);

Share this post


Link to post
Share on other sites