Table of Contents

Preface

About the Authors

Introduction

What’s New in This Edition

How This Book Is Organized

Part I: The Old Testament

Part II: Part II: The New Testament

Part III: Part III: The Apocrypha

Conventions Used in This Book

About the Companion Web Site

Part I. The Old Testament

1. Introduction to 3D Graphics and OpenGL

A Brief History of Computer Graphics

Going Electric

Going 3D

A Survey of 3D Effects

Perspective

Color and Shading

Light and Shadows

Texture Mapping

Fog

Blending and Transparency

Antialiasing

Common Uses for 3D Graphics

Real-Time 3D

Non–Real-Time 3D

Shaders

Basic 3D Programming Principles

Immediate Mode and Retained Mode

Coordinate Systems

Projections: Getting 3D to 2D

Summary

2. Using OpenGL

What Is OpenGL?

Evolution of a Standard

The API Wars

The Future of OpenGL

How Does OpenGL Work?

Generic Implementations

Hardware Implementations

The Pipeline

OpenGL: An API, Not a Language

Standard Libraries and Headers

Some Header Customizations

API Specifics

Data Types

Function-Naming Conventions

Platform Independence

Using GLUT

Your First Program

Drawing Shapes with OpenGL

Animation with OpenGL and GLUT

Double Buffering

The OpenGL State Machine

Saving and Restoring States

OpenGL Errors

When Bad Things Happen to Good Code

Identifying the Version

Getting a Clue with glHint

Using Extensions

Checking for an Extension

Whose Extension Is This?

Summary

3. Drawing in Space: Geometric Primitives and Buffers

Drawing Points in 3D

Setting Up a 3D Canvas

A 3D Point: The Vertex

Draw Something!

Drawing Points

Our First Example

Setting the Point Size

Drawing Lines in 3D

Line Strips and Loops

Approximating Curves with Straight Lines

Setting the Line Width

Line Stippling

Drawing Triangles in 3D

Triangles: Your First Polygon

Winding

Triangle Strips

Triangle Fans

Building Solid Objects

Setting Polygon Colors

Hidden Surface Removal

Culling: Hiding Surfaces for Performance

Polygon Modes

Other Primitives

Four-Sided Polygons: Quads

Quad Strips

General Polygons

Filling Polygons, or Stippling Revisited

Polygon Construction Rules

Subdivision and Edges

Other Buffer Tricks

Using Buffer Targets

Manipulating the Depth Buffer

Cutting It Out with Scissors

Using the Stencil Buffer

Creating the Stencil Pattern

Summary

4. Geometric Transformations: The Pipeline

Is This the Dreaded Math Chapter?

Understanding Transformations

Eye Coordinates

Viewing Transformations

Viewing Transformations

The Modelview Duality

Projection Transformations

Viewport Transformations

The Matrix: Mathematical Currency for 3D Graphics

What Is a Matrix?

The Transformation Pipeline

The Modelview Matrix

The Identity Matrix

The Matrix Stacks

A Nuclear Example

Using Projections

Orthographic Projections

Perspective Projections

A Far-Out Example

Advanced Matrix Manipulation

Loading a Matrix

Performing Your Own Transformations

Adding Transformations Together

Moving Around in OpenGL Using Cameras and Actors

An Actor Frame

Euler Angles: “Use the Frame, Luke!”

Camera Management

Bringing It All Together

Summary

5. Color, Materials, and Lighting: The Basics

What Is Color?

Light as a Wave

Light as a Particle

Your Personal Photon Detector

The Computer as a Photon Generator

PC Color Hardware

PC Display Modes

Screen Resolution

Color Depth

Using Color in OpenGL

The Color Cube

Setting the Drawing Color

Shading

Setting the Shading Model

Color in the Real World

Ambient Light

Diffuse Light

Specular Light

Putting It All Together

Materials in the Real World

Material Properties

Adding Light to Materials

Calculating Ambient Light Effects

Diffuse and Specular Effects

Adding Light to a Scene

Enabling the Lighting

Setting Up Cosmic Background Radiation

Setting Material Properties

Using a Light Source

Which Way Is Up?

Surface Normals

Specifying a Normal

