I tried to run two opengl windows (without GLUT) in an application. There is a problem when I quit (kill) the 2nd window and go back to the 1st one (a memory error…).
Do I have to kill the 1st window before running the other or just change the current context ?
OpenGL state variables are OS based and not application based. I guess this means that there can exist only one OpenGL window. This will mean that only one window can display OpenGL images. So if you want to switch between windows, you should properly change the rendering contexts.
I use multiple windows with opengl in VB all the time. The trick is to have
wglMakeCurrent(Me.hdc, m_hRC)
in your form’s Activate and Resize events. “Me” in this case, is the form, if you are writing directly to the form. You might be writing opengl to a picture window. In that case, use the hdc of the picture window.
If the problem is only when you kill the window, you may not be releasing the rendering context properly. In your Form_Unload command you need
wglMakeCurrent(Me.hdc, 0&)
Also, before this call, release any display lists, etc that you may have created. This will keep memory happy.