Always Learning

Advanced Search

OpenGL Programming Guide

OpenGL Programming Guide

The Official Guide to Learning OpenGL, Version 2
5th Edition

OpenGL Architecture Review Board, et al., Dave Shreiner, Mason Woo, Jackie Neider, Tom Davis

Aug 2005, Paperback, 896 pages
ISBN13: 9780321335739
ISBN10: 0321335732
This title is no longer available.

This title cannot be purchased online
  • Print pagePrint page
  • Email this pageEmail page
  • Share

OpenGL is a powerful software interface used to produce high-quality, computer-generated images and interactive applications using 2D and 3D objects, bitmaps, and color images.

The OpenGL® Programming Guide, Fifth Edition, provides definitive and comprehensive information on OpenGL and the OpenGL Utility Library. The previous edition covered OpenGL through Version 1.4. This fifth edition of the best-selling "red book" describes the latest features of OpenGL Versions 1.5 and 2.0, including the introduction of the OpenGL Shading Language.

You will find clear explanations of OpenGL functionality and many basic computer graphics techniques, such as building and rendering 3D models; interactively viewing objects from different perspective points; and using shading, lighting, and texturing effects for greater realism. In addition, this book provides in-depth coverage of advanced techniques, including texture mapping, antialiasing, fog and atmospheric effects, NURBS, image processing, and more. The text also explores other key topics such as enhancing performance, OpenGL extensions, and cross-platform techniques.

This fifth edition has been extensively updated to include the newest features of OpenGL Versions 1.5 and 2.0, including:

  • Storage of vertex arrays in buffer objects for faster rendering
  • Occlusion queries for course-grain visibility testing
  • Non-power-of-two dimensioned texture maps
  • Point sprites
  • Separate stencil operations for RGB and alpha
  • Rendering to multiple color buffers using GLSL

Most importantly, this edition discusses the OpenGL Shading Language (GLSL) and explains the mechanics of using this new language to create complex graphics effects and boost the computational power of OpenGL.

Figures xxiTables xxvExamples xxixAbout This Guide xxxvAcknowledgments xliii1. 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

OpenGL-Related Libraries 14

Animation 20

2. State Management and Drawing Geometric Objects 27

A Drawing Survival Kit 29

Describing Points, Lines, and Polygons 37

Basic State Management 48

Displaying Points, Lines, and Polygons 50

Normal Vectors 63

Vertex Arrays 65

Vertex Arrays in Buffer Objects 82

Attribute Groups 90

Some Hints for Building Polygonal Models of Surfaces 93

3. Viewing 103

Overview: The Camera Analogy 106

Viewing and Modeling Transformations 117

Projection Transformations 133

Viewport Transformation 138

Troubleshooting Transformations 142

Manipulating the Matrix Stacks 145

Additional Clipping Planes 149

Examples of Composing Several Transformations 152

Reversing or Mimicking Transformations 160

4. Color 165

Color Perception 166

Computer Color 168

RGBA versus Color-Index Mode 170

Specifying a Color and a Shading Model 176

5. Lighting 183

A Hidden-Surface Removal Survival Kit 185

Real-World and OpenGL Lighting 187

A Simple Example: Rendering a Lit Sphere 190

Creating Light Sources 194

Selecting a Lighting Model 207

Defining Material Properties 211

The Mathematics of Lighting 220

Lighting in Color-Index Mode 226

6. Blending, Antialiasing, Fog, and Polygon Offset 229

Blending 231

Antialiasing 247

Fog 261

Point Parameters 271

Polygon Offset 274

7. Display Lists 277

Why Use Display Lists? 278

An Example of Using a Display List 279

Display List Design Philosophy 282

Creating and Executing a Display List 285

Executing Multiple Display Lists 292

Managing State Variables with Display Lists 297

8. Drawing Pixels, Bitmaps, Fonts, and Images 301

Bitmaps and Fonts 303

Images 312

Reading and Drawing Pixel Rectangles 337

Tips for Improving Pixel Drawing Rates 341

Imaging Subset 342

9. Texture Mapping 365

An Overview and an Example 371

Specifying the Texture 375

Filtering 406

Texture Objects 409

Texture Functions 416

Assigning Texture Coordinates 420

Automatic Texture-Coordinate Generation 429

Multitexturing 438

Texture Combiner Functions 444

Applying Secondary Color after Texturing 450

The Texture Matrix Stack 451

Depth Textures 452

10. The Framebuffer 457

Buffers and Their Uses 460

Testing and Operating on Fragments 467

The Accumulation Buffer 482

11. Tessellators and Quadrics 497

Polygon Tessellation 498

Quadrics: Rendering Spheres, Cylinders, and Disks 515

12. Evaluators and NURBS 525

Prerequisites 527

Evaluators 528

The GLU NURBS Interface 542

13. Selection and Feedback 561

Selection 562

Feedback 583

14. Now That You Know 591

Error Handling 593

Which Version Am I Using? 595

Extensions to the Standard 597

Cheesy Translucency 600

An Easy Fade Effect 600

Object Selection Using the Back Buffer 602

Cheap Image Transformation 603

Displaying Layers 604

Antialiased Characters 605

Drawing Round Points 608

Interpolating Images 608

Making Decals 608

Drawing Filled, Concave Polygons Using the Stencil Buffer 610

Finding Interference Regions 611

Shadows 613

Hidden-Line Removal 614

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

15. OpenGL 20 and the OpenGL Shading Language 623

Why OpenGL 20? 624

Point Sprites 624

The OpenGL Graphics Pipeline and Programmable Shading 626

Using GLSL Shaders 630

The OpenGL Shading Language 638

Creating Shaders with GLSL 639

Accessing Texture Maps in Shaders 653

A. Order of Operations 665

Overview 666

Geometric Operations 667

Pixel Operations 668

Fragment Operations 669

Odds and Ends 670

B. State Variables 671

The Query Commands 672

OpenGL State Variables 674

C. OpenGL and Window Systems 713

Accessing New OpenGL Functions 714

GLX: OpenGL Extension for the X Window System 715

AGL: OpenGL Extensions for the Apple Macintosh 722

PGL: OpenGL Extension for IBM OS/2 Warp 727

WGL: OpenGL Extension for Microsoft

Windows 95/98/NT/ME/2000/XP 731

D. Basics of GLUT: The OpenGL Utility Toolkit 737

Initializing and Creating a Window 738

Handling Window and Input Events 739

Loading the Color Map 741

Initializing and Drawing Three-Dimensional Objects 741

Managing a Background Process 743

Running the Program 743

E. Calculating Normal Vectors 745

Finding Normals for Analytic Surfaces 747

Finding Normals from Polygonal Data 749

F. Homogeneous Coordinates and Transformation Matrices 751

Homogeneous Coordinates 752

Transformation Matrices 753

G. Programming Tips 757

OpenGL Correctness Tips 758

OpenGL Performance Tips 760

GLX Tips 762

H. OpenGL Invariance 763I. Built-In OpenGL Shading Language Variables and Functions 767

Variables 768

Built-In Functions 780

Glossary 791Index 813

Dave Shreiner, a leading OpenGL consultant, was a longtime member of the core OpenGL team at SGI. He authored the first commercial OpenGL training course, and has been developing computer graphics applications for more than two decades.