   Multi-threading render not drawing
  I am currently working on a multi-thread program that renders via OpenGL.  My program structure is having a main thread which creates 2 child threads.  One child thread is the win itself, another is the OpenGL render / drawscene etc.  Both child thread don't see the header files of each other, only the main thread does.The procedure is whenever we need to set up the render, we need to go through the GetDC, SetPixelFormat, MakeCurrent all kind of functions.  My program went through all those without any error message popping, but nothing drawn on the window.So, after all the debug process, I found that if the render child thread doesn't exist.  When I let the window child thread calls all the render function code, the program draws totally fine.  Then I try to recreate 2 threads again, and let the window calls the GetDC and past it to the render thread (from the main thread).  Again!  Nothing was drawn.Just wonder if anyone understand what I'm trying to say here.  And if anyone has every done similar coding before?  Or it just won't work on windows that way?Thanks.   
  Are you actually calling wglMakeCurrent and the like from the child render thread itself?   ;Quote:Original post by MENTALAre you actually calling wglMakeCurrent and the like from the child render thread itself?Yes, it that the problem?   ;  I don't think the wglMakeCurrent cost problem.  However, as long as the window is running under a child thread, nothing could be drawn at all.I tried not to let the window header file see the render header file, but keep it under the main thread.  It works just fine.  So, I think it's something to do with the compiler.I'm on VS 2005, any ideas?Thanks   ;  Haven't done multi-threaded rendering in a while. But, if I remember correctly you have to create the rendering context on the thread you are planning to use it from. You can't switch rendering contexts between threads.A little more information can be found in this thread- me   ;Quote:Original post by inferno82Haven't done multi-threaded rendering in a while. But, if I remember correctly you have to create the rendering context on the thread you are planning to use it from. You can't switch rendering contexts between threads.A little more information can be found in this thread- meMy coding is the render thread call all the GetDC, ChoosePixelFormat, .... wglCreateContext functions.  The window thread only creates a window and have a function that the main thread and get the HWND and pass to the render thread.  This way the render thread can use the correct HWND to GetDC and so on  -- that was my plan.  However, it just doesn't work!Again after all different methods of coding, I have to either let the window thread to be the main thread.  If the window thread is a child thread, then I can't use a render thread, but let the window thread call the render functions directly.  Which isn't what I wanted of course.I just wonder if it is possible to split the window and OpenGL render into 2 different threads.  By the other post, I don't see why it's not possible.   ;  I don't know why it isn't rendering but I do seem to remember that the child window needs to be created with a certain style. I think it was CLIPCHILDREN and also CS_OWNDC.More importantly, there is no advantage of calling GL functions from a second thread. GL calls aren't CPU heavy. They are mostly commands that go to the GPU. In some cases, data needs to be converted such as double to float (for vertices) or RGBA to BGRA (for textures) so this kind of thing is done by the driver on the CPU.What you should execute on a second thread is things like AI and physics (for people making games, I don't know what you are working on). These consume a lot of CPU power, specially physics.   