You are previewing OpenGL SuperBible: Comprehensive Tutorial and Reference, Seventh Edition.
O'Reilly logo
OpenGL SuperBible: Comprehensive Tutorial and Reference, Seventh Edition

Book Description

OpenGL® SuperBible, Seventh Edition, is the definitive programmer’s guide, tutorial, and reference for OpenGL 4.5, the world’s leading 3D API for real-time computer graphics. The best introduction for any developer, it clearly explains OpenGL’s newest APIs; key extensions; shaders; and essential, related concepts. You’ll find up-to-date, hands-on guidance for all facets of modern OpenGL development—both desktop and mobile.

The authors explain what OpenGL does, how it connects to the graphics pipeline, and how it manages huge datasets to deliver compelling experiences. Step by step, they present increasingly sophisticated techniques, illuminating key concepts with worked examples. They introduce OpenGL on several popular platforms, and offer up-to-date best practices and performance advice.

This revised and updated edition introduces many new OpenGL 4.5 features, including important ARB and KHR extensions that are now part of the standard. It thoroughly covers the latest Approaching Zero Driver Overhead (AZDO) performance features, and demonstrates key enhancements with new example applications.

Coverage includes

  • A practical introduction to real-time 3D graphics, including foundational math

  • Core techniques for rendering, transformations, and texturing

  • Shaders and the OpenGL Shading Language (GLSL) in depth

  • Vertex processing, drawing commands, primitives, fragments, and framebuffers

  • Compute shaders: harnessing graphics cards for more than graphics

  • Pipeline monitoring and control

  • Managing, loading, and arbitrating access to data

  • Building larger applications and deploying them across platforms

  • Advanced rendering: light simulation, artistic and non-photorealistic effects, and more

  • Reducing CPU overhead and analyzing GPU behavior

  • Supercharging performance with persistent maps, bindless textures, and fine-grained synchronization

  • Preventing and debugging errors

  • New applications: texture compression, text drawing, font rendering with distance fields, high-quality texture filtering, and OpenMP 

  • Bonus material and sample code are available at openglsuperbible.com.

    Table of Contents

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