Creating an OpenGL window in a MFC application

There are two ways to create an OpenGL window in your MFC application source code.

1.Use the COpenGLWnd or COpenGLView class. The COpenGLWnd and COpenGLView classes implementation is delivered with the OglSample sample application in the MfcClassGL.cpp and MfcClassGL.h files. You may also derive your own class from the COpenGLWnd class.
2.Embed the COpenGL object into the class you derived from a standard MFC window like class (CWnd, CView etc.). Process the PreCreateWindow, OnCreate, OnDestroy, OnSize window messages using the COpenGL class PreCreateWindow, OnCreate, OnDestroy, OnSize methods. This step gives you the functionality of the OpenGL render context creation, removal and maintenance. Process the OnLButtonDown, OnLButtonUp, OnMouseMove, OnKeyDown, OnKeyUp window messages using the COpenGL class OnLButtonDown, OnLButtonUp, OnMouseMove, OnKeyDown, OnKeyUp methods. This together with COpenGL::SetInteractionMode method function gives you various interaction modes functionality and the advantage of easy navigation in 2D/3D space.

See the OglSample application COglSampleView class implementation for more information.

See Also

OglSample sample application, Project settings