OpenGL & MFC

Can someone point me to a good tutorial of how to setup OpenGL in an MFC environment? I am reading a ton of tutorials, but they explicitly state that I can understand this tutorial easily if I know how to setup the CView class to work with OpenGL (which I do not, hehe).

Any help would be appreciated, thanks a bunch!

I think this is a good starting point:

Hi !

Have a look at, there are some OpenGL tutorials that use MFC that might help.


Thanks for the tips. I found one tutorial that supplied a wrapper class in order to interface directly between MFC and OpenGL. If you are interested, this is the link:

It is designed for a MDI, but worked fine with my SDI implementation. Thanks again for the pointers; it sent me on the right track!


Try on this website. A good example can be found there.


Why when I resize the OpenGL screen in the MFC, the square isn’t centered ?.

In fact, if we change the size of the OpenGL IDC_SCREEN, the square isn’t centered ?

Make sure you update the matrices correct when the window is resized (gluPerspective or what ever you use).



Try to replace this command GetClientRect(&rect) with m_map_window.GetClientRect(&rect)in OnInitDialog();

That is used to get size of the window. The cube is not center because the width and height of windows is not based on the IDC_SCREEN.

[This message has been edited by cwc36 (edited 11-03-2003).]