About This eBook
Title Page
Copyright Page
Dedication Page
Contents
Figures
Tables
Listings
Foreword
Preface
The Architecture of the Book
What’s New in This Edition
How to Build the Examples
Errata
Note from the Publisher
Acknowledgments
About the Author
Part I: Foundations
Chapter 1. Introduction
OpenGL and the Graphics Pipeline
The Origins and Evolution of OpenGL
Core Profile OpenGL
Primitives, Pipelines, and Pixels
Summary
Chapter 2. Our First OpenGL Program
Creating a Simple Application
Using Shaders
Drawing Our First Triangle
Summary
Chapter 3. Following the Pipeline
Passing Data to the Vertex Shader
Vertex Attributes
Passing Data from Stage to Stage
Interface Blocks
Tessellation
Tessellation Control Shaders
The Tessellation Engine
Tessellation Evaluation Shaders
Geometry Shaders
Primitive Assembly, Clipping, and Rasterization
Clipping
Viewport Transformation
Culling
Rasterization
Fragment Shaders
Framebuffer Operations
Pixel Operations
Compute Shaders
Using Extensions in OpenGL
Enhancing OpenGL with Extensions
Summary
Chapter 4. Math for 3D Graphics
Is This the Dreaded Math Chapter?
A Crash Course in 3D Graphics Math
Vectors, or Which Way Is Which?
Common Vector Operators
Matrices
Matrix Construction and Operators
Understanding Transformations
Coordinate Spaces in OpenGL
Coordinate Transformations
Concatenating Transformations
Quaternions
The Model–View Transform
Projection Transformations
Interpolation, Lines, Curves, and Splines
Curves
Splines
Summary
Chapter 5. Data
Buffers
Creating Buffers and Allocating Memory
Filling and Copying Data in Buffers
Feeding Vertex Shaders from Buffers
Uniforms
Default Block Uniforms
Uniform Blocks
Using Uniforms to Transform Geometry
Shader Storage Blocks
Synchronizing Access to Memory
Atomic Counters
Synchronizing Access to Atomic Counters
Textures
Creating and Initialzing Textures
Texture Targets and Types
Reading from Textures in Shaders
Loading Textures from Files
Controlling How Texture Data Is Read
Array Textures
Writing to Textures in Shaders
Synchronizing Access to Images
Texture Compression
Texture Views
Summary
Chapter 6. Shaders and Programs
Language Overview
Data Types
Built-In Functions
Compiling, Linking, and Examining Programs
Getting Information from the Compiler
Getting Information from the Linker
Separate Programs
Shader Subroutines
Program Binaries
Summary
Part II: In Depth
Chapter 7. Vertex Processing and Drawing Commands
Vertex Processing
Vertex Shader Inputs
Vertex Shader Outputs
Drawing Commands
Indexed Drawing Commands
Instancing
Indirect Draws
Storing Transformed Vertices
Using Transform Feedback
Starting, Pausing, and Stopping Transform Feedback
Ending the Pipeline with Transform Feedback
Transform Feedback Example: Physical Simulation
Clipping
User-Defined Clipping
Summary
Chapter 8. Primitive Processing
Tessellation
Tessellation Primitive Modes
Tessellation Subdivision Modes
Passing Data between Tessellation Shaders
Communication between Shader Invocations
Tessellation Example: Terrain Rendering
Tessellation Example: Cubic Bézier Patches
Geometry Shaders
The Pass-Through Geometry Shader
Using Geometry Shaders in an Application
Discarding Geometry in the Geometry Shader
Modifying Geometry in the Geometry Shader
Generating Geometry in the Geometry Shader
Changing the Primitive Type in the Geometry Shader
Multiple Streams of Storage
New Primitive Types Introduced by the Geometry Shader
Multiple Viewport Transformations
Summary
Chapter 9. Fragment Processing and the Framebuffer
Fragment Shaders
Interpolation and Storage Qualifiers
Per-Fragment Tests
Scissor Testing
Stencil Testing
Depth Testing
Early Testing
Color Output
Blending
Logical Operations
Color Masking
Off-Screen Rendering
Multiple Framebuffer Attachments
Layered Rendering
Framebuffer Completeness
Rendering in Stereo
Antialiasing
Antialiasing by Filtering
Multi-Sample Antialiasing
Multi-Sample Textures
Sample Rate Shading
Centroid Sampling
Advanced Framebuffer Formats
Rendering with No Attachments
Floating-Point Framebuffers
Integer Framebuffers
The sRGB Color Space
Point Sprites
Texturing Points
Rendering a Star Field
Point Parameters
Shaped Points
Rotating Points
Getting at Your Image
Reading from a Framebuffer
Copying Data between Framebuffers
Reading Back Texture Data
Summary
Chapter 10. Compute Shaders
Using Compute Shaders
Executing Compute Shaders
Compute Shader Communication
Examples
Compute Shader Parallel Prefix Sum
Compute Shader Flocking
Summary
Chapter 11. Advanced Data Management
Eliminating Binding
Sparsely Populated Textures
Texture Compression
The RGTC Compression Scheme
Generating Compressed Data
Packed Data Formats
High-Quality Texture Filtering
Summary
Chapter 12. Controlling and Monitoring the Pipeline
Queries
Occlusion Queries
Timer Queries
Transform Feedback Queries
Pipeline State Queries
Synchronization in OpenGL
Draining the Pipeline
Synchronization and Fences
Summary
Part III: In Practice
Chapter 13. Rendering Techniques
Lighting Models
The Phong Lighting Model
Blinn-Phong Lighting
Rim Lighting
Normal Mapping
Environment Mapping
Material Properties
Casting Shadows
Atmospheric Effects
Non-Photo-Realistic Rendering
Cell Shading: Texels as Light
Alternative Rendering Methods
Deferred Shading
Screen-Space Techniques
Rendering without Triangles
Two-Dimensional Graphics
Distance Field Textures
Bitmap Fonts
Summary
Chapter 14. High-Performance OpenGL
Optimizing CPU Performance
Multi-Threading in OpenGL
Packet Buffers
Low-Overhead OpenGL
Indirect Rendering
GPU Work Generation
Zero Copy
Performance Analysis Tools
Windows Performance Toolkit and GPUView
GPU PerfStudio
Tuning Your Application for Speed
Summary
Chapter 15. Debugging and Stability
Debugging Your Applications
Debug Contexts
Security and Robustness
Graphics Reset
Range-Checked Reads
Summary
Appendix A. The SuperBible Tools
The ktxtool Utility
The dds2ktx Utility
The sb6mtool Utility
Appendix B. The SBM File Format
File Header
Chunk Headers
Defined Chunks
Example
Appendix C. OpenGL Features and Versions
List of OpenGL Functions
Functions Introduced by OpenGL Extensions
Glossary
Index
Code Snippets