Open GL Super Bible:OWL-Based OpenGL Programming
To access the contents, click the chapter and section titles.
Open GL Super Bible
(Publisher: Macmillan Computer Publishing)
Author(s): Waite group Press
ISBN: 1571690735
Publication Date: 08/01/96
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)==
'4')
); }
function
bookMarkit() {varurl="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Previous
Table of Contents
Next
Build the Shell
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.
Figure 22-1 Starting a new SDI application with AppExpert
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-2 Set the Client window to be derived from TWindowView
Figure 22-3 shows the shell application after it has been built.
Figure 22-3 AppExpert-generated vanilla SDI application shell
Add the Headers
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.)
Add the Message Handlers
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.
Table 22-1 Typical Messages Handled by an OpenGL Application
Message
Purpose
WM_CREATE
Window creation. Sets required window styles and creates the rendering context.
WM_DESTROY
Cleans up by deleting the rendering context.
WM_ERASEBKGND
Tells Windows GDI not to erase the background when the window needs to be redrawn.
WM_PAINT
Handles any required painting or repainting of window. Call the OpenGL rendering code here.
WM_SIZE
Calls code to modify OpenGL viewport information.
WM_QUERYNEWPALETTE
Application gets the chance to realize its palette.
WM_PALETTECHANGED
Application gets the chance to respond to palette changes.
WM_TIMER
For timed events such as animation.
Figure 22-4 shows the ClassExpert window being used to add these messages.
Figure 22-4 Adding message handlers with the class expert
Fleshing Out the Shell
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.
Previous
Table of Contents
Next
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Wyszukiwarka
Podobne podstrony:
654 Podział zysku i pokrycie straty za 2009000 654654 ind (2)654 07 (2)654 indCh20 pg645 654więcej podobnych podstron