Jump to content
  • Advertisement
Sign in to follow this  
fathom88

OpenGL Drawing inside a thread ???

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I think you need to call wglMakeCurrent in the thread you want to make openGL api calls from.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!