   Using Multiple Rendering Contexts
  I am writing a windowed program that contains child windows.What I want to do is restrict rendering to the client area of the window that calls the rendering code (in a WM_PAINT message).  That should make all coordinates relative to each windows client area and clipping should occur correctly.  Currently when I tell OpenGL to render a triangle (from within a child window procedure) at 0,0 (orthogonal) it is ALWAYS at 0,0 on the PARENT window.I am assigning each window its own Device Context using the CS_OWNDC window style.If I dont use wglMakeCurrent I get what is described above, if I do I get a weird colored mess.Can anyone explain how to correctly implement child windows while using OpenGL?If anyone needs/wants more explaining or some code let me know.Thanks!Will Reynard 
  You can use the same gl context for multiple device contexts, just make sure that you set the pixel format for EVERY device context to be the same.  From the sounds of things (garbled colors) this might be you''re problem.;  So how do I specify which DC is being drawn to?  I know you can attach a DC to a window, but even from within that windows procedure I was drawing at 0,0 on the parent.  That should have been clipped right?So you''re saying I need multiple DC and only one rendering context?A bit confused now.. I ''ll do some reading.-Will ;  You can get the device context for each child window using    HDC hdc = GetDC(hwnd);Then set the pixel format as normal for each of those device contexts.  Make sure that all of the pixel formats are compatible, for simplicity you could make them all the same.  Then create you''re gl context using one of the device contexts, it doesn''t matter which you use, all that matters is that they have the same pixel formats.  Then whenever you want to render into a child window call    wglMakeCurrent(child_hdc,glcontext);Where child_hdc is the device context of the child you want to render into.  I haven''t actually done this myself before, but I''m fairly sure it should work.;  Thanks for the post joanusdmentia but i've already got that part figgured out.  What I have is a graphics class that has two instances, one for the parent and one for the child window.  In the class, everytime I call a function that uses any OpenGL function I first call wglSetCurrent(hDC[myDCIndex], hRC[myRCIndex]).  hDC and hRC are arrays of HDC and HGLRC structures.  They are both static members of the graphics class.// Add class, functionsclass GRAPHICS {public: // At top so they're easy to find// bunch of functionsprivate:// Variables static HDC hDC[MAX_DC];static HGLRC hRC[MAX_RC];// rendering contextstatic int numTextures; static int numRC;static int lastTexId;HWND hwnd;int myDCIndex, myRCIndex;PIXELFORMATDESCRIPTOR pfd;int clientWidth, clientHeight;// Function Prototypesvoid SetupPixelFormat();}; // End class GRAPHICSI also use glShareDisplayLists() on the two hRC's so I can share textures between them.What I am currently having a problem with is that everytime I try to render to the child window, it doesn't render anything.  However, setting the background clear color and use glClear() to clear the buffer and depth buffer, works liks its supposed to (in the child window).I dunno if that help explain the situation, but I will probably figgure it out if I keep searching.  If there are any Win32/OpenGL pros out there, I would greatly appreciate an explanation of whats happening.Peace,Will [edited by - AcidInjury on August 6, 2003 3:30:44 AM] [edited by - AcidInjury on August 6, 2003 3:32:01 AM];  If glClear() is working then rendering should also work.  Check that your projection and modelview matrices are correct, and that you're viewport is also set correctly.  A test I use to check that rendering is working is to set both matrices to identity and the viewport to the window's client area (which I imagine you would be doing anyway), and then draw a single 2d triangle with points (-1,-1),(0,1),(1,-1).  The triangle should fit nicely in the window if everything is setup properly. [edited by - joanusdmentia on August 7, 2003 7:17:36 AM];  To elaborate on the previous post... (in short form), it sounds like a viewport problem.... glViewport() !! ;  I am doing exactly the same kind of application as you, and I got well with one different DC and RC for each one of my child windows. This works because I know the number of windows that I can have in my application, if this number is not fixed, then you could have a dynamic array, or something like this.I just need to remember to use wglMakeCurrent before drawing to each window, and it works nicely.This way, the problem of clipping shall be dealt with the same way you would for a single window application.And you don''t need to use CS_OWNDC, I''ve seen in some tutorials that this is no good for OpenGL windows. All you need is a different window handle (HWND) for each window, so you''ll have a different DC for each window naturally.I hope this helps ! 