I was trying to create multiple windows in OpenGL by creating an OpenGLwnd class derived from CWnd and then defining as many as I needed as children of my main window. However only the last one will render and it does not render properly. I remember vaguely that the device context may be locked to one window. Is this the source of the problem? If so what solutions exist?
I was thinking of trying multiple viewports, but was wondering if switching between viewports will create too much overhead?
Yes !, you must use wglMakeCurrent(…) before you render anything in your OpenGL windows to select the context to use.
It does have some overhead, if just need 4 viewports or something like that I would say it’s better to use one window and split it up with glViewport().
This has been discussed in the past on this list so if you do a search you will find more about it.
Thanks. Much appreciated.
Just a follow up. If I create two windows via Viewports and double buffering is enabled, I will have to redraw each viewport each frame? If so, does it mean that swapbuffers clears out the back buffer each time it is called, hence previous images can’t be reused?
If this is true, what if I have an image where only a small section of it changes at a time? I was hoping to just change that section (no depth buffer being used) instead of redrawing the image. The section is random, so it makes a mess of display lists. Also the entire image it takes long to display (9 secs) since I don’t have an OpenGL compliant card (I am hoping to make the program useable on PC’s without OpenGL acceleration). The section that changes is typically less than 10 tri’s which draws in no time. I’ve heard about auxillary buffers so theoretically I can update an auxillary buffer that won’t get redrawn then blit the image to the back buffer. However I understand that not all PCs support an auxillary buffer.
What’s the best thing to do then?