Open GL MFC Wrapper

This is more just an esoteric question, but the answers might be interesting.

Recently while looking for examples using Open GL in MFC, I noticed that the majority of examples derived an Open GL class from CView. Although this approach works well if you only want to display in a Doc/View window, the main disadvantage is that it can’t be used anywhere else, such as a CDialog or a non Doc/View architecture.

Then I ran across an article in Dr. Dobb’s where they derived a GL class from CWnd. This has the advantage that it supports any class, such as CDialog, CView, etc. But it becomes a little tricky when trying to create a CView from this class.

The approach I’ve taken for the last couple of years was to create a base GL class I call CGLWindow which isn’t derived from anything. In this case the user must pass in the window handle when the GL class is created. This has the advantage that it works with any class (CWnd, CView, CDialog, etc). The big disadvantage is that all messages (such as OnSize and mouse messages) have to be explicitly passed to the GL class from its owner, whether it is a view or dialog, etc.

Anyway, I was just looking for comments regarding which method is best. Or maybe there is a still better approach that I haven’t even thought of.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.