Unit Normals

Finding a Normal

Setting Up a Source

Setting the Material Properties

Specifying the Polygons

Lighting Effects

Specular Highlights

Specular Light

Specular Reflectance

Specular Exponent

Normal Averaging

Putting It All Together

Creating a Spotlight

Drawing a Spotlight

Shadows

What Is a Shadow?

Squish Code

A Shadow Example

Sphere World Revisited

Summary

6. More on Colors and Materials

Blending

Combining Colors

Changing the Blending Equation

Antialiasing

Multisample

Applying Fog

Fog Equations

Fog Coordinates

Accumulation Buffer

Other Color Operations

Color Masking

Color Logical Operations

Alpha Testing

Dithering

Summary

7. Imaging with OpenGL

Bitmaps

Bitmapped Data

The Raster Position

Pixel Packing

Pixmaps

Packed Pixel Formats

A More Colorful Example

Moving Pixels Around

Saving Pixels

More Fun with Pixels

Pixel Zoom

Pixel Transfer

Pixel Mapping

The Imaging “Subset” and Pipeline

Color Matrix

Color Lookup

Proxies

Other Operations

Convolutions

Histogram

Minmax Operations

Summary

8. Texture Mapping: The Basics

Loading Textures

Using the Color Buffer

Updating Textures

Mapping Textures to Geometry

Texture Matrix

A Simple 2D Example

Texture Environment

Texture Parameters

Basic Filtering

Texture Wrap

Cartoons with Texture

Mipmapping

Texture Objects

Managing Multiple Textures

Summary

9. Texture Mapping: Beyond the Basics

Secondary Color

Anisotropic Filtering

Texture Compression

Compressing Textures

Loading Compressed Textures

Texture Coordinate Generation

Object Linear Mapping

Eye Linear Mapping

Sphere Mapping

Cube Mapping

Multitexture

Multiple Texture Coordinates

A Multitextured Example

Texture Combiners

Point Sprites

Using Points

Texture Application

Point Parameters

Summary

10. Curves and Surfaces

Built-in Surfaces

Setting Quadric States

Drawing Quadrics

Modeling with Quadrics

Bézier Curves and Surfaces

Parametric Representation

Evaluators

NURBS

From Bézier to B-Splines

Knots

Creating a NURBS Surface

NURBS Properties

Defining the Surface

Trimming

NURBS Curves

Tessellation

The Tessellator

Tessellator Callbacks

Specifying Vertex Data

Putting It All Together

Summary

11. It’s All About the Pipeline: Faster Geometry Throughput

Display Lists

Batch Processing

Preprocessed Batches

Display List Caveats

Converting to Display Lists

Vertex Arrays

Loading the Geometry

Enabling Arrays

Where’s the Data?

Pull the Data and Draw

Indexed Vertex Arrays

Vertex Buffer Objects

Managing and Using Buffer Objects

Back to the Thunderbird!

Summary

12. Interactive Graphics

Selection

Naming Your Primitives

Working with Selection Mode

The Selection Buffer

Picking

Hierarchical Picking

Feedback

The Feedback Buffer

Feedback Data

Passthrough Markers

A Feedback Example

Label the Objects for Feedback

Step 1: Select the Object

Step 2: Get Feedback on the Object

Summary

13. Occlusion Queries: Why Do More Work Than You Need To?

The World Before Occlusion Queries

Bounding Boxes

Querying the Query Object

Best Practices

Summary

14. Depth Textures and Shadows

Be That Light

Fit the Scene to the Window

No Bells or Whistles, Please

A New Kind of Texture

Size Matters

Draw the Shadows First?!

And Then There Was Light

Projecting Your Shadow Map: The “Why”

Projecting Your Shadow Map: The “How”

The Shadow Comparison

Two Out of Three Ain’t Bad

A Few Words About Polygon Offset

Summary

Part II. The New Testament

15. Programmable Pipeline: This Isn’t Your Father’s OpenGL

Out with the Old

Fixed Vertex Processing

Fixed Fragment Processing

In with the New

Programmable Vertex Shaders

Fixed Functionality Glue

Programmable Fragment Shaders

OpenGL Shading Language: A First Glimpse

