056 058














Open GL Super Bible:Learning OpenGL with the AUX Library















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





Finally, Some 3D!
Thus far, all our samples have been simple rectangles in the middle of the window; they either scaled to the new window size or bounced around off the walls. By now you may be bouncing off some walls of your own, waiting anxiously to see something in 3D. Wait no more!

As mentioned earlier, we have been drawing in 3D all along, but our view of the rectangle has been perpendicular to the clipping volume. If we could just rotate the clipping volume with respect to the viewer, we might actually see something with a little depth. However, we arenłt going to get into coordinate transformations and rotations until Chapter 7. And even if we started that work now, a flat rectangle isnłt very interesting, even when viewed from an angle.
To see some depth, we need to draw an object that is not flat. The AUX library contains nearly a dozen 3D objectsfrom a sphere to a teapotthat can be created with a single function call. These called functions are of the form auxSolidxxxx() or auxWirexxxx(), where xxxx names the solid or wireframe object that is created. For example, the following command draws a wireframe teapot of approximately 50.0 units in diameter:

auxWireTeapot(50.0f);

If we define a clipping volume that extends from -100 to 100 along all three axes, wełll get the wireframe teapot shown in Figure 3-12. The teapot is probably the best example at this point because the other objects still look two-dimensional when viewed from a parallel projection. The program that produced this image is found in this chapterłs subdirectory on the CD in teapot.c.


Figure 3-12  A wireframe teapot
If you change the wire teapot to a solid teapot with the command


auxSolidTeapot(50.0f);

youłll see only a red outline of the teapot. In order to see relief in a solid-colored object, you will need to incorporate shading and lighting with other OpenGL commands that youłll learn about in Chapter 9 and later.

For further study of the AUX library objects, see the samples AUXWIRE and AUXSOLID on the CD in this chapterłs subdirectory. These samples make use of the glRotatef() function (explained in Chapter 7), which spins the objects around all three axes of the viewing volume. Some of these objects make use of the utility library, so be sure that you link with glu32.lib when using these objects yourself.
Summary
In this chapter we have introduced the AUX library toolkit and presented the fundamentals of writing a program that uses OpenGL. We have used this library to show the easiest possible way to create a window and draw in it using OpenGL commands. You have learned to use the AUX library to create windows that can be resized, as well as to create simple animation. You have also been introduced to the process of using OpenGL to do drawingcomposing and selecting colors, clearing the screen, drawing a rectangle, and setting the viewport and clipping volume to scale images to match the window size. Wełve also discussed the various OpenGL data types, and the headers and libraries required to build programs that use OpenGL.

The Auxiliary library contains many other functions to handle keyboard and mouse input as well. Microsoftłs implementation of the Aux library contains Windows-specific functions that enable access to window handles and device contexts. You are encouraged to explore the upcoming reference section of this chapter to discover other uses and features of the AUX library. Youłll also want to examine and run the other Chapter 3 samples on the CD.
Reference Section
auxIdleFunc

Purpose
Establishes a callback function for idle processing.
Include File
<glaux.h>
Syntax
void auxIdleFunc(AUXIDLEPROC func);
Description
Specifies the idle function func() to be called
when no other activity is pending. Typically used for animation. When
not busy rendering the current scene, the idle function changes some
parameters used by the rendering function to produce the next scene.


Parameters

func

This function is prototyped as
void CALLBACK IdleFunc(void);
This is the user-defined function used for idle processing. Passing NULL as this function name will disable idle processing.
Returns
None.
Example
See BOUNCE and BOUNCE2 examples from this chapter.
See Also
auxSwapBuffers, auxMainLoop, auxReshapeFunc






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:
056 058
v 02 058
052 056
058 14sept61
dg0561
2010 03, str 058 064
F F 056
058 ADMM
058 Malarstwo rokokowe we Francji
dg0568
The Modern Dispatch 056 Executive Solutions
dg0567
058 59

więcej podobnych podstron