Drawing inside a thread ???

Started by
2 comments, last by jvsstudios 18 years, 8 months ago
I have a really silly question to ask. I tried to draw inside a thread, but it does not seem to work. I'm writing a Windows App with VC++ and OpenGL. Originally, I had a function call that did my drawing. I would call it and it would do: glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBegin(GL_POINTS); define some points ...... glEnd(); glFlush(); It worked fine. I created a thread function using the same code. Now, I have a function which creates a thread to execute the same code as above. It does not work. I placed a break point inside the thread and it seems to be executing. I tried to force a OnPaint and Invalidate but it does nothing. What's going on?
Advertisement
Since your thread is a separate process, you need to have the thread create its own device context and render context in order to draw with it.
I think you need to call wglMakeCurrent in the thread you want to make openGL api calls from.
Actually, you are correct JanT (duh!). You can have multiple rendering contexts but you only need one device context. Then you should be able to use wglMakeCurrent inside of the thread.

This topic is closed to new replies.

Advertisement