PDA

View Full Version : OpenGl cross thread calls under WIN32 OS



husakm
05-26-2002, 11:24 PM
I have following problem: My application is running in 2 threads. It is nessesery to execute OpenGl commands from a different thread than the one in witch OpenGl was initializated. It looks like it does not work under Win32 API - opengl commands are accepted only from the thread witch had intilaized the OpenGl. I can not use only one thread (the aplication architecture is fixed by some external standard). Some idea what to do (e.g. how to jump from on thread to another, execute OpenGl , jump bakc) ?

Mete Ciragan
05-27-2002, 01:19 AM
I've encountered the same problem. I found, that certain commands like glDeleteTextures() cannot occure between glBegin() glEnd(), so you have to lock the critical sections.

I just want to know, if it is possible to invoke glDeleteTextures() from another thread?

For any hints I thank in advance,
Mete Ciragan

sbennett
05-27-2002, 03:25 AM
You definitely need to call wglMakeCurrent for each thread, you may need a new DC or RC for each thread. I'm not sure exactly which handles can be passed between threads.

marcus256
05-27-2002, 03:28 AM
Are you calling GL commands from both threads? That is a very risky thing, and generally a no-no thing to do. As I understand it both threads share the same OpenGL state, so any state change in one thread affects how the other thread behaves (and most OpenGL API calls are state changes).

husakm
05-27-2002, 04:12 AM
marcus: It is exactly what I must to do. Call OpenGl commands from both threads.
I can putt all OpenGl commands in each thread in one critical section - Ii hope it can help.