I am making an application using VC++ MFC where i have two different opengl windows. I have followed the tutorial of enter link description here
I am able to succes
OpenGL is a thread global context state machine. That means, that you must switch the OpenGL context of the current thread to the right window so that drawing commands end up where you want them.
In every member function in which you make OpenGL calls put at the beginning
wglMakeCurrent(hdc, hrc);
and before you leave the function (i.e. at the end, or before a return)
wglMakeCurrent(NULL, NULL);
BTW: You can use a single OpenGL context for any number of windows, as long as they share the same visual properties, i.e. if you called SetPixelFormatDescriptor
with the same PFD for each window you want the context to use with.
Last but not least, all of the code found in OnSize
and all of the "Basic Setup" found in onInitialize
should be put into the drawing code. Your OnDraw
is not very useful either.