Managing GLSL Shaders

Shader Objects

Program Objects

Variables

Basic Types

Structures

Arrays

Qualifiers

Built-In Variables

Expressions

Operators

Array Access

Constructors

Component Selectors

Control Flow

Loops

if/else

discard

Functions

Summary

16. Vertex Shading: Do-It-Yourself Transform, Lighting, and Texgen

Getting Your Feet Wet

Diffuse Lighting

Specular Lighting

Improved Specular Lighting

Per-Vertex Fog

Per-Vertex Point Size

Customized Vertex Transformation

Vertex Blending

Summary

17. Fragment Shading: Empower Your Pixel Processing

Color Conversion

Grayscale

Sepia Tone

Inversion

Heat Signature

Per-Fragment Fog

Image Processing

Blur

Sharpen

Dilation and Erosion

Edge Detection

Lighting

Diffuse Lighting

Multiple Specular Lights

Procedural Texture Mapping

Checkerboard Texture

Beach Ball Texture

Toy Ball Texture

Summary

18. Advanced Buffers

Pixel Buffer Objects

How to Use PBOs

The Benefits of PBOs

PBOs in Action

Oh, Where Is the Home Where the PBOs Roam?

Framebuffer Objects

How to Use FBOs

Offscreen Rendering

Rendering to Textures

Multiple Render Targets

Floating-Point Textures

High Dynamic Range

OpenEXR File Format

Tone Mapping

Making Your Whites Whiter and Your Brights Brighter

Drawing the Scene

Bright Pass

Gaussian Blur with a Little Help

The Sum Is Greater Than Its Parts

PBOs Make a Comeback

Summary

Part III. The Apocrypha

19. Wiggle: OpenGL on Windows

OpenGL Implementations on Windows

Generic OpenGL

Installable Client Driver

Mini-Client Driver

Mini-Driver

OpenGL on Vista

Extended OpenGL

Basic Windows Rendering

GDI Device Contexts

Pixel Formats

The OpenGL Rendering Context

Putting It All Together

Creating the Window

Using the OpenGL Rendering Context

Other Windows Messages

OpenGL and Windows Fonts

3D Fonts and Text

2D Fonts and Text

Full-Screen Rendering

Creating a Frameless Window

Creating a Full-Screen Window

Multithreaded Rendering

OpenGL and WGL Extensions

Simple Extensions

Using New Entrypoints

Auto-Magic Extensions

WGL Extensions

Summary

20. OpenGL on Mac OS X

GLUT

Setting Up a GLUT Project

Application Frameworks

Ditching Cocoa

OpenGL with Carbon

Setting Up for OpenGL

Bitmap Fonts

OpenGL with Cocoa

Creating a Cocoa Program

Wiring It All Together

Hang on a Second There!

Full-Screen Rendering

Managing the Display

AGL Full-Screen Support

Summary

21. OpenGL on Linux

The Basics

Setup

Setting Up Mesa

Setting Up Hardware Drivers

More Setup Details

Setting Up GLUT

Building OpenGL Apps

GLUT

GLX—Dealing with the X Windows Interface

Displays and X

Config Management and Visuals

Windows and Render Surfaces

Context Management

Synchronization

GLX Strings

The Rest of GLX

Putting It All Together

Summary

22. OpenGL ES: OpenGL on the Small

OpenGL on a Diet

What’s the ES For?

A Brief History

Which Version Is Right for You?

ES 1.0

ES 1.1

ES 2.0

ES SC

The ES Environment

Application Design Considerations

Dealing with a Limited Environment

Fixed-Point Math

EGL: A New Windowing Environment

EGL Displays

Creating a Window

Context Management

Presenting Buffers and Rendering Synchronization

More EGL Stuff

Negotiating Embedded Environments

Popular Operating Systems

Embedded Hardware

Vendor-Specific Extensions

For the Home Gamer

Putting OpenGL ES into Action

Setting Up the Environment

Setting Up OpenGL ES State

Rendering

Cleaning Up

Summary

A. Further Reading/References

Other Good OpenGL Books

3D Graphics Books

Web Sites

B. Glossary

C. API Reference

Overview of Appendix C

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset