Skip to main content
gamedev.net
🔒 Locked

Drawing inside a thread ???

Started by fathom88 Aug 5, 2005 at 8:46 AM 2 replies 550+ views
Original Post
fathom88
fathom88
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?
jvsstudios
jvsstudios
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.
JanT
JanT
I think you need to call wglMakeCurrent in the thread you want to make openGL api calls from.
jvsstudios
jvsstudios
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.