Opengl Performer™ Getting Started Guide
Total Page:16
File Type:pdf, Size:1020Kb
OpenGL Performer™ Getting Started Guide 007-3560-003 CONTRIBUTORS Written by George Eckel, Ken Jones, and Tammy Domeier Illustrated by Dany Galgani, Chrystie Danzer, and Chris Wengelski Edited by Susan Wilkening and Connie Boltz 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, and Alexandre Naaman. COPYRIGHT © 1997, 2000, 2002 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. LIMITED RIGHTS LEGEND The electronic (software) version of this document was developed at private expense; if acquired under an agreement with the USA government or any contractor thereto, it is acquired as "commercial computer software" subject to the provisions of its applicable license agreement, as specified in (a) 48 CFR 12.212 of the FAR; or, if acquired for Department of Defense units, (b) 48 CFR 227-7202 of the DoD FAR Supplement; or sections succeeding thereto. Contractor/manufacturer is Silicon Graphics, Inc., 1600 Amphitheatre Pkwy 2E, Mountain View, CA 94043-1351. 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, OpenGL Multipipe, OpenGL Optimizer, OpenGL Performer, OpenGL Shader, OpenGL Volumizer, and Power Onyx are trademarks of Silicon Graphics, Inc. Alias|Wavefront and Wavefront are trademarks of Alias|Wavefront, a division of Silicon Graphics Limited. Designer’s Workbench is a trademark of Centric Software, Inc. 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. All other trademarks are the properties of their respective owners. Yosemite image copyright of Delphi International. DI-Guy image copyright of Bostom Dynamics Inc. Palace image copyright of Pinxi. Clouds image copyright of SWRI. Ocean and Marine Effects Simulation image copyright of Paradigm Simulation Inc. Cover Design By Sarah Bolles, Sarah Bolles Design, and Dany Galgani, SGI Technical Publications. 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.0, which has the following features: • New hardware support - SGI Scalable Graphics Compositor - InfiniteReality4 • New OS platforms - Windows NT 4.0 - Windows 2000 - Windows XP • Functional features - Image-Based rendering using simplified 3D proxy geometry - Other image-based rendering enhancements - Occlusion culling using cull programs - Cull helper processes (cull sidekick) - New library libpfv, providing a feature-rich viewer • Integration with other graphics toolkits - OpenGL Multipipe SDK - Direct integration with OpenGL Shader 3.0 - OpenGL Volumizer • OpenFlight 15.7 support 007-3560-003 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. 007-3560-003 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 . xxvii PART I Overview of OpenGL Performer 1. Getting Acquainted with OpenGL Performer . 3 Installing the Software . 3 007-3560-003 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-003 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 . 63 Scene-to-Screen Path . 63 Scene Graph . 64 Channels . 66 007-3560-003 ix Contents Parts of a Performer Application . 70 Initializing Performer . 71 Creating the Pipe, Channel, and Pipe Window . 71 Loading the Scene Graph . 72 Positioning the Channel . 72 Creating the Simulation Loop . 73 Inputting and Reading User Events . 74 Implementing User Input with Window Events . 74 Retrieving User Events . 75 5. Creating a Display with pfChannel . 79 Creating and Configuring a pfChannel . 81 Acquiring a pfPipe . 81 Creating a pfChannel Rendered by a pfPipe . 82 Creating and Configuring a pfPipeWindow . 82 Attaching a pfScene to the pfChannel . 82 Configuring a Viewport for the pfChannel . 82 Creating a Background for a pfChannel . 83 Initializing the pfChannel View . 83 Bounding Volumes . 85 Defining the Viewing Frustum . 85 Channel Callbacks . 89 Using Passthrough Data . 89 Channel Callback Example . 90 Using Multiple Channels . 91 Grouping Channels . 92 Choosing the Attributes to Share . 92 Using View Offsets . 94 Multiple Pipes . 95 Setting the Multiprocessing Configuration . 96 Creating Multiple pfPipes . 97 x 007-3560-003 Contents 6. Creating Scene Graphs . 99 What Is a Node? . 99 Node Attributes . .100 Scene Graph Nodes . .101 Group Nodes . .101 Leaf Nodes. .102 Creating a Scene Graph . .103 Creating and Attaching the pfScene Node . .103 Adding Nodes in a Scene Graph . .103 Removing Nodes from a Scene Graph . .103 Arrangement of Nodes . .104 Loading a Scene Graph . .104 Finding Scene Graph Files . .106 Saving a Scene Graph . .107 Scene Graph Traversals . .107 Pipelined Traversals . .107 Traversal Order . .109 Customizing OpenGL Performer Traversals . .110 Setting Up Node Callbacks . .110 Sample Customized Traversals . .112 7. Creating Geometry with pfGeoSet . .115 pfGeoSet Overview . .115 Creating a pfGeoSet . ..