   Threading issue with OpenGL
  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 glutPostRedisplay5. I tried lowering the priority of the background thread6. 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.   
  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...   ;  When do you use sleep(0)?  I'm curious because I'm doing muliple thread rendering as well.   ;  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...   