We’ll start by building an SDI shell application with AppExpert, skipping most of the options for OLE functionality, drag and drop, and so forth. Figure 22-1 shows the first AppExpert dialog to create our shell OWL application.
You might also want to turn off the option to add Print and Print Preview. OpenGL scenes can only be rendered to a printer device context if the printer is a color printer supporting four or more bitplanes of color depth (16 or more colors). Printing to a monochrome laser or dot-matrix printer is possible but cumbersome. See the supplementary program GLPRINT in the \OpenGL11 subdirectory for an example of printing OpenGL scenes using the new features in OpenGL version 1.1.
You can leave the Application options at their default values, or go in and unselect the tool bars, status bars, and so forth. In addition, it’s important to select the window styles for Clip Children and Clip Siblings (which are required for OpenGL programs) in the MainWindow Basic Options page. Finally, select the SDI Client page and specify that the main window be derived from TWindowView, as shown in Figure 22-2.
Figure 22-3 shows the shell application after it has been built.
Before we start adding any OpenGL code to this shell, we have to add the OpenGL headers to the project. Add these two headers to the top of the owlglapp.h header file:
#include <gl\gl.h> // OpenGL Libraries #include <gl\glu.h> // GLU OpenGL Libraries
This will define the OpenGL functions and commands for all our OWL-based files for this project.
As a general rule, Borland automatically links to an import library that contains all the Win32 API functions. Sometimes these libraries will be out of sync with later releases of the operating system, and you will need to create your own import libraries and link to them. (See the discussion of Borland C++ in the Introduction to the book.)
We finish fleshing out our OpenGL-capable shell with OWL by adding message handlers for at least the first five of the messages listed in Table 22-1. These first five are required for a well-behaved OpenGL Windows application. The palette messages are only necessary if you are including palette-handling code so your application can run on 8-bit color systems. The WM_TIMER message is optional, as well, but is useful when you need to do timed events or animations. Our example later in this chapter makes use of WM_TIMER to produce an animated effect.
Figure 22-4 shows the ClassExpert window being used to add these messages.
At this point we have a complete skeleton application, with message handlers defined for window initialization and cleanup, painting, resizing, and palette handling. To this shell we will add the code that enables OpenGL to render in the window. This is accomplished by calling the Win32 functions specific for OpenGL, and then calling our OpenGL-specific code in the glcode.c module at the appropriate places.