Opengl Performer™ Getting Started Guide
Total Page:16
File Type:pdf, Size:1020Kb
OpenGL Performer™ Getting Started Guide Version 3.2 007-3560-005 CONTRIBUTORS Written by George Eckel, Ken Jones, and Tammy Domeier Illustrated by Dany Galgani, Chrystie Danzer, and Chris Wengelski Production by Karen Jacobson Engineering contributions by the Performer Team, including Sharon Clay, Tom McReynolds, Don Hatch, Jenny Zhao, Remi Arnaud, Yair Kurzion, Rob Mace, Marcin Romaszewicz, Allan Schaffer, Tom Flynn, Radomir Mech, Angus Dorbie, Paolo Farinelli, Alexandre Naaman, and Stace Peterson. COPYRIGHT © 1997, 2000, 2002–2004 Silicon Graphics, Inc. All rights reserved; provided portions may be copyright in third parties, as indicated elsewhere herein. No permission is granted to copy, distribute, or create derivative works from the contents of this electronic documentation in any manner, in whole or in part, without the prior written permission of Silicon Graphics, Inc.whole or in part, without the prior written permission of Silicon Graphics, Inc. LIMITED RIGHTS LEGEND The software described in this document is "commercial computer software" provided with restricted rights (except as to included open/free source) as specified in the FAR 52.227-19 and/or the DFAR 227.7202, or successive sections. Use beyond license provisions is a violation of worldwide intellectual property laws, treaties and conventions. This document is provided with limited rights as defined in 52.227-14. TRADEMARKS AND ATTRIBUTIONS Silicon Graphics, SGI, the SGI logo, InfiniteReality, IRIX, OpenGL, O2, Octane, and Onyx are registered trademarks of Silicon Graphics, Inc., and Geometry Pipeline, GL, Graphics Library, InfiniteReality4, Inventor, IRIS GL, Onyx4, OpenGL Multipipe, OpenGL Optimizer, OpenGL Performer, OpenGL Volumizer, Power Onyx, Silicon Graphics Prism, UltimateVision, and VPro are trademarks of Silicon Graphics, Inc., in the United States and/or other countries worldwide. CATIA is a registered trademark of DASSAULT SYSTEMES S.A. Designer’s Workbench is a trademark of Centric Software, Inc. Maya is a registered trademark and Wavefront is a trademark of Alias Systems, a division of Silicon Graphics Limited in the United States and/or other countries worldwide. MIPS, R4400, and R8000 are trademarks or registered trademarks of MIPS Technologies, Inc., used under license by Silicon Graphics, Inc. OpenFlight is a registered trademark of Multigen. Motif is a registered trademark and OSF/Motif and the X Window System are trademarks of The Open Group. Netscape is a trademark of Netscape Communications Corporation. DI-Guy is a trademark of Boston Dynamics, Inc. Lightscape is a trademark of Autodesk, Inc. Linux is a registered trademark of Linus Torvolds. Weather Environment Simulation Technology and WEST are trademarks of Southwest Research Institute. Microsoft, Windows, and Windows NT are registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Red Hat is a registered trademark of Red Hat, Inc. All other trademarks are the properties of their respective owners. Yosemite image copyright of Delphi International. DI-Guy image copyright of Boston Dynamics Inc. Palace image copyright of Pinxi. Clouds image copyright of SWRI. Ocean and Marine Effects Simulation image copyright of Paradigm Simulation Inc. PATENT DISCLOSURE Many of the techniques and methods disclosed in the Getting Started Guide are covered by patents held by Silicon Graphics including U.S. Patent Nos. 5,051,737; 5,369,739; 5,438,654; 5,394,170; 5,528,737; 5,528,738; 5,581,680; 5,471,572 and patent applications pending. New Features in This Guide This revision of the guide documents OpenGL Performer 3.2, which has support for the following features: • Silicon Graphics Prism visualization systems • OpenGL 2.0 Shading Language • Scene graph optimizer • New compositor API • Maya 6.0 exporter 007-3560-005 iii Record of Revision Version Description 001 1997 Original publication. 002 November 2000 Updated for the 2.4 version of OpenGL Performer. 003 December 2002 Updated for the 3.0 version of OpenGL Performer. 004 December 2003 Updated for the 3.1 version of OpenGL Performer. 005 November 2004 Updated for the 3.2 version of OpenGL Performer. 007-3560-005 v Contents New Features in This Guide. iii Record of Revision . v Figures . xvii Tables . xxi About This Guide. xxiii What Is OpenGL Performer? . xxiii Why Use OpenGL Performer? . xxiii What You Should Know Before Reading This Guide . xxiv What This Guide Contains . xxv Part One: Overview of OpenGL Performer . xxv Part Two: Programming with OpenGL Performer . xxv Conventions . xxvi Internet and Hardcopy Reading for the OpenGL Performer Series . xxvii Reader Comments . xxviii PART I Overview of OpenGL Performer 1. Getting Acquainted with OpenGL Performer . 3 Installing the Software . 3 007-3560-005 vii Contents Exploring the OpenGL Performer Sample Scenes with Perfly . 3 Locations of Perfly and Example Source Code . 4 Starting and Quitting Perfly . 4 Basic Perfly Controls . 5 Looking Around . 5 Approaching the Building . 5 More Controls . 6 Other Motion Models . 7 The Use of Instances . 9 Loading Databases into OpenGL Performer . .9 Going Beyond Visual Simulation . 10 2. OpenGL Performer Basics . 13 OpenGL Performer Applications . 13 Library Structure of OpenGL Performer. 13 Library Features . 16 Overview of the OpenGL Performer Library Structure . 19 libpf—Visual Simulation Library . 19 libpr—High-Performance Rendering Library . 23 libpfdu—Geometry Builder Library . .26 libpfv—A Graphical Viewer Library . 29 libpfmpk—A Configuration-Import Library . 30 X and IRIS IM . 30 Porting from IRIS GL to OpenGL. 31 Survey of Visual Simulation Techniques . 31 Low-Latency Image Generation . 33 Consistent Frame Rates . 34 Rich Scene Content . 35 Texture Mapping . 37 Character Animation . 38 Database Construction . 40 viii 007-3560-005 Contents PART II Programming with OpenGL Performer 3. OpenGL Performer Programming Interface . 45 General Naming Conventions . 45 Prefixes. 45 Header Files . 46 Naming in C and C++ . 46 Abbreviations . 47 Macros, Tokens, and Enums. 47 Class API . 47 Object Creation . 47 Set Routines . 48 Get Routines . 48 Action Routines . 49 Enable and Disable of Modes . 49 Mode, Attribute, or Value . 49 Base Classes . 50 Inheritance Graph. 51 Libpr and Libpf Objects . 53 User Data . 53 pfDelete() and Reference Counting . 54 Copying Objects with pfCopy() . 58 Printing Objects with pfPrint() . 58 Determining Object Type . 60 4. Introduction to OpenGL Performer Concepts . 61 Scene-to-Screen Path . 61 Scene Graph . 62 Channels . 64 007-3560-005 ix Contents Parts of a Performer Application . 68 Initializing Performer . 69 Creating the Pipe, Channel, and Pipe Window . 69 Loading the Scene Graph . 70 Positioning the Channel . 70 Creating the Simulation Loop . 70 Inputting and Reading User Events . 71 Implementing User Input with Window Events . 72 Retrieving User Events . 73 5. Creating a Display with pfChannel . 75 Creating and Configuring a pfChannel . 77 Acquiring a pfPipe . 77 Creating a pfChannel Rendered by a pfPipe . 78 Creating and Configuring a pfPipeWindow . 78 Attaching a pfScene to the pfChannel . 78 Configuring a Viewport for the pfChannel . 78 Creating a Background for a pfChannel . 79 Initializing the pfChannel View . 79 Bounding Volumes . 81 Defining the Viewing Frustum . 81 Channel Callbacks . 85 Using Passthrough Data . 85 Channel Callback Example . 86 Using Multiple Channels . 87 Grouping Channels . 88 Choosing the Attributes to Share . 88 Using View Offsets . 90 Multiple Pipes . 91 Setting the Multiprocessing Configuration . 92 Creating Multiple pfPipes . 93 x 007-3560-005 Contents 6. Creating Scene Graphs . 95 What Is a Node? . 95 Node Attributes . 96 Scene Graph Nodes . 97 Group Nodes . 97 Leaf Nodes. 98 Creating a Scene Graph . 99 Creating and Attaching the pfScene Node . 99 Adding Nodes in a Scene Graph . 99 Removing Nodes from a Scene Graph . 99 Arrangement of Nodes . .100 Loading a Scene Graph . .100 Finding Scene Graph Files . .102 Saving a Scene Graph . .103 Scene Graph Traversals . .103 Pipelined Traversals . .103 Traversal Order . .105 Customizing OpenGL Performer Traversals . .106 Setting Up Node Callbacks . .106 Sample Customized Traversals . .108 7. Creating Geometry with pfGeoSets . .111 pfGeoSet Overview . .112 Creating a pfGeoSet . .112 Creating a pfGeoSet.