Full download OpenGL Programming Guide 5th Edition Opengl Architecture Review Board pdf docx
Full download OpenGL Programming Guide 5th Edition Opengl Architecture Review Board pdf docx
https://ebookfinal.com/download/beginning-opengl-game-programming-1st-
edition-dave-astle/
ebookfinal.com
https://ebookfinal.com/download/beginning-opengl-game-programming-1st-
edition-dave-astle-2/
ebookfinal.com
https://ebookfinal.com/download/advanced-graphics-programming-using-
opengl-1st-edition-tom-mcreynolds/
ebookfinal.com
https://ebookfinal.com/download/opengl-superbible-comprehensive-
tutorial-and-reference-5th-edition-richard-s-wright/
ebookfinal.com
OpenGL Game Programming Prima Tech s Game Development 1st
Edition Kevin Hawkins
https://ebookfinal.com/download/opengl-game-programming-prima-tech-s-
game-development-1st-edition-kevin-hawkins/
ebookfinal.com
https://ebookfinal.com/download/opengl-es-2-for-android-a-quick-start-
guide-1st-edition-kevin-brothaler/
ebookfinal.com
https://ebookfinal.com/download/family-practice-examination-board-
review-second-edition-mcgraw-hill-specialty-board-review-mark-graber/
ebookfinal.com
https://ebookfinal.com/download/urology-board-review-stephen-leslie/
ebookfinal.com
https://ebookfinal.com/download/specialty-board-review-dermatology-a-
pictorial-review-2nd-edition-ali-asra/
ebookfinal.com
OpenGL Programming Guide 5th Edition Opengl
Architecture Review Board Digital Instant Download
Author(s): OpenGL Architecture Review Board, Dave Shreiner, Mason Woo,
Jackie Neider, Tom Davis
ISBN(s): 9780321335739, 0321335732
Edition: 5
File Details: PDF, 54.80 MB
Year: 2005
Language: english
OpenGL®
Programming Guide
Fifth Edition
Addison-Wesley
Upper Saddle River, NJ • Boston • Indianapolis • San Francisco
New York • Toronto • Montreal • London • Munich • Paris • Madrid
Capetown • Sydney • Tokyo • Singapore • Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and the publisher was
aware of a trademark claim, the designations have been printed with initial capital letters or
in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no
expressed or implied warranty of any kind and assume no responsibility for errors or
omissions. No liability is assumed for incidental or consequential damages in connection
with or arising out of the use of the information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk
purchases or special sales, which may include electronic versions and/or custom covers and
content particular to your business, training goals, marketing focus, and branding interests.
For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
[email protected]
For sales outside of the U.S., please contact:
International Sales
[email protected]
Visit us on the Web: www.awprofessional.com
Library of Congress Cataloging-in-Publication Data
OpenGL programming guide : the official guide to learning OpenGL, version 2 /
OpenGL Architecture Review Board, Dave Shreiner ... [et al.]. –5th ed.
p. cm.
Includes index.
ISBN 0-321-33573-2 (pbk. : alk. paper)
1. Computer graphics. 2. OpenGL. I. Shreiner, Dave. II. OpenGL Architecture
Review Board
T385.0635 2005
006.6'6—dc22 2005014386
Copyright © 2006 by Silicon Graphics, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by
copyright, and permission must be obtained from the publisher prior to any prohibited
reproduction, storage in a retrieval system, or transmission in any form or by any means,
electronic, mechanical, photocopying, recording, or likewise. For information regarding
permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
One Lake Street
Upper Saddle River, NJ 07458
ISBN 0-321-33573-2
Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts.
First printing, July 2005
For my family—Felicity, Max, Sarah, and Scout.
—JLN
To Tom Doeppner and Andy van Dam, who started me along this path.
—MW
For my family—Vicki, Bonnie, Bob, Phantom, Toby, Squiggles, and Tuxedo.
—DRS
Figures xxi
Tables xxv
Examples xxix
Acknowledgments xliii
1. Introduction to OpenGL 1
What Is OpenGL? 2
A Smidgen of OpenGL Code 5
OpenGL Command Syntax 7
OpenGL as a State Machine 9
OpenGL Rendering Pipeline 10
Display Lists 11
Evaluators 11
Per-Vertex Operations 12
Primitive Assembly 12
vii
Pixel Operations 12
Texture Assembly 13
Rasterization 13
Fragment Operations 13
OpenGL-Related Libraries 14
Include Files 15
GLUT, the OpenGL Utility Toolkit 16
Animation 20
The Refresh That Pauses 22
Motion = Redraw + Swap 23
viii Contents
Allocating and Initializing Buffer Objects with Vertex Data 84
Updating Data Values in Buffer Objects 88
Cleaning up Buffer Objects 90
Attribute Groups 90
Some Hints for Building Polygonal Models of Surfaces 93
An Example: Building an Icosahedron 95
3. Viewing 103
Overview: The Camera Analogy 106
A Simple Example: Drawing a Cube 109
General-PurpOse TransfOrmation Commands 114
Viewing and Modeling Transformations 117
Thinking abOut Transformations 117
Modeling TransfOrmations 120
Viewing TransformatiOns 126
Projection TransfOrmations 133
Perspective Projection 133
Orthographic Projection 136
Viewing Volume Clipping 138
Viewport Transformation 138
Defining the Viewport 39
The Transformed Depth CoOrdinate 141
Troubleshooting Transformations 142
Manipulating the Matrix Stacks 145
The Modelview Matrix Stack 148
The Projection Matrix Stack 148
Additional Clipping Planes 149
Examples of Composing Several TransfOrmations 152
Building a SOlar System 153
Building an Articulated RObOt Arm 156
Reversing or Mimicking Transformations 160
4. Color 165
ColOr PerceptiOn 166
Computer Color 168
RGBA versus Color-Index Mode 170
Contents ix
RGBA Display Mode 171
Color-Index Display Mode 173
Choosing between RGBA and Color-Index Mode 1
175
Changing between Display Modes 176
Specifying a Color and a Shading Model 176
Specifying a Color in RGBA Mode 177
Specifying a Color in Color-Index Mode 178
Specifying a Shading Model 179
5. Lighting 183
A Hidden-Surface Removal Survival Kit 185
Real-World and OpenGL Lighting 187
Ambient, Diffuse, Specular, and Emissive Light 188
Material Colors 189
RGB Values for Lights and Materials 189
A Simple Example: Rendering a Lit Sphere 190
Creating Light Sources 194
Color 196
Position and Attenuation 197
Spotlights 199
Multiple Lights 200
Controlling a Light's Position and Direction 201
Selecting a Lighting Model 207
Global Ambient Light 208
Local Or Infinite ViewpOint 209
Two-Sided Lighting 209
Secondary Specular Color 210
Enabling Lighting 211
Defining Material Properties 211
Diffuse and Ambient Reflection 213
Specular Reflection 214
Emission 214
Changing Material Properties 215
Color Material Mode 217
The Mathematics of Lighting 220
Material Emission 221
X Contents
Scaled Global Ambient Light 222
Contributions from Light Sources 222
Putting It All Together 224
Secondary Specular Color 225
Lighting in Color-Index Mode 226
The Mathematics of Color-Index Mode Lighting 227
Blending 231
The Source and Destination Factors 232
Enabling Blending 235
Combining Pixels Using Blending EquatiOns 235
Sample Uses of Blending 238
A Blending Example 240
Three-Dimensional Blending with the Depth Buffer 243
Antialiasing 247
Antialiasing Points or Lines 249
Antialiasing Geometric Primitives with Multisampling 255
Antialiasing POlygons 259
Fog 261
Using Fog 261
Fog Equations 264
Point Parameters 271
PolygOn Offset 274
Contents xi
Managing State Variables with Display Lists 297
Encapsulating Mode Changes 299
xii Contents
Three-Dimensional Textures 387
Compressed Texture Images 392
Using a Texture's Borders 395
Mipmaps: Multiple Levels of Detail 395
Filtering 406
Texture Objects 409
Naming a Texture Object 410
Creating and Using Texture Objects 410
Cleaning Up Texture Objects 413
A Working Set of Resident Textures 414
Texture Functions 416
Assigning Texture Coordinates 420
COmputing Appropriate Texture CoOrdinates 422
Repeating and Clamping Textures 423
Automatic Texture-Coordinate GeneratiOn 429
Creating COntOurs 430
Sphere Map 434
Cube Map Textures 436
Multitexturing 438
Texture Combiner Functions 444
The Interpolation Combiner Function 448
Applying Secondary Color after Texturing 450
SecOndary Color When Lighting Is Disabled 450
Secondary Specular Color When Lighting Is Enabled 450
The Texture Matrix Stack 451
Depth Textures 452
Creating a ShadOw Map 453
Generating Texture Coordinates and Rendering 454
Contents xiii
Scissor Test 468
Alpha Test 468
Stencil Test 470
Depth Test 475
Occlusion Query 476
Blending, Dithering, and Logical Operations 479
The Accumulation Buffer 482
Scene Antialiasing 483
Motion Blur 489
Depth of Field 489
Soft Shadows 494
Jittering 494
xiv Contents
Creating a NURBS Curve Or Surface 551
Trimming a NURBS Surface 557
Contents xv
Hidden-Line Removal with Polygon Offset 614
Hidden-Line Removal with the Stencil Buffer 615
Texture Mapping Applications 616
Drawing Depth-Buffered Images 617
Dirichlet Domains 617
Life in the Stencil Buffer 619
Alternative Uses for glDrawPixels() and glCopyPixels() 620
Overview 666
Geometric Operations 667
Per-Vertex Operations 667
Primitive Assembly 668
Pixel Operations 668
Texture Memory 669
xvi Contents
Fragment Operations 669
Odds and Ends 670
Contents xvii
Swapping Buffers 724
Updating the Rendering Buffers 724
Using an Apple Macintosh Font 724
Error Handling 725
AGL Prototypes 725
PGL: OpenGL Extension for IBM OS/2 Warp 727
Initialization 727
Controlling Rendering 728
PGL Prototypes 729
WGL: OpenGL Extension for Microsoft
Windows 95/98/NT/ME/2000/XP 731
Initialization 731
Controlling Rendering 732
WGL Prototypes 733
xviii Contents
Perspective Projection 755
Orthographic Projection 756
Variables 768
Vertex Shader Input Attributes Variables 768
Vertex Shader Special Output Variables 768
Vertex Shader Output Varying Variables 769
Built-In Implementation Constants 770
Built-In UnifOrm State Variables 771
Built-In Functions 780
Angle Conversion and Trigonometric Functions 780
Transcendental FunctiOns 781
Basic Numerical Functions 782
Vector-Operation Functions 783
Matrix Functions 784
VectOr-COmponent Relational Functions 784
Texture Lookup Functions 785
Fragment Processing Functions 790
Noise Functions 790
Glossary 791
Index 813
Contents xix
Figures
xxi
Figure 3-5 Translating an Object 121
Figure 3-6 Rotating an Object 122
Figure 3-7 Scaling and Reflecting an Object 123
Figure 3-8 Modeling Transformation Example 124
Figure 3-9 Object and Viewpoint at the Origin 127
Figure 3-10 Separating the Viewpoint and the Object 127
Figure 3-11 Default Camera Position 130
Figure 3-12 Using gluLookAt() 130
Figure 3-13 Perspective Viewing VOlume Specified by glFrustum() 134
Figure 3-14 Perspective Viewing Volume Specified
by gluPerspective() 135
Figure 3-15 Orthographic Viewing VOlume 137
Figure 3-16 Viewport Rectangle 139
Figure 3-17 Mapping the Viewing Volume to the Viewport 140
Figure 3-18 Perspective Projection and Transformed
Depth Coordinates 141
Figure 3-19 Using Trigonometry to Calculate the Field of View 143
Figure 3-20 Modelview and Projection Matrix Stacks 145
Figure 3-21 Pushing and Popping the Matrix Stack 146
Figure 3-22 Additional Clipping Planes and the Viewing Volume 149
Figure 3-23 Clipped Wireframe Sphere 151
Figure 3-24 Planet and Sun 153
Figure 3-25 Robot Arm 156
Figure 3-26 Robot Arm with Fingers 159
Figure 4-1 The Color Cube in Black and White 169
Figure 4-2 RGB Values from the Bitplanes 171
Figure 4-3 Dithering Black and White to Create Gray 173
Figure 4-4 A Color Map 174
Figure 4-5 Using a Color Map to Paint a Picture 174
Figure 5-1 A Lit and an Unlit Sphere 184
Figure 5-2 GL_SPOT_CUTOFF Parameter 199
Figure 6-1 Creating a Nonrectangular Raster Image 240
Figure 6-2 Aliased and Antialiased Lines 247
Figure 6-3 Determining Coverage Values 248
Figure 6-4 Fog-Density Equations 265
xxii Figures
Figure 6-5 Polygons and Their Depth Slopes 275
Figure 7-1 Stroked Font That Defines the Characters A, E, P, R, S 294
Figure 8-1 Bitmapped F and Its Data 304
Figure 8-2 Bitmap and Its Associated Parameters 307
Figure 8-3 Simplistic Diagram of Pixel Data FlOw 314
Figure 8-4 CompOnent Ordering for Some Data Types
and Pixel Formats 319
Figure 8-5 Imaging Pipeline 322
Figure 8-6 glCopyPixels() Pixel Path 323
Figure 8-7 glBitmap() Pixel Path 323
Figure 8-8 glTexImage*(), glTexSubImage*(), and
glGetTexImage() Pixel Paths 324
Figure 8-9 glCopyTexlmage*() and
glCopyTexSublmage*() Pixel Paths 324
Figure 8-10 Byte Swap Effect on Byte, Short, and Integer Data 328
Figure 8-11 *SKIP_ROWS, *SKIP_PIXELS, and
*ROW_LENGTH Parameters 329
Figure 8-12 Drawing Pixels with glDrawPixels() 338
Figure 8-13 Reading Pixels with glReadPixels() 340
Figure 8-14 Imaging Subset Operations 343
Figure 8-15 The Pixel COnvolution Operation 350
Figure 9-1 Texture-Mapping Process 367
Figure 9-2 Texture-Mapped Squares 373
Figure 9-3 Texture with Subimage Added 383
Figure 9-4 *IMAGE_HEIGHT Pixel-Storage Mode 391
Figure 9-5 *SKIP_IMAGES Pixel-Storage Mode 392
Figure 9-6 Mipmaps 396
Figure 9-7 Using a MOsaic Texture 401
Figure 9-8 Texture MagnificatiOn and Minification 407
Figure 9-9 Texture-Map Distortion 423
Figure 9-10 Repeating a Texture 425
Figure 9-11 Comparing GL_REPEAT to GL_MIRRORED_REPEAT 426
Figure 9-12 Clamping a Texture 426
Figure 9-13 Repeating and Clamping a Texture 426
Figure 9-14 Multitexture Processing Pipeline 439
Figures xxiii
Figure 10-1 Region Occupied by a Pixel 458
Figure 10-2 Motion-Blurred Object 489
Figure 10-3 Jittered Viewing Volume for Depth-of-Field Effects 491
Figure 11-1 Contours That Require Tessellation 499
Figure 11-2 Winding Numbers for Sample Contours 507
Figure 11-3 How Winding Rules Define Interiors 508
Figure 12-1 Bézier Curve 529
Figure 12-2 Bézier Surface 536
Figure 12-3 Lit, Shaded Bézier Surface Drawn with a Mesh 539
Figure 12-4 NURBS Surface 544
Figure 12-5 Parametric Trimming Curves 558
Figure 12-6 Trimmed NURBS Surface 559
Figure 14-1 Antialiased Characters 606
Figure 14-2 Concave Polygon 610
Figure 14-3 Dirichlet Domains 618
Figure 14-4 Six Generations from the Game of Life 619
Figure 15-1 Comparison of Antialiased Points and
Textured Point Sprites 625
Figure 15-2 Assignment of Texture Coordinates Based on the
Setting Of GL_POINT_SPRITE_COORD_ORIGIN 625
Figure 15-3 Overview of the OpenGL Fixed-Function Pipeline 626
Figure 15-4 Vertex Processing Pipeline 628
Figure 15-5 Fragment PrOcessing Pipeline 629
Figure 15-6 Shader Creation Flowchart 631
Figure 15-7 GLSL Vertex Shader Input and Output Variables 656
Figure 15-8 Fragment Shader Built-In Variables 662
Figure A-1 Order of Operations 666
Figure E-1 Rendering with Polygonal Normals versus
True Normals 746
Figure E-2 Averaging Normal Vectors 750
xxiv Figures
Tables
xxv
Table 8-6 glPixelMap*() Parameter Names and Values 333
Table 8-7 When Color Table Operations Occur in the
Imaging Pipeline 344
Table 8-8 Color Table Pixel Replacement 345
Table 8-9 How Convolution Filters Affect RGBA
Pixel Components 351
Table 9-1 Mipmapping Level Parameter Controls 402
Table 9-2 Mipmapping Level-of-Detail Parameter Controls 403
Table 9-3 Filtering Methods fOr Magnification and Minification 407
Table 9-4 Deriving Color Values from Different Texture Formats 417
Table 9-5 Replace, Modulate, and Decal Texture Functions 418
Table 9-6 Blend and Add Texture FunctiOns 419
Table 9-7 glTexParameter*() Parameters 427
Table 9-8 Texture Environment Parameters If target Is
GL_TEXTURE_ENV 445
Table 9-9 GL_COMBINE_RGB and GL_COMBINE_ALPHA
Functions 446
Table 9-10 Default Values fOr Some Texture EnvirOnment Modes 449
Table 10-1 Query Parameters for Per-Pixel Buffer Storage 460
Table 10-2 glAlphaFunc() Parameter Values 469
Table 10-3 Query Values for the Stencil Test 471
Table 10-4 Sixteen Logical Operations 481
Table 10-5 Sample Jittering Values 494
Table 12-1 Types of Control Points for glMap1*() 532
Table 13-1 glFeedbackBuffer() type Values 584
Table 13-2 Feedback Array Syntax 585
Table 14-11 OpenGL Error Codes of Layers 594
Eight Combinations
Table 605
Table 15-1 Basic Data Types in GLSL 639
Table 15-2 GLSL VectOr and Matrix Types 641
Table 15-3 Vector Component Accessor y 643
Table 15-4 GLSL Type Modifiers 645
Table 15-5 GLSL Operators and Their Precedence 648
Table 15-6 GLSL Flow-Control Statements 651
Table 15-7 GLSL Function Parameter Access Modifiers 652
xxvi Tables
Table 15-8 Fragment Shader Texture Sampler Types 653
Table 15-9 Vertex Shader Attribute Global Variables 657
Table 15-10 Vertex Shader Special Global Variables 660
Table 15-11 Vertex Shader Varying Global Variables 661
Table 15-12 Fragment Shader Varying Global Variables 663
Table 15-13 Fragment Shader Output Global Variables 663
Table B-1 State Variables for Current Values and AssOciated Data 676
Table B-2 Vertex-Array State Variables 677
Table B-3 Vertex Buffer Object State Variables 680
Table B-4 Transformation State Variables 681
Table B-5 Coloring State Variables 683
Table B-6 Lighting State Variables 684
Table B-7 Rasterization State Variables 686
Table B-8 "Multisampling" 688
Table B-9 Texturing State Variables 689
Table B-10 Pixel Operations 695
Table B-11 Framebuffer Control State Variables 697
Table B-12 Pixel State Variables 698
Table B-13 Evaluator State Variables 704
Table B-14 Hint State Variables 705
Table B-15 Implementation-Dependent State Variables 706
Table B-16 Implementation-Dependent Pixel-Depth
State Variables 710
Table B-17 Miscellaneous State Variables 710
Table I-1 Global Vertex Shader Attribute Variables 768
Table I-2 Special Vertex Shader Output Variables 769
Table I-3 Varying Vertex Shader Output Variables 769
Table I-4 Varying Fragment Shader Input Variables 770
Table I-5 Implementation Maximum Value Variables 770
Table I-6 Transformation Matrix Variables 772
Table I-7 Depth Range Variables 774
Table I-8 Point Size and Attenuation Variables 775
Table I-9 Lighting Material Variables 776
Table I-10 Light Source Variables 777
Tables xxvii
Table I-11 Light Model Variables 778
Table I-12 Cached Light Model Value Variables 778
Table I-13 Cached Light Product Value Variables 779
Table I-14 Fog Variables and Cached Values 780
Table I-15 Angle Conversion and Trigonometric Functions 780
Table I-16 Transcendental Functions 781
Table I-17 Basic Numerical Functions 782
Table I-18 Vector-Operation Functions 783
Table I-19 Matrix Functions 784
Table I-20 Vector CompOnent Operation Functions 785
Table I-21 Basic Texture Access Functions 786
Table I-22 Projective Texture Access Functions 787
Table I-23 Vertex Shader Texture Access Functions 788
Table I-24 Cube-Map Texture Access Functions 788
Table I-25 Shadow-Map Texture Access Functions 789
Table I-26 Fragment Derivative Functions 790
Table I-27 Random-Noise Generation Functions 790
xxviii Tables
Examples
xxx Examples
Example 7-1 Creating a Display List: torus.c 279
Example 7-2 Using a Display List: list.c 285
Example 7-3 Hierarchical Display List 291
Example 7-4 Defining Multiple Display Lists 293
Example 7-5 Multiple Display Lists to Define a Stroked
Font: stroke.c 294
Example 7-6 Persistence of State Changes after Execution of a
Display List 298
Example 7-7 Restoring State Variables within a Display List 298
Example 7-8 The Display List May or May Not Affect drawLine() 299
Example 7-9 Display Lists for Mode Changes 300
Example 8-1 Drawing a Bitmapped Character: drawf.c 304
Example 8-2 Drawing a Complete Font: font.c 311
Example 8-3 Use of glDrawPixels(): image.c 320
Example 8-4 Drawing, Copying, and Zooming Pixel Data: image.c 335
Example 8-5 Pixel Replacement Using Color Tables: colortable.c 346
Example 8-6 Using TwO-Dimensional Convolution Filters:
convolution.c 351
Example 8-7 Exchanging Color Components Using the ColOr
Matrix: colormatrix.c 358
Example 8-8 Computing and Diagramming an Image's Histogram:
histogram.c 360
Example 8-9 Computing Minimum and Maximum Pixel Values:
minmax.c 363
Example 9-1 Texture-Mapped Checkerboard: checker.c 373
Example 9-2 Querying Texture Resources with a Texture Proxy 381
Example 9-3 Replacing a Texture Subimage: texsub.c 383
Example 9-4 Three-Dimensional Texturing: texture3d.c 388
Example 9-5 Mipmap Textures: mipmap.c 398
Example 9-6 Setting Base and Maximum Mipmap Levels 403
Example 9-7 Binding Texture Objects: texbind.c 411
Example 9-8 Automatic Texture-Coordinate Generation: texgen.c 430
Example 9-9 Generating Cube Map Texture Coordinates:
cubemap.c 438
Example 9-10 Initializing Texture Units for Multitexturing:
multitex.c 441
Examples xxxi
Example 9-11 Specifying Vertices for Multitexturing 442
Example 9-12 Reverting to Texture Unit 0 443
Example 9-13 Setting the Programmable Combiner Functions 446
Example 9-14 Setting the Combiner Function Sources 446
Example 9-15 Using an Alpha Value for RGB Combiner Operations 447
Example 9-16 Interpolation Combiner Function: combiner.c 448
Example 9-17 Rendering Scene with Viewpoint at Light Source:
shadowmap.c 454
Example 9-18 Calculating Texture Coordinates: shadowmap.c 455
Example 9-19 Rendering Scene Comparing r CoOrdinate:
shadowmap.c 456
Example 10-1 Using the Stencil Test: stencil.c 472
Example 10-2 Rendering Geometry with Occlusion Query 478
Example 10-3 Retrieving the Results of an Occlusion Query 479
Example 10-4 Routines for Jittering the Viewing Volume: accpersp.c 484
Example 10-5 Scene Antialiasing: accpersp.c 485
Example 10-6 Jittering with an Orthographic Projection: accanti.c 488
Example 10-7 Depth-of-Field Effect: dof.c 490
Example 11-1 Registering Tessellation Callbacks: tess.c 502
Example 11-2 Vertex and Combine Callbacks: tess.c 504
Example 11-3 Polygon Definition: tess.c 512
Example 11-4 Quadrics Objects: quadric.c 521
Example 12-1 Bézier Curve with Four Control Points: bezcurve.c 529
Example 12-2 Bézier Surface: bersurf.c 536
Example 12-3 Lit, Shaded Bézier Surface Using a Mesh: bezmesh.c 538
Example 12-4 Using Evaluators for Textures: texturesurf.c 540
Example 12-5 NURBS Surface: surface.c 544
Example 12-6 Registering NURBS Tessellation Callbacks: surfpoints.c 555
Example 12-7 The NURBS Tessellation Callbacks: surfpoints.c 556
Example 12-8 Trimming a NURBS Surface: trim.c 559
Example 13-1 Creating a Name Stack 565
Example 13-2 SelectiOn Example: select.c 567
Example 13-3 Picking Example: picksquare.c 572
Example 13-4 Creating Multiple Names 575
Example 13-5 Using Multiple Names 576
xxxii Examples
Example 13-6 Picking with Depth Values: pickdepth.c 577
Example 13-7 Feedback MOde: feedback.c 587
Example 14-1 Querying and Printing an Error 595
Example 14-2 Determining if an Extension Is Supported
(Prior to GLU 1.3) 598
Example 14-3 Locating an OpenGL Extension with
wglGetProcAddress() 599
Example 15-1 COnfiguring a Point Sprite for Texture Mapping:
sprite . c 626
Example 15-2 A Sample GLSL Vertex Shader 630
Example 15-3 Creating and Liking GLSL shaders 636
Example 15-4 Obtaining a Uniform Variable's Index and
Assigning Values 647
Example 15-5 Associating Texture Units with Sampler Variables 654
Example 15-6 Sampling a Texture Within a GLSL Shader 654
Example 15-7 Dependent Texture Reads in GLSL 655
Examples xxxiii
About This Guide
xxxv
• Chapter 5, "Lighting," explains how to control the lighting condi-
tions surrounding an object and how that object responds to light
(that is, how it reflects or absorbs light). Lighting is an important topic,
since objects usually don't look three-dimensional until they're lit.
• Chapter 10, "The Framebuffer," describes all the possible buffers that
can exist in an OpenGL implementation and how you can control
them. You can use the buffers fOr such effects as hidden-surface elimi-
nation, stenciling, masking, motion blur, and depth-of-field focusing.
Finally, an extensive Glossary defines the key terms used in this guide.
Another great place for all sorts of general information is the Official
OpenGL Web Site. This Web site contains software, documentation, FAQs,
and news. It is always a good place to start any search for answers to your
OpenGL questions:
http://www.opengl.org/
Once you begin programming with OpenGL, you might want to obtain the
OpenGL Reference Manual by the OpenGL Architecture Review Board (also
published by Addison-Wesley), which is designed as a companion volume
to this guide. The Reference Manual provides a technical view of how OpenGL
operates on data that describes a geometric object or an image to produce
an image on the screen. It also contains full descriptions of each set of
related OpenGL commands—the parameters used by the commands, the
default values for those parameters, and what the commands accomplish.
Many OpenGL implementatiOns have this same material online, in the
form of manual pages or other help documents, which are probably more
up-to-date. There are also versions on the World Wide Web; consult the
previously mentioned Official OpenGL Web Site.
For the source code examples found in this book, please visit
http://www.opengl-redbook.com/code/
For Mark Kilgard's source code for GLUT (for Microsoft Windows or the
X Window System), check this Web page to find out what current version
of GLUT is available and where to download the source code from:
http://www.opengl.org/developers/documentation/glut/index.html
http://www.xmission.com/~nate/tutors.html
Errata
Undoubtedly this book has errors. An error list is maintained at the
following Web site:
If you find any bugs, you can use the pointer at this Web site to report them.
Style Conventions
These style conventions are used in this guide:
Code examples are set off from the text in a monospace font, and command
summaries are shaded with gray boxes.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com