OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.5 with SPIR-V (9e) : 9780134495491

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.5 with SPIR-V (9e)

Published by
Pearson Higher Ed USA
Out of stock
Title type
Title type
OpenGL® Programming Guide, Ninth 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.
Table of contents

Figures xxi

Tables xxvii

Examples xxxi

About This Guide xxxix

Acknowledgments xlv


Chapter 1: Introduction to OpenGL 1

What Is OpenGL? 2

Your First Look at an OpenGL Program 4

OpenGL Syntax 8

OpenGL’s Rendering Pipeline 10

Our First Program: A Detailed Discussion 14


Chapter 2: Shader Fundamentals 33

Shaders and OpenGL 34

OpenGL’s Programmable Pipeline 35

An Overview of the OpenGL Shading Language 37

Interface Blocks 61

Compiling Shaders 72

Shader Subroutines 79

Separate Shader Objects 84



Chapter 3: Drawing with OpenGL 95

OpenGL Graphics Primitives 96

Data in OpenGL Buffers 102

Vertex Specification 117

OpenGL Drawing Commands 124


Chapter 4: Color, Pixels, and Fragments 151

Basic Color Theory 152

Buffers and Their Uses 154

Color and OpenGL 158

Testing and Operating on Fragments 163

Multisampling 185

Per-Primitive Antialiasing 188

Reading and Copying Pixel Data 191

Copying Pixel Rectangles 193


Chapter 5: Viewing Transformations, Culling, Clipping, and Feedback 197

Viewing 198

User Transformations 203

OpenGL Transformations 226

Transform Feedback 231


Chapter 6: Textures and Framebuffers 255

Introduction to Texturing 257

Basic Texture Types 258

Creating and Initializing Textures 260

Specifying Texture Data 265

Texture Formats 279

Compressed Textures 285

Sampler Objects 288

Using Textures 291

Complex Texture Types 302

Texture Views 317

Filtering 321

Bindless Textures 337

Sparse Textures 341

Point Sprites 344

Framebuffer Objects 348

Rendering to Texture Maps 351

Chapter Summary 370


Chapter 7: Light and Shadow 373

Lighting Introduction 374

Classic Lighting Model 375

Advanced Lighting Models 399

Shadow Mapping 413


Chapter 8: Procedural Texturing 423

Procedural Texturing 424

Bump Mapping 444

Antialiasing Procedural Textures 454

Noise 472

Further Information 495


Chapter 9: Tessellation Shaders 497

Tessellation Shaders 498

Tessellation Patches 499

Tessellation Control Shaders 500

Tessellation Evaluation Shaders 508

A Tessellation Example: The Teapot 512

Additional Tessellation Techniques 516


Chapter 10: Geometry Shaders 521

Creating a Geometry Shader 523

Geometry Shader Inputs and Outputs 526

Producing Primitives 537

Advanced Transform Feedback 544

Geometry Shader Instancing 561

Multiple Viewports and Layered Rendering 562

Chapter Summary 572


Chapter 11: Memory 577

Using Textures for Generic Data Storage 578

Shader Storage Buffer Objects 589

Atomic Operations and Synchronization 591

Example: Order-Independent Transparency 621


Chapter 12: Compute Shaders 635

Overview 636

Workgroups and Dispatch 637

Communication and Synchronization 644

Examples 648

Chapter Summary 659


Appendix A: Support Libraries 663

Basics of GLFW: The OpenGL Utility Framework 664

Initializing and Creating a Window 664

Handling User Input 667

Controlling the Window 671

Shutting Down Cleanly 675

GL3W: OpenGL Glue 676


Appendix B: OpenGL ES and WebGL 679

OpenGL ES 680

WebGL 682


Appendix C: Built-in GLSL Variables and Functions 693

Built-in Variables 693

Built-in Constants 705

Built-in Functions 707


Appendix D: State Variables 757

The Query Commands 757

OpenGL State Variables 765


Appendix E: Homogeneous Coordinates and Transformation Matrices 849

Homogeneous Coordinates 849

Transformation Matrices 851


Appendix F: Floating-Point Formats for Textures, Framebuffers, and Renderbuffers 855

Reduced-Precision Floating-Point Values 855

16-Bit Floating-Point Values 856

10- and 11-Bit Unsigned Floating-Point Values 858


Appendix G: Debugging and Profiling OpenGL 863

Creating a Debug Context 863

Debug Output 866

Debug Groups 874

Profiling 877


Appendix H: Buffer Object Layouts 883

Using Standard Layout Qualifiers 883

The std140 Layout Rules 884

The std430 Layout Rules 885


Glossary 887

Index 917

New to this edition
Previous book only went through OpenGL version 4.3, but, OpenGL has added 4.4, 4.5, SPIR-V, and extensions. This new (and final) update will incorporate all of these changes.
Features & benefits
  • Authoritative, trusted OpenGL 4.5 coverage: the latest book in the official Open Graphics Library, written by members of the Khronos OpenGL standards committees
  • Responds to developers' requests with extensive, up-to-date coverage of shaders, the part of the OpenGL spec that has changed the most
  • Contains extensive new text and code, replacing coverage of deprecated features
Author biography

John M. Kessenich, staff software engineer at Google and creator of SPIR-V, has been active in OpenGL and GLSL Khronos standards’ development since 1999. He is the primary editor of the SPIR-V and GLSL specifications, and creates shader compiler tools and translators to promote portability of those standards.


Graham Sellers, AMD Software Architect and Engineering Fellow, is a Khronos API lead and represents AMD at the OpenGL ARB. He has contributed to the core Vulkan and OpenGL specs and extensions, and holds several graphics and image processing patents.


Dave Shreiner is a twenty-five year veteran of the computer graphics industry, where he’s worked almost exclusively with programming interfaces like OpenGL. In addition to having written and taught instructional courses on using computer graphics APIs, he was also the lead author for almost ten years on several Addison-Wesley publications relating to computer graphics.