SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
Also available in other formats.
Register your product to gain access to bonus material or receive a coupon.
Complete Coverage of OpenGL® 4.5—the Latest Version (Includes 4.5, 4.4, SPIR-V, and Extensions)
The latest version of today’s leading worldwide standard for computer graphics, OpenGL 4.5 delivers significant improvements in application efficiency, flexibility, and performance. OpenGL 4.5 is an exceptionally mature and robust platform for programming high-quality computer-generated images and interactive applications using 2D and 3D objects, color images, and shaders.
OpenGL® Programming Guide, Ninth Edition, presents definitive, comprehensive information on OpenGL 4.5, 4.4, SPIR-V, OpenGL extensions, and the OpenGL Shading Language. It will serve you for as long as you write or maintain OpenGL code.
This edition of the best-selling “Red Book” fully integrates shader techniques alongside classic, function-centric approaches, and contains extensive code examples that demonstrate modern techniques. Starting with the fundamentals, its wide-ranging coverage includes drawing, color, pixels, fragments, transformations, textures, framebuffers, light and shadow, and memory techniques for advanced rendering and nongraphical applications. It also offers discussions of all shader stages, including thorough explorations of tessellation, geometric, and compute shaders.
New coverage in this edition includes
Download the sample pages (includes Chapter 2 and the Index.)
Figures xxi
Tables xxvii
Examples xxxi
About This Guide xxxix
Acknowledgments xlvChapter 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
SPIR-V 86
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