Site Contents

Home
Programming
OpenGL Demos
MFC OpenGL
Tutorial 1
Graphics Demos
Jonathan
Travel
Garden

Main Guestbook
Help!
Contact Us

Forum

ISP Referral

Page Validation

Valid XHTML 1.0!
Valid CSS!

tutorial 1 - simple project

Getting Started

To get started open up MS Visual C++ (hereafter know as MSVC) and if you want to, your project workspace. Goto File|New and choose to create a new MFC AppWizard Project. Choose a name for your project, I called mine "MFC_Tutorial_01".

Create a new project (click to enlarge)

Clicking on okay in the new project dialog window automatically runs the MFC AppWizard and asks you what type of application you want. For this tutorial we need to select Dialog based.

AppWizard Step 1 (click to enlarge)

Next, the AppWizard asks us what features we want our dialog application to have. We don't want to clutter up the code for this tutorial, so uncheck all the options and just leave the 3D Controls option checked (although we won't use any in our application, it will display standard windows interface controls in the familiar 3D fashion that we are all used to).

AppWizard Step 2 (click to enlarge)

You don't have to change any options in the next dialog. By default it will add comments to the generated code to help you understand what everything does. I recommend you leave them enabled until you are comfortable with MFC.

AppWizard Step 3 (click to enlarge)

At Step 4, you will experience the horrible class names that MFC generates! You will see two classes listed in front of you, CMFC_Tutorial_01App and CMFC_Tutorial_01Dlg. The first one is the "Application Class" which you use in place of the winmain function you use with Win32. The "Dialog Class" will be your window - it is here where you will place your OpenGL code. To make your code easier to understand, I would suggest renaming the classes before you click on Finish. I called mine "CApp" and "CDlg" then renamed the dialog class source files to "Dlg.h" and "Dlg.cpp" respectively. Now you can click on the Finish button!

Original dialog:

New class names:

AppWizard Step 4 (click to enlarge) AppWizard Step 4 with new class names (click to enlarge)

The AppWizard closes and leaves us with a very simple dialog window with OK and Cancel buttons on it. I suggest you compile and execute the programme now to make sure that it works. When you execute it, you should be presented with a dialog window that looks very much like this:

AppWizard Generated dialog (click to enlarge)

(Before you read on, you may want to add opengl32.lib to the project settings, if you haven't already done so).

 

Part 1: Introduction Part 2: Getting Started

Part 3: Creating a Window Part 4: Using OpenGL

Go to Top

Page Stats

Page last updated: 19:21 GMT on Saturday 1 January 2005
This page has had 4941 hits since 27 March 2004. Last viewed on 6 February 2012.
It took the server 0.1896639 seconds to generate this page.

Site designed and maintained by Jonathan Copelin
Go to homepage