Jump to content
  • Advertisement
Sign in to follow this  
emanon12

OpenGL Threading issue with OpenGL

This topic is 4703 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

Hi all, I have a multi-threaded application. One of the images I am drawing takes a while to build, however, it is not particularly important that happen quickly, just that it happens. Thus I decided to push this off to another thread and have the other thread build this image while my application continues on it's merry way. Unfortunately, rather than continuing with a nice smoothly operating and refreshing application for some reason I am blocking on the background thread while it generates the img. I have tried the following without success: 1. I checked to make sure my drawing/ui thread has a different id than the background thread. 2. I removed all mutexes to make sure I hadn't unbenownest to me created a block. 3. Yes, I made sure that the background thread calls sleep/yield during it's work. 4. I tried calling glutPostRedisplay 5. I tried lowering the priority of the background thread 6. I have done significant profiling to check to make sure that the slowness is due to generating this img. Is there something about the interaction with the main ogl thread I am not understanding? Are there suggestions for other things I can try? Obviously I can re-architect this so I don't have the large img to deal with to begin with, but if that was simple/easy/desirable I wouldn't be messing around with background thread. Also, I would like to understand why this behavior is occuring. Other background: This is C++ I am using OpenGL/glut. I am on a Windows XP machine. I am posting here as I am concerned that this is some ogl specific idiosyncrasy occurring. Thanks for your suggestions.

Share this post


Link to post
Share on other sites
Advertisement
I'm doing a very similar thing, and I found thread syncing was a pain. first, don't rely on Sleep(0). use events (CreateEvent for win32) mixed with Sleep(0)s (and NOT Sleep(1)). read the MSDN page on Sleep and you'll see what Sleep(0) does and hopefully you'll be able to properly make good us of it. if you have any questions, feel free to ask. you didn't really gve much details in your post, so I wasn't able to help much...

Share this post


Link to post
Share on other sites
be very careful using Sleep(0). first it doesn't yeild the CPU instantly, and the delay could be up to 15 ms. use it only when you still have work to do, not waiting for vents, yet still want to play along nicely with other threads. try to keep your synchronization to events, and structure it properly. Sleep(0) most o the time makes my OpenGL Thread take most of the process time, which doesn't sound like a bad thing until you remember another thread is doing physics/world updates/input and processing scripts...

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!