COpenGL class

The COpenGL class implements the default behavior for many Microsoft Windows specific tasks, such as window creation, window removal, or window resize events. Main task of the COpenGL object is to prepare viewing transformation for the rendering, and provide visual and API like interface for scene navigation. This way, the COpenGL class is taking care about all projection and modelview matrices manipulation for you. All other standard OpenGL API functions can be used freely side by side with the COpenGL class.

The COpenGL class provides several wrapper methods for the most commonly used OpenGL functions. That gives to an experienced Microsoft Windows user a “bit” more Microsoft Win32 API like interface.

The COpenGL object is usually embedded in CView, CWnd or another window-like MFC class. To create an OpenGL window using COpenGL class, perform the following steps:

1.Create a new class by inheriting a standard MFC window like class (usually CView or CWnd)
2.Embed a COpenGL variable into your class
3.Override PreCreateWindow, OnCreate, OnDestroy, OnSize members of your class. Overriden method function implementations must include appropriate the embedded COpenGL PreCreateWindow, OnCreate and OnDestroy method function calls. This step gives you the functionality of the OpenGL render context creation, removal and maintenance.
4.Override OnLButtonDown, OnLButtonUp, OnMouseMove, OnKeyDown, OnKeyUp members of your class. Method function implementations must include the appropriate embedded COpenGL OnLButtonDown, OnLButtonUp, OnMouseMove, OnKeyDown, OnKeyUp method function calls. This together with the COpenGL::SetInteractionMode method function gives you various interaction modes functionality and the advantage of easy navigation in 2D/3D space.

For further information about using COpenGL class, see COpenGLView and COpenGLWnd classes implementation available in the OglSample sample application source code.

See Also

COpenGL class members, COpenGL interaction modes, OglSample sample application, COpenGLWnd