source code - OpenGL Drawing on MFC dlg(using COpenGLControl class)

This  post introduces how to drawing opengl on the mfc dialog.
If we are using COpenGLControl class, this work is very easy and simple.

Fi rstly, get the COpenGLControl class in the web or on this.

1. In the ~Dlg.h, Add header file and member variable

#include "OpenGLControl.h"
COpenGLControl m_oglWindow;

2. Add below source code in the OnInitDialog() function.

CRect rect;
// Get size and position of the template textfield we created before in the dialog editor
// Convert screen coordinates to client coordinates
// Create OpenGL Control window
m_oglWindow.oglCreate(rect, this);
// Setup the OpenGL Window's timer to render
m_oglWindow.m_unpTimer = m_oglWindow.SetTimer(1, 1, 0);

* You have to set picture box option as "Visible is False".

The source code is here.

No comments:

Post a Comment