Recently, I studied up on how to write OpenGL programs. I have tried GLUT, a window system independent toolkit for
writing OpenGL programs. But I don't like it since it is C-style and need an additional glut32.dll. I have
played with WTL for a while, I really like this great framework for developing Win32
program, so I decided
to write OpenGL programs using WTL.
Actually, WTL DOES provide OpenGL support in
atlgdi.h. If you didn't define
you should be able to use
wglCreateContext, etc. However, you have
to do a lot of work every time to write an OpenGL program. For simplification, I developed a class
which can be easily plugged into your WTL programs.
COpenGL is a template class which implements most necessary work for OpenGL. It is defined in
atlopengl.h. For using it in your program, you have to do the following steps: (assume your main program
Cube.cpp, your OpenGL window is
#include <atlopengl.h> in
- derive your OpenGL window
- chain message map to
COpenGL by adding
CMainFrame's message map.
- if you have implemented
OnCreate function in
bHandled = FALSE;
- implement three functions in
OnInit(), OnRender(), OnResize()
- (optional) if you want to do animation, derive
CIdleHandler and implement
OnIdle. In additional, change
(you have to do this, otherwise, you cannot get animation).
Similarly you can use it in your view windows. Read
and the demo project for more details.
is still very simple, but it is a good start for writing OpenGL programs using WTL.
Partial codes in demo project generated by "OpenGL AppWizard" developed by Ulf Öhlén.
See here for details.