OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition

Read it now on the O’Reilly learning platform with a 10-day free trial.

O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

Book description

Includes Complete Coverage of the OpenGL® Shading Language!

Today’s OpenGL software interface enables programmers to produce extraordinarily high-quality computer-generated images and interactive applications using 2D and 3D objects, color images, and programmable shaders.

OpenGL® Programming Guide: The Official Guide to Learning OpenGL®, Version 4.3, Eighth Edition, has been almost completely rewritten and provides definitive, comprehensive information on OpenGL and the OpenGL Shading Language. This edition of the best-selling “Red Book” describes the features through OpenGL version 4.3. It also includes updated information and techniques formerly covered in OpenGL® Shading Language (the “Orange Book”).

For the first time, this guide completely integrates shader techniques, alongside classic, functioncentric techniques. Extensive new text and code are presented, demonstrating the latest in OpenGL programming techniques.

OpenGL® Programming Guide, Eighth Edition, provides clear explanations of OpenGL functionality and techniques, including processing geometric objects with vertex, tessellation, and geometry shaders using geometric transformations and viewing matrices; working with pixels and texture maps through fragment shaders; and advanced data techniques using framebuffer objects and compute shaders.

New OpenGL features covered in this edition include

Show and hide more Table of contents Product information

Table of contents

  1. Title Page
  2. Copyright Page
  3. Praise for OpenGL® Programming Guide, Eighth Edition
  4. Dedication Page
  5. Contents
  6. Figures
  7. Tables
  8. Examples
  9. About This Guide
    1. What This Guide Contains
    2. What’s New in This Edition
    3. What You Should Know Before Reading This Guide
    4. How to Obtain the Sample Code
    5. Errata
    6. Style Conventions
    1. What Is OpenGL?
    2. Your First Look at an OpenGL Program
    3. OpenGL Syntax
    4. OpenGL’s Rendering Pipeline
      1. Preparing to Send Data to OpenGL
      2. Sending Data to OpenGL
      3. Vertex Shading
      4. Tessellation Shading
      5. Geometry Shading
      6. Primitive Assembly
      7. Clipping
      8. Rasterization
      9. Fragment Shading
      10. Per-Fragment Operations
      1. Entering main()
      2. OpenGL Initialization
      3. Our First OpenGL Rendering
      1. Shaders and OpenGL
      2. OpenGL’s Programmable Pipeline
      3. An Overview of the OpenGL Shading Language
        1. Creating Shaders with GLSL
        2. Storage Qualifiers
        3. Statements
        4. Computational Invariance
        5. Shader Preprocessor
        6. Compiler Control
        7. Global Shader-Compilation Option
        1. Uniform Blocks
        2. Specifying Uniform Blocks in Shaders
        3. Accessing Uniform Blocks from Your Application
        4. Buffer Blocks
        5. In/Out Blocks
        1. Our LoadShaders() Function
        1. Advanced
        2. GLSL Subroutine Setup
        3. Selecting Shader Subroutines
        1. Advanced
        1. OpenGL Graphics Primitives
          1. Points
          2. Lines, Strips, and Loops
          3. Triangles, Strips, and Fans
          1. Creating and Allocating Buffers
          2. Getting Data into and out of Buffers
          3. Accessing the Content of Buffers
          4. Discarding Buffer Data
          1. VertexAttribPointer in Depth
          2. Static Vertex-Attribute Specification
          1. OpenGL Drawing Exercises
          2. Restarting Primitives
          1. Instanced Vertex Attributes
          2. Using the Instance Counter in Shaders
          3. Instancing Redux
          1. Basic Color Theory
          2. Buffers and Their Uses
            1. Color Buffers
            2. Depth Buffer
            3. Stencil Buffer
            4. Clearing Buffers
            5. Masking Buffers
            1. Color Representation and OpenGL
            2. Vertex Colors
            3. Rasterization
            1. Sample Shading
            1. Scissor Test
            2. Multisample Fragment Operations
            3. Stencil Test
            4. Stencil Examples
            5. Depth Test
            6. Blending
            7. Blending Factors
            8. Controlling Blending Factors
            9. The Blending Equation
            10. Dithering
            11. Logical Operations
            12. Occlusion Query
            13. Conditional Rendering
            1. Antialiasing Lines
            2. Antialiasing Polygons
            1. Advanced
            2. Renderbuffers
            3. Creating Renderbuffer Storage
            4. Framebuffer Attachments
            5. Framebuffer Completeness
            6. Invalidating Framebuffers
            1. Advanced
            2. Selecting Color Buffers for Writing and Reading
            3. Dual-Source Blending
            1. Clamping Returned Values
            1. Viewing
              1. Viewing Model
              2. Camera Model
              3. Orthographic Viewing Model
              1. Matrix Multiply Refresher
              2. Homogeneous Coordinates
              3. Linear Transformations and Matrices
              4. Transforming Normals
              5. OpenGL Matrices
              1. Viewport
              2. Multiple Viewports
              3. Advanced: z Precision
              4. Advanced: User Clipping
              1. Transform Feedback Objects
              2. Transform Feedback Buffers
              3. Configuring Transform Feedback Varyings
              4. Starting and Stopping Transform Feedback
              5. Transform Feedback Example—Particle System
              1. Texture Mapping
              2. Basic Texture Types
              3. Creating and Initializing Textures
                1. Texture Formats
                1. Explicitly Setting Texture Data
                2. Using Pixel Unpack Buffers
                3. Copying Data from the Framebuffer
                4. Loading Images from Files
                5. Retrieving Texture Data
                6. Texture Data Layout
                1. Sampler Parameters
                1. Texture Coordinates
                2. Arranging Texture Data
                3. Using Multiple Textures
                1. 3D Textures
                2. Array Textures
                3. Cube-Map Textures
                4. Shadow Samplers
                5. Depth-Stencil Textures
                6. Buffer Textures
                1. Linear Filtering
                2. Using and Generating Mipmaps
                3. Calculating the Mipmap Level
                4. Mipmap Level-of-Detail Control
                1. Explicit Level of Detail
                2. Explicit Gradient Specification
                3. Texture Fetch with Offsets
                4. Projective Texturing
                5. Texture Queries in Shaders
                6. Gathering Texels
                7. Combining Special Functions
                1. Textured Point Sprites
                2. Controlling the Appearance of Points
                1. Discarding Rendered Data
                1. Texture Redux
                2. Texture Best Practices
                1. Lighting Introduction
                2. Classic Lighting Model
                  1. Fragment Shaders for Different Light Styles
                  2. Moving Calculations to the Vertex Shader
                  3. Multiple Lights and Materials
                  4. Lighting Coordinate Systems
                  5. Limitations of the Classic Lighting Model
                  1. Hemisphere Lighting
                  2. Image-Based Lighting
                  3. Lighting with Spherical Harmonics
                  1. Creating a Shadow Map
                  1. Procedural Texturing
                    1. Regular Patterns
                    2. Toy Ball
                    3. Lattice
                    4. Procedural Shading Summary
                    1. Application Setup
                    2. Vertex Shader
                    3. Fragment Shader
                    4. Normal Maps
                    1. Sources of Aliasing
                    2. Avoiding Aliasing
                    3. Increasing Resolution
                    4. Antialiasing High Frequencies
                    5. Frequency Clamping
                    6. Procedural Antialiasing Summary
                    1. Definition of Noise
                    2. Noise Textures
                    3. Trade-offs
                    4. A Simple Noise Shader
                    5. Turbulence
                    6. Marble
                    7. Granite
                    8. Wood
                    9. Noise Summary
                    1. Tessellation Shaders
                    2. Tessellation Patches
                    3. Tessellation Control Shaders
                      1. Generating Output-Patch Vertices
                      2. Tessellation Control Shader Variables
                      3. Controlling Tessellation
                      1. Specifying the Primitive Generation Domain
                      2. Specifying the Face Winding for Generated Primitives
                      3. Specifying the Spacing of Tessellation Coordinates
                      4. Additional Tessellation Evaluation Shader layout Options
                      5. Specifying a Vertex’s Position
                      6. Tessellation Evaluation Shader Variables
                      1. Processing Patch Input Vertices
                      2. Evaluating Tessellation Coordinates for the Teapot
                      1. View-Dependent Tessellation
                      2. Shared Tessellated Edges and Cracking
                      3. Displacement Mapping
                      1. Creating a Geometry Shader
                      2. Geometry Shader Inputs and Outputs
                        1. Geometry Shader Inputs
                        2. Special Geometry Shader Primitives
                        3. Geometry Shader Outputs
                        1. Culling Geometry
                        2. Geometry Amplification
                        1. Multiple Output Streams
                        2. Primitive Queries
                        3. Using Transform Feedback Results
                        1. Viewport Index
                        2. Layered Rendering
                        1. Geometry Shader Redux
                        2. Geometry Shader Best Practices
                        1. Using Textures for Generic Data Storage
                          1. Binding Textures to Image Units
                          2. Reading from and Writing to Images
                          1. Writing Structured Data
                          1. Atomic Operations on Images
                          2. Atomic Operations on Buffers
                          3. Sync Objects
                          4. Image Qualifiers and Barriers
                          5. High Performance Atomic Counters
                          1. Order-Independent Transparency
                          1. Overview
                          2. Workgroups and Dispatch
                            1. Knowing Where You Are
                            1. Communication
                            2. Synchronization
                            1. Physical Simulation
                            2. Image Processing
                            1. Compute Shader Redux
                            2. Compute Shader Best Practices
                            1. Initializing and Creating a Window
                            2. Accessing Functions
                            3. Handling Window and Input Events
                            4. Managing a Background Process
                            5. Running the Program
                            1. OpenGL ES
                            2. WebGL
                              1. Setting up WebGL within an HTML5 page
                              2. Initializing Shaders in WebGL
                              3. Initializing Vertex Data in WebGL
                              4. Using Texture Maps in WebGL
                              1. Built-in Variables
                                1. Built-in Variable Declarations
                                2. Built-in Variable Descriptions
                                1. Angle and Trigonometry Functions
                                2. Exponential Functions
                                3. Common Functions
                                4. Floating-Point Pack and Unpack Functions
                                5. Geometric Functions
                                6. Matrix Functions
                                7. Vector Relational Functions
                                8. Integer Functions
                                9. Texture Functions
                                10. Atomic-Counter Functions
                                11. Atomic Memory Functions
                                12. Image Functions
                                13. Fragment Processing Functions
                                14. Noise Functions
                                15. Geometry Shader Functions
                                16. Shader Invocation Control Functions
                                17. Shader Memory Control Functions
                                1. The Query Commands
                                2. OpenGL State Variables
                                  1. Current Values and Associated Data
                                  2. Vertex Array Object State
                                  3. Vertex Array Data
                                  4. Buffer Object State
                                  5. Transformation State
                                  6. Coloring State
                                  7. Rasterization State
                                  8. Multisampling
                                  9. Textures
                                  10. Textures
                                  11. Textures
                                  12. Textures
                                  13. Texture Environment
                                  14. Pixel Operations
                                  15. Framebuffer Controls
                                  16. Framebuffer State
                                  17. Framebuffer State
                                  18. Frambuffer State
                                  19. Renderbuffer State
                                  20. Renderbuffer State
                                  21. Pixel State
                                  22. Shader Object State
                                  23. Shader Program Pipeline Object State
                                  24. Shader Program Object State
                                  25. Program Interface State
                                  26. Program Object Resource State
                                  27. Vertex and Geometry Shader State
                                  28. Query Object State
                                  29. Image State
                                  30. Transform Feedback State
                                  31. Atomic Counter State
                                  32. Shader Storage Buffer State
                                  33. Sync Object State
                                  34. Hints
                                  35. Compute Dispatch State
                                  36. Implementation-Dependent Values
                                  37. Tessellation Shader Implementation-Dependent Limits
                                  38. Geometry Shader Implementation-Dependent Limits
                                  39. Fragment Shader Implementation-Dependent Limits
                                  40. Implementation-Dependent Compute Shader Limits
                                  41. Implementation-Dependent Shader Limits
                                  42. Implementation-Dependent Debug Output State
                                  43. Implementation-Dependent Values
                                  44. Internal Format-Dependent Values
                                  45. Implementation-Dependent Transform Feedback Limits
                                  46. Framebuffer-Dependent Values
                                  47. Miscellaneous
                                  1. Homogeneous Coordinates
                                    1. Transforming Vertices
                                    2. Transforming Normals
                                    1. Translation
                                    2. Scaling
                                    3. Rotation
                                    4. Perspective Projection
                                    5. Orthographic Projection
                                    1. Accessing New OpenGL Functions
                                      1. GLEW: The OpenGL Extension Wrangler
                                      1. Initialization
                                      2. Controlling Rendering
                                      3. GLX Prototypes
                                      1. Initialization
                                      2. Controlling Rendering
                                      3. WGL Prototypes
                                      1. Initialization
                                      2. Controlling Rendering
                                      3. CGL Prototypes
                                      1. Initialization
                                      1. Reduced-Precision Floating-Point Values
                                      2. 16-bit Floating-Point Values
                                      3. 10- and 11-bit Unsigned Floating-Point Values
                                      1. Creating a Debug Context
                                      2. Debug Output
                                        1. Debug Messages
                                        2. Filtering Messages
                                        3. Application-Generated Messages
                                        1. Naming Objects
                                        1. Profiling Tools
                                        2. In-Application Profiling
                                        1. Using Standard Layout Qualifiers
                                        2. The std140 Layout Rules
                                        3. The std430 Layout Rules
                                        Show and hide more

                                        Product information

                                        • Title: OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition
                                        • Author(s): Dave Shreiner, Graham Sellers, John M. Kessenich, Bill M. Licea-Kane
                                        • Release date: March 2013
                                        • Publisher(s): Addison-Wesley Professional
                                        • ISBN: 9780132748445