I am currently working on a small project and I need to render to 2 different HWNDs. I have a PANEL which will display a small rendering of the currently selected unit and I have a SCROLLBOX which will display the map (note that it is a WIN32 Level Editor for a game I am working on). Now I need to render that correctly… the problem is however that if I set the HWND to the main form… the SwapBuffers function will fill the whole form with the backbuffer color (glScissor doesn’t work on that function). If I set the HWND to the Panel… I can draw only on the panel and not on the SCROLLBOX. I think I can get it working by creating 2 rendering contexts and using glShareList (provided that it actually shares textures) but I think there must be a better way. When I use the wglMakeCurrent(hDC, hRC) for the appropriate hDC it failed… I fixed that by setting the correct pixel format for the hDC… however… I still do not see anything where it is supposed to be…
If you know how to do it… please please please help me… it is driving me crazy!
First of all, you’re on the right track with using wglMakeCurrent(hDC, hRC) to reuse your render context with different dc’s. But, I think before you can make it current to another context, you must release it from the old one first…do this kind of thing:-
Care to elaborate on “doesn’t work”?
Believe me, it works. You must have made a mistake somewhere else in your code.
On creating your render context, you must first set the dc’s pixel format, then create the render context from any of the dc’s you’ve set the pixel format of.
I’m too tired to carry on…look, just post your code (the important stuff - ie. every single pixelformat/wgl/gl call, telling us where you’re calling them from).
Oh yeah… it works… I made a very very silly error… my CRenderSystem class had a SwapBuffers function which used the hDC managed by the class… after I used the pure SwapBuffers function it worked…
You set me on the right track. Thank you very much!