Graphics Links at Holmes3D.net

OpenGLSkeleton

Note: The below is a copy of the Project 0 warm-up project that OpenGLSkeleton was part of. You are welcome to download the source and follow along, ignoring instructions that have to do with project submission and grading. The source code on the OpenGLSkeleton home page is an extended version of the solution to this set of instructions.
Back to the OpenGLSkeleton Home Page


Project 0

Warm-Up Project


This is a warm-up project, intended to allow you to become comfortable with the structure of a Visual C++ program using MFC and OpenGL. Completion of the entire project should take you about three hours, although you may expect to go faster or slower depending on your level of experience with Visual C++. You will be following the step-by-step instructions that are given below.

This project consists of the following steps:

And that's it!


Step-by-Step Instructions


Creating a Project

In this section you will create your own Visual C++ project, named after yourself. Note that submissions named "project0" or "openglskeleton" or anything other than your own name will not get full credit. If your name is very long, you may abbreviate words.

Adding Skeleton Functionality

In this section you will be copying in OpenGL code from the provided skeleton. The code is well documented so that you can gain an understanding of what it is doing. You are not expected to understand OpenGL or write your own OpenGL code here. As you are copying, read the comments and take note of what types of functions go in which file.

A Detour for Some Explanation

The text book uses the GLUT windowing system. It functions very similarly to the MFC system, but with a bit less sophistication and a lot less complexity. The functions that you added have very close correspondence to the GLUT functions used in the text. OnDraw is called when the window needs to be re-drawn. This is like the glutDisplayFunc() callback in GLUT. If you want a display to be done, you can call Invalidate, which is like the glutPostRedisplay() call. OnSize, which you added for the WM_SIZE message, is called when the window size is changed. This is like the glutReshapeFunc callback. The OnPreCreate and OnCreate functions are called while the window is being created, allowing it to be customized to use OpenGL. OnDestroy is called when the window is being destroyed (The program is quitting), so that the OpenGl resources can be released. You will see glutKeyboardFunc and glutMouseFunc callbacks in the book, these roughly correspond to the OnKeyDown, OnLMouseDown, OnLMouseUp, etc. functions you can add through the Class Wizard. The MFC functions are much more specific, and you can do something like OnLButtonDblClk to respond only to the left mouse button's double clicks, which would take a bit of tinkering in GLUT.

Adding a Color Chooser

In this section you will add a menu item and attach a menu handler to it. The menu handler will use a standard Windows dialog box (The color chooser) to get input from the user. You will then use that input to change the OpenGL state.


Toggling Inset Squares

In this section you will add a menu item and menu handler that toggle a boolean variable. You will also add a menu update handler that allows the user to easily see the state of the boolean variable when they view the menu.


Creating a Dialog

In this section you will create a simple MFC dialog using Visual C++'s dialog editor. This is a very powerful editor, and you may want to play with some of the other controls if you have the time.

Using Your Dialog

In this section you will connect the dialog that you created to a menu item/menu handler and react to the input received from the user through the dialog.

Congratulations

You've got a working 3D OpenGL program!


Back to the OpenGLSkeleton Home Page




Graphics Links at Holmes3D.net
Page contents copyright Ryan Holmes