953

OpenGL 4.4 (Compatibility Profile) - March 19, 2014€¦ · The OpenGL R Graphics System: A Specification (Version 4.4 (Compatibility Profile) - March 19, 2014) Mark Segal Kurt

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

  • The OpenGL R© Graphics System:A Specification

    (Version 4.4 (Compatibility Profile) - March 19,2014)

    Mark SegalKurt Akeley

    Editor (version 1.1): Chris FrazierEditor (versions 1.2-4.4 ): Jon Leech

    Editor (version 2.0): Pat Brown

  • Copyright c© 2006-2014 The Khronos Group Inc. All Rights Reserved.

    This specification is protected by copyright laws and contains material proprietaryto the Khronos Group, Inc. It or any components may not be reproduced, repub-lished, distributed, transmitted, displayed, broadcast or otherwise exploited in anymanner without the express prior written permission of Khronos Group. You mayuse this specification for implementing the functionality therein, without altering orremoving any trademark, copyright or other notice from the specification, but thereceipt or possession of this specification does not convey any rights to reproduce,disclose, or distribute its contents, or to manufacture, use, or sell anything that itmay describe, in whole or in part.

    Khronos Group grants express permission to any current Promoter, Contributoror Adopter member of Khronos to copy and redistribute UNMODIFIED versionsof this specification in any fashion, provided that NO CHARGE is made for thespecification and the latest available update of the specification for any versionof the API is used whenever possible. Such distributed specification may be re-formatted AS LONG AS the contents of the specification are not changed in anyway. The specification may be incorporated into a product that is sold as long assuch product includes significant independent work developed by the seller. A linkto the current version of this specification on the Khronos Group web-site shouldbe included whenever possible with specification distributions.

    Khronos Group makes no, and expressly disclaims any, representations or war-ranties, express or implied, regarding this specification, including, without limita-tion, any implied warranties of merchantability or fitness for a particular purposeor non-infringement of any intellectual property. Khronos Group makes no, andexpressly disclaims any, warranties, express or implied, regarding the correctness,accuracy, completeness, timeliness, and reliability of the specification. Under nocircumstances will the Khronos Group, or any of its Promoters, Contributors orMembers or their respective partners, officers, directors, employees, agents or rep-resentatives be liable for any damages, whether direct, indirect, special or conse-quential damages for lost revenues, lost profits, or otherwise, arising from or inconnection with these materials.

    Khronos is a trademark of The Khronos Group Inc. OpenGL is a registered trade-mark, and OpenGL ES is a trademark, of Silicon Graphics International.

  • Contents

    1 Introduction 11.1 Formatting of the OpenGL Specification . . . . . . . . . . . . . . 1

    1.1.1 Formatting of the Compatibility Profile . . . . . . . . . . 11.1.2 Formatting of Optional Features . . . . . . . . . . . . . . 1

    1.2 What is the OpenGL Graphics System? . . . . . . . . . . . . . . 21.2.1 Programmer’s View of OpenGL . . . . . . . . . . . . . . 21.2.2 Implementor’s View of OpenGL . . . . . . . . . . . . . . 21.2.3 Our View . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2.4 Fixed-function Hardware and the Compatibility Profile . . 31.2.5 The Deprecation Model . . . . . . . . . . . . . . . . . . 3

    1.3 Related APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3.1 OpenGL Shading Language . . . . . . . . . . . . . . . . 41.3.2 OpenGL ES . . . . . . . . . . . . . . . . . . . . . . . . . 41.3.3 OpenGL ES Shading Language . . . . . . . . . . . . . . 51.3.4 WebGL . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.3.5 Window System Bindings . . . . . . . . . . . . . . . . . 61.3.6 OpenCL . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    1.4 Filing Bug Reports . . . . . . . . . . . . . . . . . . . . . . . . . 7

    2 OpenGL Fundamentals 82.1 Execution Model . . . . . . . . . . . . . . . . . . . . . . . . . . 82.2 Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    2.2.1 Data Conversion For State-Setting Commands . . . . . . 122.2.2 Data Conversions For State Query Commands . . . . . . 14

    2.3 Command Execution . . . . . . . . . . . . . . . . . . . . . . . . 152.3.1 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.3.2 Flush and Finish . . . . . . . . . . . . . . . . . . . . . . 182.3.3 Numeric Representation and Computation . . . . . . . . . 182.3.4 Fixed-Point Data Conversions . . . . . . . . . . . . . . . 22

    i

  • CONTENTS ii

    2.4 Rendering Commands . . . . . . . . . . . . . . . . . . . . . . . 242.5 Context State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    2.5.1 Generic Context State Queries . . . . . . . . . . . . . . . 252.6 Objects and the Object Model . . . . . . . . . . . . . . . . . . . 25

    2.6.1 Object Management . . . . . . . . . . . . . . . . . . . . 252.6.2 Buffer Objects . . . . . . . . . . . . . . . . . . . . . . . 272.6.3 Shader Objects . . . . . . . . . . . . . . . . . . . . . . . 272.6.4 Program Objects . . . . . . . . . . . . . . . . . . . . . . 272.6.5 Program Pipeline Objects . . . . . . . . . . . . . . . . . 272.6.6 Texture Objects . . . . . . . . . . . . . . . . . . . . . . . 272.6.7 Sampler Objects . . . . . . . . . . . . . . . . . . . . . . 282.6.8 Renderbuffer Objects . . . . . . . . . . . . . . . . . . . . 282.6.9 Framebuffer Objects . . . . . . . . . . . . . . . . . . . . 282.6.10 Vertex Array Objects . . . . . . . . . . . . . . . . . . . . 292.6.11 Transform Feedback Objects . . . . . . . . . . . . . . . . 292.6.12 Query Objects . . . . . . . . . . . . . . . . . . . . . . . 292.6.13 Sync Objects . . . . . . . . . . . . . . . . . . . . . . . . 292.6.14 Display Lists . . . . . . . . . . . . . . . . . . . . . . . . 30

    3 Dataflow Model 31

    4 Event Model 344.1 Sync Objects and Fences . . . . . . . . . . . . . . . . . . . . . . 34

    4.1.1 Waiting for Sync Objects . . . . . . . . . . . . . . . . . . 364.1.2 Signaling . . . . . . . . . . . . . . . . . . . . . . . . . . 384.1.3 Sync Object Queries . . . . . . . . . . . . . . . . . . . . 38

    4.2 Query Objects and Asynchronous Queries . . . . . . . . . . . . . 394.2.1 Query Object Queries . . . . . . . . . . . . . . . . . . . 43

    4.3 Time Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

    5 Shared Objects and Multiple Contexts 485.1 Object Deletion Behavior . . . . . . . . . . . . . . . . . . . . . . 49

    5.1.1 Side Effects of Shared Context Destruction . . . . . . . . 495.1.2 Automatic Unbinding of Deleted Objects . . . . . . . . . 495.1.3 Deleted Object and Object Name Lifetimes . . . . . . . . 49

    5.2 Sync Objects and Multiple Contexts . . . . . . . . . . . . . . . . 505.3 Propagating Changes to Objects . . . . . . . . . . . . . . . . . . 50

    5.3.1 Determining Completion of Changes to an object . . . . . 515.3.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 525.3.3 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS iii

    6 Buffer Objects 546.1 Creating and Binding Buffer Objects . . . . . . . . . . . . . . . . 55

    6.1.1 Binding Buffer Objects to Indexed Targets . . . . . . . . . 576.2 Creating and Modifying Buffer Object Data Stores . . . . . . . . 60

    6.2.1 Clearing Buffer Object Data Stores . . . . . . . . . . . . 656.3 Mapping and Unmapping Buffer Data . . . . . . . . . . . . . . . 66

    6.3.1 Unmapping Buffers . . . . . . . . . . . . . . . . . . . . . 716.3.2 Effects of Mapping Buffers on Other GL Commands . . . 71

    6.4 Effects of Accessing Outside Buffer Bounds . . . . . . . . . . . . 726.5 Invalidating Buffer Data . . . . . . . . . . . . . . . . . . . . . . 726.6 Copying Between Buffers . . . . . . . . . . . . . . . . . . . . . . 736.7 Buffer Object Queries . . . . . . . . . . . . . . . . . . . . . . . . 74

    6.7.1 Indexed Buffer Object Limits and Binding Queries . . . . 756.8 Buffer Object State . . . . . . . . . . . . . . . . . . . . . . . . . 77

    7 Programs and Shaders 787.1 Shader Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 797.2 Shader Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . 827.3 Program Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    7.3.1 Program Interfaces . . . . . . . . . . . . . . . . . . . . . 907.4 Program Pipeline Objects . . . . . . . . . . . . . . . . . . . . . . 109

    7.4.1 Shader Interface Matching . . . . . . . . . . . . . . . . . 1127.4.2 Program Pipeline Object State . . . . . . . . . . . . . . . 115

    7.5 Program Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . 1167.6 Uniform Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    7.6.1 Loading Uniform Variables In The Default Uniform Block 1257.6.2 Uniform Blocks . . . . . . . . . . . . . . . . . . . . . . . 1297.6.3 Uniform Buffer Object Bindings . . . . . . . . . . . . . . 132

    7.7 Atomic Counter Buffers . . . . . . . . . . . . . . . . . . . . . . . 1337.7.1 Atomic Counter Buffer Object Storage . . . . . . . . . . 1347.7.2 Atomic Counter Buffer Bindings . . . . . . . . . . . . . . 134

    7.8 Shader Buffer Variables and Shader Storage Blocks . . . . . . . . 1357.9 Subroutine Uniform Variables . . . . . . . . . . . . . . . . . . . 1377.10 Samplers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1407.11 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1417.12 Shader Memory Access . . . . . . . . . . . . . . . . . . . . . . . 142

    7.12.1 Shader Memory Access Ordering . . . . . . . . . . . . . 1427.12.2 Shader Memory Access Synchronization . . . . . . . . . 144

    7.13 Shader, Program, and Program Pipeline Queries . . . . . . . . . . 1487.14 Required State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS iv

    8 Textures and Samplers 1598.1 Texture Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 1628.2 Sampler Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 1668.3 Sampler Object Queries . . . . . . . . . . . . . . . . . . . . . . . 1708.4 Pixel Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

    8.4.1 Pixel Storage Modes and Pixel Buffer Objects . . . . . . . 1718.4.2 The Imaging Subset . . . . . . . . . . . . . . . . . . . . 1728.4.3 Pixel Transfer Modes . . . . . . . . . . . . . . . . . . . . 1738.4.4 Transfer of Pixel Rectangles . . . . . . . . . . . . . . . . 1928.4.5 Pixel Transfer Operations . . . . . . . . . . . . . . . . . 205

    8.5 Texture Image Specification . . . . . . . . . . . . . . . . . . . . 2158.5.1 Required Texture Formats . . . . . . . . . . . . . . . . . 2198.5.2 Encoding of Special Internal Formats . . . . . . . . . . . 2198.5.3 Texture Image Structure . . . . . . . . . . . . . . . . . . 224

    8.6 Alternate Texture Image Specification Commands . . . . . . . . . 2318.6.1 Texture Copying Feedback Loops . . . . . . . . . . . . . 237

    8.7 Compressed Texture Images . . . . . . . . . . . . . . . . . . . . 2378.8 Multisample Textures . . . . . . . . . . . . . . . . . . . . . . . . 2448.9 Buffer Textures . . . . . . . . . . . . . . . . . . . . . . . . . . . 2468.10 Texture Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 2498.11 Texture Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

    8.11.1 Active Texture . . . . . . . . . . . . . . . . . . . . . . . 2538.11.2 Texture Parameter Queries . . . . . . . . . . . . . . . . . 2538.11.3 Texture Level Parameter Queries . . . . . . . . . . . . . . 2548.11.4 Texture Image Queries . . . . . . . . . . . . . . . . . . . 256

    8.12 Depth Component Textures . . . . . . . . . . . . . . . . . . . . . 2598.13 Cube Map Texture Selection . . . . . . . . . . . . . . . . . . . . 260

    8.13.1 Seamless Cube Map Filtering . . . . . . . . . . . . . . . 2608.14 Texture Minification . . . . . . . . . . . . . . . . . . . . . . . . 261

    8.14.1 Scale Factor and Level of Detail . . . . . . . . . . . . . . 2628.14.2 Coordinate Wrapping and Texel Selection . . . . . . . . . 2648.14.3 Mipmapping . . . . . . . . . . . . . . . . . . . . . . . . 2698.14.4 Manual Mipmap Generation . . . . . . . . . . . . . . . . 2718.14.5 Automatic Mipmap Generation . . . . . . . . . . . . . . 272

    8.15 Texture Magnification . . . . . . . . . . . . . . . . . . . . . . . . 2738.16 Combined Depth/Stencil Textures . . . . . . . . . . . . . . . . . 2738.17 Texture Completeness . . . . . . . . . . . . . . . . . . . . . . . . 273

    8.17.1 Effects of Sampler Objects on Texture Completeness . . . 2758.17.2 Effects of Completeness on Texture Application . . . . . . 2758.17.3 Effects of Completeness on Texture Image Specification . 275

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS v

    8.18 Texture Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2768.19 Immutable-Format Texture Images . . . . . . . . . . . . . . . . . 2808.20 Invalidating Texture Image Data . . . . . . . . . . . . . . . . . . 2858.21 Clearing Texture Image Data . . . . . . . . . . . . . . . . . . . . 2868.22 Texture State and Proxy State . . . . . . . . . . . . . . . . . . . . 2888.23 Texture Comparison Modes . . . . . . . . . . . . . . . . . . . . . 291

    8.23.1 Depth Texture Comparison Mode . . . . . . . . . . . . . 2918.24 sRGB Texture Color Conversion . . . . . . . . . . . . . . . . . . 2938.25 Shared Exponent Texture Color Conversion . . . . . . . . . . . . 2948.26 Texture Image Loads and Stores . . . . . . . . . . . . . . . . . . 294

    8.26.1 Image Unit Queries . . . . . . . . . . . . . . . . . . . . . 303

    9 Framebuffers and Framebuffer Objects 3049.1 Framebuffer Overview . . . . . . . . . . . . . . . . . . . . . . . 3049.2 Binding and Managing Framebuffer Objects . . . . . . . . . . . . 306

    9.2.1 Framebuffer Object Parameters . . . . . . . . . . . . . . 3109.2.2 Attaching Images to Framebuffer Objects . . . . . . . . . 3119.2.3 Framebuffer Object Queries . . . . . . . . . . . . . . . . 3129.2.4 Renderbuffer Objects . . . . . . . . . . . . . . . . . . . . 3159.2.5 Required Renderbuffer Formats . . . . . . . . . . . . . . 3189.2.6 Renderbuffer Object Queries . . . . . . . . . . . . . . . . 3189.2.7 Attaching Renderbuffer Images to a Framebuffer . . . . . 3199.2.8 Attaching Texture Images to a Framebuffer . . . . . . . . 321

    9.3 Feedback Loops Between Textures and the Framebuffer . . . . . . 3259.3.1 Rendering Feedback Loops . . . . . . . . . . . . . . . . . 3259.3.2 Texture Copying Feedback Loops . . . . . . . . . . . . . 327

    9.4 Framebuffer Completeness . . . . . . . . . . . . . . . . . . . . . 3279.4.1 Framebuffer Attachment Completeness . . . . . . . . . . 3289.4.2 Whole Framebuffer Completeness . . . . . . . . . . . . . 3299.4.3 Required Framebuffer Formats . . . . . . . . . . . . . . . 3329.4.4 Effects of Framebuffer Completeness on Framebuffer Op-

    erations . . . . . . . . . . . . . . . . . . . . . . . . . . . 3329.4.5 Effects of Framebuffer State on Framebuffer Dependent

    Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3339.5 Mapping between Pixel and Element in Attached Image . . . . . . 3349.6 Conversion to Framebuffer-Attachable Image Components . . . . 3349.7 Conversion to RGBA Values . . . . . . . . . . . . . . . . . . . . 3359.8 Layered Framebuffers . . . . . . . . . . . . . . . . . . . . . . . . 335

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS vi

    10 Vertex Specification and Drawing Commands 33710.1 Primitive Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

    10.1.1 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34110.1.2 Line Strips . . . . . . . . . . . . . . . . . . . . . . . . . 34210.1.3 Line Loops . . . . . . . . . . . . . . . . . . . . . . . . . 34210.1.4 Separate Lines . . . . . . . . . . . . . . . . . . . . . . . 34210.1.5 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . 34210.1.6 Triangle Strips . . . . . . . . . . . . . . . . . . . . . . . 34310.1.7 Triangle Fans . . . . . . . . . . . . . . . . . . . . . . . . 34310.1.8 Separate Triangles . . . . . . . . . . . . . . . . . . . . . 34410.1.9 Quadrilateral (quad) strips . . . . . . . . . . . . . . . . . 34410.1.10 Separate Quadrilaterals . . . . . . . . . . . . . . . . . . . 34410.1.11 Lines with Adjacency . . . . . . . . . . . . . . . . . . . 34510.1.12 Line Strips with Adjacency . . . . . . . . . . . . . . . . . 34610.1.13 Triangles with Adjacency . . . . . . . . . . . . . . . . . 34610.1.14 Triangle Strips with Adjacency . . . . . . . . . . . . . . . 34710.1.15 Separate Patches . . . . . . . . . . . . . . . . . . . . . . 34810.1.16 General Considerations For Polygon Primitives . . . . . . 34910.1.17 Polygon Edges . . . . . . . . . . . . . . . . . . . . . . . 349

    10.2 Current Vertex Attribute Values . . . . . . . . . . . . . . . . . . . 35010.2.1 Current Generic Attributes . . . . . . . . . . . . . . . . . 35010.2.2 Current Conventional Attributes . . . . . . . . . . . . . . 35210.2.3 Vertex Attribute Queries . . . . . . . . . . . . . . . . . . 35510.2.4 Required State . . . . . . . . . . . . . . . . . . . . . . . 355

    10.3 Vertex Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35610.3.1 Specifying Arrays for Generic Vertex Attributes . . . . . . 35610.3.2 Specifying Arrays for Fixed-Function Attributes . . . . . 36210.3.3 Vertex Attribute Divisors . . . . . . . . . . . . . . . . . . 36510.3.4 Transferring Array Elements . . . . . . . . . . . . . . . . 36510.3.5 Primitive Restart . . . . . . . . . . . . . . . . . . . . . . 36610.3.6 Robust Buffer Access . . . . . . . . . . . . . . . . . . . . 36710.3.7 Packed Vertex Data Formats . . . . . . . . . . . . . . . . 36710.3.8 Vertex Arrays in Buffer Objects . . . . . . . . . . . . . . 36810.3.9 Array Indices in Buffer Objects . . . . . . . . . . . . . . 36910.3.10 Indirect Commands in Buffer Objects . . . . . . . . . . . 370

    10.4 Vertex Array Objects . . . . . . . . . . . . . . . . . . . . . . . . 37010.5 Drawing Commands Using Vertex Arrays . . . . . . . . . . . . . 372

    10.5.1 Interleaved Arrays . . . . . . . . . . . . . . . . . . . . . 38210.6 Vertex Array and Vertex Array Object Queries . . . . . . . . . . . 38410.7 Required State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS vii

    10.8 Drawing Commands Using Begin and End . . . . . . . . . . . . 38710.8.1 Transferring Vertices With Vertex Commands . . . . . . . 38710.8.2 Transferring Vertices With Vertex Attribute Zero . . . . . 38810.8.3 Bundling Attributes With Vertex Commands . . . . . . . 38810.8.4 Transferring Vertices With ArrayElement . . . . . . . . 38810.8.5 Commands Allowed Between Begin and End . . . . . . . 390

    10.9 Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39110.10Conditional Rendering . . . . . . . . . . . . . . . . . . . . . . . 392

    11 Programmable Vertex Processing 39411.1 Vertex Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . . 394

    11.1.1 Vertex Attributes . . . . . . . . . . . . . . . . . . . . . . 39411.1.2 Vertex Shader Variables . . . . . . . . . . . . . . . . . . 40011.1.3 Shader Execution . . . . . . . . . . . . . . . . . . . . . . 405

    11.2 Tessellation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41711.2.1 Tessellation Control Shaders . . . . . . . . . . . . . . . . 41811.2.2 Tessellation Primitive Generation . . . . . . . . . . . . . 42311.2.3 Tessellation Evaluation Shaders . . . . . . . . . . . . . . 432

    11.3 Geometry Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . 43711.3.1 Geometry Shader Input Primitives . . . . . . . . . . . . . 43811.3.2 Geometry Shader Output Primitives . . . . . . . . . . . . 44011.3.3 Geometry Shader Variables . . . . . . . . . . . . . . . . . 44011.3.4 Geometry Shader Execution Environment . . . . . . . . . 441

    12 Fixed-Function Vertex Processing 44812.1 Fixed-Function Vertex Transformations . . . . . . . . . . . . . . 448

    12.1.1 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 44912.1.2 Normal Transformation . . . . . . . . . . . . . . . . . . . 45512.1.3 Generating Texture Coordinates . . . . . . . . . . . . . . 456

    12.2 Fixed-Function Vertex Lighting and Coloring . . . . . . . . . . . 45912.2.1 Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . 46012.2.2 Lighting Parameter Specification . . . . . . . . . . . . . . 46512.2.3 ColorMaterial . . . . . . . . . . . . . . . . . . . . . . . 46812.2.4 Lighting Parameter Queries . . . . . . . . . . . . . . . . 46812.2.5 Lighting State . . . . . . . . . . . . . . . . . . . . . . . . 47012.2.6 Color Index Lighting . . . . . . . . . . . . . . . . . . . . 470

    13 Fixed-Function Vertex Post-Processing 47213.1 Clamping or Masking . . . . . . . . . . . . . . . . . . . . . . . . 47313.2 Transform Feedback . . . . . . . . . . . . . . . . . . . . . . . . 473

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS viii

    13.2.1 Transform Feedback Objects . . . . . . . . . . . . . . . . 47413.2.2 Transform Feedback Primitive Capture . . . . . . . . . . 47613.2.3 Transform Feedback Draw Operations . . . . . . . . . . . 480

    13.3 Primitive Queries . . . . . . . . . . . . . . . . . . . . . . . . . . 48113.4 Flatshading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48213.5 Primitive Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . 484

    13.5.1 Color and Associated Data Clipping . . . . . . . . . . . . 48713.5.2 Clip Plane Queries . . . . . . . . . . . . . . . . . . . . . 487

    13.6 Coordinate Transformations . . . . . . . . . . . . . . . . . . . . 48813.6.1 Controlling the Viewport . . . . . . . . . . . . . . . . . . 488

    13.7 Final Color Processing . . . . . . . . . . . . . . . . . . . . . . . 491

    14 Fixed-Function Primitive Assembly and Rasterization 49314.1 Discarding Primitives Before Rasterization . . . . . . . . . . . . 49514.2 Invariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49514.3 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

    14.3.1 Multisampling . . . . . . . . . . . . . . . . . . . . . . . 49714.4 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500

    14.4.1 Basic Point Rasterization . . . . . . . . . . . . . . . . . . 50214.4.2 Point Rasterization State . . . . . . . . . . . . . . . . . . 50614.4.3 Point Multisample Rasterization . . . . . . . . . . . . . . 506

    14.5 Line Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . 50714.5.1 Basic Line Segment Rasterization . . . . . . . . . . . . . 50714.5.2 Other Line Segment Features . . . . . . . . . . . . . . . . 51014.5.3 Line Rasterization State . . . . . . . . . . . . . . . . . . 51314.5.4 Line Multisample Rasterization . . . . . . . . . . . . . . 513

    14.6 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51314.6.1 Basic Polygon Rasterization . . . . . . . . . . . . . . . . 51414.6.2 Stippling . . . . . . . . . . . . . . . . . . . . . . . . . . 51614.6.3 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . 51714.6.4 Options Controlling Polygon Rasterization . . . . . . . . 51814.6.5 Depth Offset . . . . . . . . . . . . . . . . . . . . . . . . 51814.6.6 Polygon Multisample Rasterization . . . . . . . . . . . . 52014.6.7 Polygon Rasterization State . . . . . . . . . . . . . . . . 520

    14.7 Current Raster Position . . . . . . . . . . . . . . . . . . . . . . . 52114.8 Bitmaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52414.9 Early Per-Fragment Tests . . . . . . . . . . . . . . . . . . . . . . 526

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS ix

    15 Programmable Fragment Processing 52715.1 Fragment Shader Variables . . . . . . . . . . . . . . . . . . . . . 52715.2 Shader Execution . . . . . . . . . . . . . . . . . . . . . . . . . . 529

    15.2.1 Texture Access . . . . . . . . . . . . . . . . . . . . . . . 52915.2.2 Shader Inputs . . . . . . . . . . . . . . . . . . . . . . . . 52915.2.3 Shader Outputs . . . . . . . . . . . . . . . . . . . . . . . 53215.2.4 Early Fragment Tests . . . . . . . . . . . . . . . . . . . . 536

    16 Fixed-Function Fragment Processing 53716.1 Texture Environments and Texture Functions . . . . . . . . . . . 537

    16.1.1 Texture Environment Queries . . . . . . . . . . . . . . . 54316.2 Texture Application . . . . . . . . . . . . . . . . . . . . . . . . . 54316.3 Color Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54616.4 Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546

    17 Writing Fragments and Samples to the Framebuffer 54917.1 Antialiasing Application . . . . . . . . . . . . . . . . . . . . . . 54917.2 Multisample Point Fade . . . . . . . . . . . . . . . . . . . . . . . 55017.3 Per-Fragment Operations . . . . . . . . . . . . . . . . . . . . . . 550

    17.3.1 Pixel Ownership Test . . . . . . . . . . . . . . . . . . . . 55117.3.2 Scissor Test . . . . . . . . . . . . . . . . . . . . . . . . . 55117.3.3 Multisample Fragment Operations . . . . . . . . . . . . . 55317.3.4 Alpha Test . . . . . . . . . . . . . . . . . . . . . . . . . 55517.3.5 Stencil Test . . . . . . . . . . . . . . . . . . . . . . . . . 55617.3.6 Depth Buffer Test . . . . . . . . . . . . . . . . . . . . . . 55717.3.7 Occlusion Queries . . . . . . . . . . . . . . . . . . . . . 55817.3.8 Blending . . . . . . . . . . . . . . . . . . . . . . . . . . 55917.3.9 sRGB Conversion . . . . . . . . . . . . . . . . . . . . . 56617.3.10 Dithering . . . . . . . . . . . . . . . . . . . . . . . . . . 56617.3.11 Logical Operation . . . . . . . . . . . . . . . . . . . . . 56717.3.12 Additional Multisample Fragment Operations . . . . . . . 569

    17.4 Whole Framebuffer Operations . . . . . . . . . . . . . . . . . . . 57017.4.1 Selecting Buffers for Writing . . . . . . . . . . . . . . . . 57017.4.2 Fine Control of Buffer Updates . . . . . . . . . . . . . . 57417.4.3 Clearing the Buffers . . . . . . . . . . . . . . . . . . . . 57617.4.4 Invalidating Framebuffer Contents . . . . . . . . . . . . . 58017.4.5 The Accumulation Buffer . . . . . . . . . . . . . . . . . 581

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS x

    18 Drawing, Reading, and Copying Pixels 58318.1 Drawing Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . 583

    18.1.1 Final Conversion . . . . . . . . . . . . . . . . . . . . . . 58418.1.2 Conversion to Fragments . . . . . . . . . . . . . . . . . . 58518.1.3 Pixel Rectangle Multisample Rasterization . . . . . . . . 58618.1.4 Writing to the Stencil or Depth/Stencil Buffers . . . . . . 586

    18.2 Reading Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . 58718.2.1 Selecting Buffers for Reading . . . . . . . . . . . . . . . 58718.2.2 ReadPixels . . . . . . . . . . . . . . . . . . . . . . . . . 58918.2.3 Obtaining Pixels from the Framebuffer . . . . . . . . . . 59018.2.4 Conversion of RGBA values . . . . . . . . . . . . . . . . 59218.2.5 Conversion of Depth values . . . . . . . . . . . . . . . . 59218.2.6 Pixel Transfer Operations . . . . . . . . . . . . . . . . . 59218.2.7 Conversion to L . . . . . . . . . . . . . . . . . . . . . . . 59218.2.8 Final Conversion . . . . . . . . . . . . . . . . . . . . . . 59318.2.9 Placement in Pixel Pack Buffer or Client Memory . . . . . 594

    18.3 Copying Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . 59418.3.1 Copying Pixel Rectangles . . . . . . . . . . . . . . . . . 59618.3.2 Blitting Pixel Rectangles . . . . . . . . . . . . . . . . . . 59918.3.3 Copying Between Images . . . . . . . . . . . . . . . . . 602

    18.4 Pixel Draw and Read State . . . . . . . . . . . . . . . . . . . . . 605

    19 Compute Shaders 60619.1 Compute Shader Variables . . . . . . . . . . . . . . . . . . . . . 608

    20 Debug Output 60920.1 Debug Messages . . . . . . . . . . . . . . . . . . . . . . . . . . 61020.2 Debug Message Callback . . . . . . . . . . . . . . . . . . . . . . 61220.3 Debug Message Log . . . . . . . . . . . . . . . . . . . . . . . . 61320.4 Controlling Debug Messages . . . . . . . . . . . . . . . . . . . . 61320.5 Externally Generated Messages . . . . . . . . . . . . . . . . . . . 61520.6 Debug Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61520.7 Debug Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61720.8 Asynchronous and Synchronous Debug Output . . . . . . . . . . 61820.9 Debug Output Queries . . . . . . . . . . . . . . . . . . . . . . . 619

    21 Special Functions 62221.1 Evaluators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622

    21.1.1 Evaluator Queries . . . . . . . . . . . . . . . . . . . . . . 62921.2 Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS xi

    21.3 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63221.4 Display Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635

    21.4.1 Commands Not Usable In Display Lists . . . . . . . . . . 63921.5 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64121.6 Saving and Restoring State . . . . . . . . . . . . . . . . . . . . . 642

    22 Context State Queries 64622.1 Simple Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . 64622.2 Pointer andString Queries . . . . . . . . . . . . . . . . . . . . . . 64822.3 Internal Format Queries . . . . . . . . . . . . . . . . . . . . . . . 651

    22.3.1 Supported Operation Queries . . . . . . . . . . . . . . . . 65222.3.2 Other Internal Format Queries . . . . . . . . . . . . . . . 655

    23 State Tables 662

    A Invariance 751A.1 Repeatability . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751A.2 Multi-pass Algorithms . . . . . . . . . . . . . . . . . . . . . . . 752A.3 Invariance Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 752A.4 Tessellation Invariance . . . . . . . . . . . . . . . . . . . . . . . 755A.5 Atomic Counter Invariance . . . . . . . . . . . . . . . . . . . . . 757A.6 What All This Means . . . . . . . . . . . . . . . . . . . . . . . . 757

    B Corollaries 759

    C Compressed Texture Image Formats 762C.1 RGTC Compressed Texture Image Formats . . . . . . . . . . . . 762

    C.1.1 Format COMPRESSED_RED_RGTC1 . . . . . . . . . . . . 763C.1.2 Format COMPRESSED_SIGNED_RED_RGTC1 . . . . . . . 764C.1.3 Format COMPRESSED_RG_RGTC2 . . . . . . . . . . . . . 765C.1.4 Format COMPRESSED_SIGNED_RG_RGTC2 . . . . . . . . 765

    C.2 BPTC Compressed Texture Image Formats . . . . . . . . . . . . 765C.2.1 Formats COMPRESSED_RGBA_BPTC_UNORM and

    COMPRESSED_SRGB_ALPHA_BPTC_UNORM . . . . . . . . 766C.2.2 Formats COMPRESSED_RGB_BPTC_SIGNED_FLOAT and

    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT . . . . . . 768C.3 ETC Compressed Texture Image Formats . . . . . . . . . . . . . 774

    C.3.1 Format COMPRESSED_RGB8_ETC2 . . . . . . . . . . . . 779C.3.2 Format COMPRESSED_SRGB8_ETC2 . . . . . . . . . . . . 786C.3.3 Format COMPRESSED_RGBA8_ETC2_EAC . . . . . . . . . 786

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS xii

    C.3.4 Format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC . . . . 789C.3.5 Format COMPRESSED_R11_EAC . . . . . . . . . . . . . . 789C.3.6 Format COMPRESSED_RG11_EAC . . . . . . . . . . . . . 792C.3.7 Format COMPRESSED_SIGNED_R11_EAC . . . . . . . . . 793C.3.8 Format COMPRESSED_SIGNED_RG11_EAC . . . . . . . . 796C.3.9 Format

    COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 . . 796C.3.10 Format

    COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 . 803

    D Profiles and the Deprecation Model 804D.1 Core and Compatibility Profiles . . . . . . . . . . . . . . . . . . 805D.2 Deprecated and Removed Features . . . . . . . . . . . . . . . . . 805

    D.2.1 Deprecated But Still Supported Features . . . . . . . . . . 805D.2.2 Removed Features . . . . . . . . . . . . . . . . . . . . . 806

    E Version 4.2 811E.1 New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811E.2 Deprecation Model . . . . . . . . . . . . . . . . . . . . . . . . . 812E.3 Changed Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . 812E.4 Change Log for Released Specifications . . . . . . . . . . . . . . 813E.5 Credits and Acknowledgements . . . . . . . . . . . . . . . . . . 815

    F Version 4.3 818F.1 Restructuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818F.2 New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819F.3 Deprecation Model . . . . . . . . . . . . . . . . . . . . . . . . . 820F.4 Changed Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . 820F.5 Change Log for Released Specifications . . . . . . . . . . . . . . 821F.6 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828F.7 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . 830

    G Version 4.4 831G.1 New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831G.2 Deprecation Model . . . . . . . . . . . . . . . . . . . . . . . . . 832G.3 Change Log for Released Specifications . . . . . . . . . . . . . . 832G.4 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843G.5 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . 844

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • CONTENTS xiii

    H OpenGL Registry, Header Files, and ARB Extensions 846H.1 OpenGL Registry . . . . . . . . . . . . . . . . . . . . . . . . . . 846H.2 Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 846H.3 ARB and Khronos Extensions . . . . . . . . . . . . . . . . . . . 847

    H.3.1 Naming Conventions . . . . . . . . . . . . . . . . . . . . 848H.3.2 Promoting Extensions to Core Features . . . . . . . . . . 848H.3.3 Extension Summaries . . . . . . . . . . . . . . . . . . . 848H.3.4 Bindless Textures . . . . . . . . . . . . . . . . . . . . . . 872H.3.5 Compute Variable Group Size . . . . . . . . . . . . . . . 872H.3.6 Indirect Parameters . . . . . . . . . . . . . . . . . . . . . 872H.3.7 Seamless Cubemap per Texture . . . . . . . . . . . . . . 872H.3.8 Shader Draw Parameters . . . . . . . . . . . . . . . . . . 872H.3.9 Shader Group Vote . . . . . . . . . . . . . . . . . . . . . 872H.3.10 Sparse Textures . . . . . . . . . . . . . . . . . . . . . . . 873

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • List of Figures

    3.1 Block diagram of the GL pipeline. . . . . . . . . . . . . . . . . . 32

    8.1 Transfer of pixel rectangles. . . . . . . . . . . . . . . . . . . . . 1928.2 Selecting a subimage from an image . . . . . . . . . . . . . . . . 1978.3 A texture image and the coordinates used to access it. . . . . . . . 2308.4 Example of the components returned for textureGather. . . . . 267

    10.1 Vertex processing and primitive assembly. . . . . . . . . . . . . . 33710.2 Creation of a processed vertex from a transformed vertex and cur-

    rent values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33910.3 Primitive assembly and processing. . . . . . . . . . . . . . . . . . 33910.4 Triangle strips, fans, and independent triangles. . . . . . . . . . . 34310.5 Quadrilateral strips and independent quadrilaterals. . . . . . . . . 34410.6 Lines with adjacency. . . . . . . . . . . . . . . . . . . . . . . . . 34510.7 Triangles with adjacency. . . . . . . . . . . . . . . . . . . . . . . 34610.8 Triangle strips with adjacency. . . . . . . . . . . . . . . . . . . . 347

    11.1 Domain parameterization for tessellation. . . . . . . . . . . . . . 42411.2 Inner triangle tessellation. . . . . . . . . . . . . . . . . . . . . . . 42811.3 Inner quad tessellation. . . . . . . . . . . . . . . . . . . . . . . . 43011.4 Isoline tessellation. . . . . . . . . . . . . . . . . . . . . . . . . . 432

    12.1 Vertex transformation sequence. . . . . . . . . . . . . . . . . . . 44812.2 Processing of RGBA colors. . . . . . . . . . . . . . . . . . . . . 45912.3 Processing of color indices. . . . . . . . . . . . . . . . . . . . . . 45912.4 ColorMaterial operation. . . . . . . . . . . . . . . . . . . . . . . 468

    14.1 Rasterization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49314.2 Rasterization of non-antialiased wide points. . . . . . . . . . . . . 50214.3 Rasterization of antialiased wide points. . . . . . . . . . . . . . . 502

    xiv

  • LIST OF FIGURES xv

    14.4 Visualization of Bresenham’s algorithm. . . . . . . . . . . . . . . 50814.5 Rasterization of non-antialiased wide lines. . . . . . . . . . . . . 51114.6 The region used in rasterizing an antialiased line segment. . . . . 51214.7 Current raster position. . . . . . . . . . . . . . . . . . . . . . . . 52214.8 A bitmap and its associated parameters. . . . . . . . . . . . . . . 524

    16.1 Multitexture pipeline. . . . . . . . . . . . . . . . . . . . . . . . . 545

    17.1 Per-fragment operations. . . . . . . . . . . . . . . . . . . . . . . 550

    18.1 Operation of ReadPixels. . . . . . . . . . . . . . . . . . . . . . . 58718.2 Operation of CopyPixels. . . . . . . . . . . . . . . . . . . . . . . 596

    21.1 Map Evaluation. . . . . . . . . . . . . . . . . . . . . . . . . . . . 62421.2 Feedback syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . 636

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • List of Tables

    2.1 GL command suffixes . . . . . . . . . . . . . . . . . . . . . . . . 122.2 GL data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.3 Summary of GL errors . . . . . . . . . . . . . . . . . . . . . . . 17

    4.1 Initial properties of a sync object created with FenceSync. . . . . 35

    6.1 Buffer object binding targets. . . . . . . . . . . . . . . . . . . . . 566.2 Buffer object parameters and their values. . . . . . . . . . . . . . 566.3 Buffer object state. . . . . . . . . . . . . . . . . . . . . . . . . . 626.4 Buffer object state set by MapBufferRange. . . . . . . . . . . . 696.5 Indexed buffer object limits and binding queries . . . . . . . . . . 76

    7.1 CreateShader type values and the corresponding shader stages. . 807.2 GetProgramResourceiv properties and supported interfaces . . . 1007.3 OpenGL Shading Language type tokens . . . . . . . . . . . . . . 1077.4 Query targets for default uniform block storage, in components. . 1197.5 Query targets for combined uniform block storage, in components. 1207.6 GetProgramResourceiv properties used by GetActiveUniformsiv. 1237.7 GetProgramResourceiv properties used by GetActiveUniform-

    Blockiv. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1247.8 GetProgramResourceiv properties used by GetActiveAtomic-

    CounterBufferiv. . . . . . . . . . . . . . . . . . . . . . . . . . . 1257.9 Interfaces for active subroutines . . . . . . . . . . . . . . . . . . 1387.10 Interfaces for active subroutine uniforms . . . . . . . . . . . . . . 138

    8.1 PixelStore* parameters. . . . . . . . . . . . . . . . . . . . . . . 1728.2 PixelTransfer parameters. . . . . . . . . . . . . . . . . . . . . . 1748.3 PixelMap parameters. . . . . . . . . . . . . . . . . . . . . . . . 1758.4 Color table names. . . . . . . . . . . . . . . . . . . . . . . . . . 1778.5 Pixel data formats accepted for the imaging queries. . . . . . . . . 181

    xvi

  • LIST OF TABLES xvii

    8.6 Pixel data types accepted for the imaging queries. . . . . . . . . . 1828.7 Pixel data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1948.8 Pixel data formats. . . . . . . . . . . . . . . . . . . . . . . . . . 1958.9 Swap Bytes bit ordering. . . . . . . . . . . . . . . . . . . . . . . 1968.10 Packed pixel formats. . . . . . . . . . . . . . . . . . . . . . . . . 1998.11 UNSIGNED_BYTE formats. Bit numbers are indicated for each

    component. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2008.12 UNSIGNED_SHORT formats . . . . . . . . . . . . . . . . . . . . . 2018.13 UNSIGNED_INT formats . . . . . . . . . . . . . . . . . . . . . . 2028.14 FLOAT_UNSIGNED_INT formats . . . . . . . . . . . . . . . . . . 2038.15 Packed pixel field assignments. . . . . . . . . . . . . . . . . . . . 2048.16 Color table lookup. . . . . . . . . . . . . . . . . . . . . . . . . . 2088.17 Computation of filtered color components. . . . . . . . . . . . . . 2098.18 Conversion from RGBA, depth, and stencil pixel components to

    internal texture, table, or filter components. . . . . . . . . . . . . 2178.19 Sized internal color formats. . . . . . . . . . . . . . . . . . . . . 2228.20 Sized internal luminance and intensity formats. . . . . . . . . . . 2238.21 Sized internal depth and stencil formats. . . . . . . . . . . . . . . 2248.22 Generic and specific compressed internal formats. . . . . . . . . . 2258.23 Internal formats for buffer textures . . . . . . . . . . . . . . . . . 2498.24 Texture parameters and their values. . . . . . . . . . . . . . . . . 2528.25 Texture, table, and filter return values. . . . . . . . . . . . . . . . 2598.26 Selection of cube map images. . . . . . . . . . . . . . . . . . . . 2608.27 Texel location wrap mode application. . . . . . . . . . . . . . . . 2668.28 Legal texture targets for TextureView. . . . . . . . . . . . . . . . 2778.29 Compatible internal formats for TextureView . . . . . . . . . . . 2788.30 Depth texture comparison functions. . . . . . . . . . . . . . . . . 2928.31 sRGB texture internal formats. . . . . . . . . . . . . . . . . . . . 2938.32 Mapping of image load, store, and atomic texel coordinate compo-

    nents to texel numbers. . . . . . . . . . . . . . . . . . . . . . . . 2978.33 Supported image unit formats, with equivalent format layout qual-

    ifiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3008.34 Texel sizes, compatibility classes, and pixel format/type combina-

    tions for each image format. . . . . . . . . . . . . . . . . . . . . 303

    9.1 Framebuffer attachment points. . . . . . . . . . . . . . . . . . . . 3209.2 Layer numbers for cube map texture faces. . . . . . . . . . . . . . 336

    10.1 Triangles generated by triangle strips with adjacency. . . . . . . . 348

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • LIST OF TABLES xviii

    10.2 Vertex array sizes (values per vertex) and data types for genericvertex attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 358

    10.3 Fixed-function vertex array sizes and data types . . . . . . . . . . 36310.4 Packed component layout for non-BGRA formats. . . . . . . . . . 36810.5 Packed component layout for BGRA format. . . . . . . . . . . . . 36810.6 Packed component layout for UNSIGNED_INT_10F_11F_11F_-

    REV format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36810.7 Indirect commands and corresponding indirect buffer targets. . . . 37010.8 Variables that direct the execution of InterleavedArrays. . . . . . 383

    11.1 Generic attribute components accessed by attribute variables. . . . 39511.2 Generic attributes and vector types used by column vectors of ma-

    trix variables bound to generic attribute index i. . . . . . . . . . . 39611.3 Scalar and vector vertex attribute types . . . . . . . . . . . . . . . 396

    12.1 Summary of lighting parameters. . . . . . . . . . . . . . . . . . . 46212.2 Correspondence of lighting parameter symbols to names. . . . . . 466

    13.1 Transform feedback modes . . . . . . . . . . . . . . . . . . . . . 47713.2 Provoking vertex selection. . . . . . . . . . . . . . . . . . . . . . 483

    16.1 Correspondence of filtered texture components to texture basecomponents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539

    16.2 Texture functions REPLACE, MODULATE, and DECAL . . . . . . . . 54016.3 Texture functions BLEND and ADD. . . . . . . . . . . . . . . . . . 54016.4 COMBINE texture functions. . . . . . . . . . . . . . . . . . . . . . 54116.5 Arguments for COMBINE_RGB functions. . . . . . . . . . . . . . . 54216.6 Arguments for COMBINE_ALPHA functions. . . . . . . . . . . . . 542

    17.1 RGB and alpha blend equations. . . . . . . . . . . . . . . . . . . 56217.2 Blending functions. . . . . . . . . . . . . . . . . . . . . . . . . . 56317.3 Logical operations . . . . . . . . . . . . . . . . . . . . . . . . . 56817.4 Buffer selection for the default framebuffer . . . . . . . . . . . . 57117.5 Buffer selection for a framebuffer object . . . . . . . . . . . . . . 57217.6 DrawBuffers buffer selection for the default framebuffer . . . . . 572

    18.1 PixelStore parameters. . . . . . . . . . . . . . . . . . . . . . . . 59018.2 ReadPixels GL data types and reversed component conversion for-

    mulas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59518.3 ReadPixels index masks. . . . . . . . . . . . . . . . . . . . . . . 596

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • LIST OF TABLES xix

    18.4 Effective ReadPixels format for DEPTH_STENCIL CopyPixelsoperation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598

    18.5 Compatible internal formats for copying . . . . . . . . . . . . . . 604

    20.1 Sources of debug output messages . . . . . . . . . . . . . . . . . 61020.2 Types of debug output messages . . . . . . . . . . . . . . . . . . 61120.3 Severity levels of messages . . . . . . . . . . . . . . . . . . . . . 61120.4 Object namespace identifiers . . . . . . . . . . . . . . . . . . . . 617

    21.1 Values specified by the target to Map1. . . . . . . . . . . . . . . 62321.2 Correspondence of feedback type to number of values per vertex. . 63421.3 Hint targets and descriptions . . . . . . . . . . . . . . . . . . . . 64221.4 Attribute groups . . . . . . . . . . . . . . . . . . . . . . . . . . . 644

    22.1 Context profile bits . . . . . . . . . . . . . . . . . . . . . . . . . 64922.2 Internal format targets . . . . . . . . . . . . . . . . . . . . . . . . 651

    23.1 State Variable Types . . . . . . . . . . . . . . . . . . . . . . . . . 66423.2 GL Internal Begin/End state variables (inaccessible) . . . . . . . 66523.3 Current Values and Associated Data . . . . . . . . . . . . . . . . 66623.4 Vertex Array Object State . . . . . . . . . . . . . . . . . . . . . . 66723.5 Vertex Array Object State (cont.) . . . . . . . . . . . . . . . . . . 66823.6 Vertex Array Object State (cont.) . . . . . . . . . . . . . . . . . . 66923.7 Vertex Array Object State (cont.)

    † The ith attribute defaults to a value of i. . . . . . . . . . . . 67023.8 Vertex Array Data (not in Vertex Array objects) . . . . . . . . . . 67123.9 Buffer Object State . . . . . . . . . . . . . . . . . . . . . . . . . 67223.10Transformation state . . . . . . . . . . . . . . . . . . . . . . . . 67323.11Coloring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67423.12Lighting (see also table 12.1 for defaults) . . . . . . . . . . . . . 67523.13Lighting (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . 67623.14Rasterization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67723.15Rasterization (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . 67823.16Multisampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67923.17Textures (state per texture unit) . . . . . . . . . . . . . . . . . . . 68023.18Textures (state per texture unit (cont.) . . . . . . . . . . . . . . . 68123.19Textures (state per texture object) . . . . . . . . . . . . . . . . . . 68223.20Textures (state per texture object) (cont.) . . . . . . . . . . . . . . 68323.21Textures (state per texture image) . . . . . . . . . . . . . . . . . . 68423.22Textures (state per texture image) (cont.) . . . . . . . . . . . . . . 68523.23Textures (state per sampler object) . . . . . . . . . . . . . . . . . 686

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • LIST OF TABLES xx

    23.24Texture Environment and Generation . . . . . . . . . . . . . . . . 68723.25Texture Environment and Generation (cont.) . . . . . . . . . . . . 68823.26Pixel Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 68923.27Pixel Operations (cont.) . . . . . . . . . . . . . . . . . . . . . . . 69023.28Framebuffer Control . . . . . . . . . . . . . . . . . . . . . . . . 69123.29Framebuffer (state per target binding point) . . . . . . . . . . . . 69223.30Framebuffer (state per framebuffer object)

    † This state is queried from the currently bound read framebuffer.69323.31Framebuffer (state per attachment point) . . . . . . . . . . . . . . 69423.32Renderbuffer (state per target and binding point) . . . . . . . . . . 69523.33Renderbuffer (state per renderbuffer object) . . . . . . . . . . . . 69623.34Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69723.35Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69823.36Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69923.37Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70023.38Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70123.39Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70223.40Evaluators (GetMap takes a map name) . . . . . . . . . . . . . . 70323.41Shader Object State . . . . . . . . . . . . . . . . . . . . . . . . . 70423.42Program Pipeline Object State . . . . . . . . . . . . . . . . . . . 70523.43Program Object State . . . . . . . . . . . . . . . . . . . . . . . . 70623.44Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 70723.45Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 70823.46Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 70923.47Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 71023.48Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 71123.49Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 71223.50Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 71323.51Program Interface State . . . . . . . . . . . . . . . . . . . . . . . 71423.52Program Object Resource State . . . . . . . . . . . . . . . . . . . 71523.53Program Object Resource State (cont.) . . . . . . . . . . . . . . . 71623.54Vertex and Geometry Shader State (not part of program objects) . 71723.55Query Object State . . . . . . . . . . . . . . . . . . . . . . . . . 71823.56Image State (state per image unit) . . . . . . . . . . . . . . . . . 71923.57Atomic Counter Buffer Binding State . . . . . . . . . . . . . . . 72023.58Shader Storage Buffer Binding State . . . . . . . . . . . . . . . . 72123.59Transform Feedback State . . . . . . . . . . . . . . . . . . . . . 72223.60Uniform Buffer Binding State . . . . . . . . . . . . . . . . . . . 72323.61Sync (state per sync object) . . . . . . . . . . . . . . . . . . . . . 72423.62Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • LIST OF TABLES xxi

    23.63Compute Dispatch State . . . . . . . . . . . . . . . . . . . . . . 72623.64Implementation Dependent Values . . . . . . . . . . . . . . . . . 72723.65Implementation Dependent Values (cont.) . . . . . . . . . . . . . 72823.66Implementation Dependent Values (cont.) . . . . . . . . . . . . . 72923.67Implementation Dependent Values (cont.) . . . . . . . . . . . . . 73023.68Implementation Dependent Version and Extension Support . . . . 73123.69Implementation Dependent Vertex Shader Limits . . . . . . . . . 73223.70Implementation Dependent Tessellation Shader Limits . . . . . . 73323.71Implementation Dependent Tessellation Shader Limits (cont.) . . 73423.72Implementation Dependent Geometry Shader Limits . . . . . . . 73523.73Implementation Dependent Fragment Shader Limits . . . . . . . . 73623.74Implementation Dependent Compute Shader Limits . . . . . . . . 73723.75Implementation Dependent Aggregate Shader Limits . . . . . . . 73823.76Implementation Dependent Aggregate Shader Limits (cont.) . . . 73923.77Implementation Dependent Aggregate Shader Limits (cont.) . . . 74023.78Implementation Dependent Aggregate Shader Limits (cont.)

    † The minimum value for each stage isMAX_stage_UNIFORM_BLOCKS × MAX_UNIFORM_BLOCK_SIZE/ 4 + MAX_stage_UNIFORM_COMPONENTS . . . . . . . . . . . 741

    23.79Debug Output State† The initial value of DEBUG_OUTPUT is TRUE in a debug con-

    text and FALSE in a non-debug context. . . . . . . . . . . . . . . 74223.80Implementation Dependent Debug Output State . . . . . . . . . . 74323.81Implementation Dependent Values (cont.) . . . . . . . . . . . . . 74423.82Implementation Dependent Values (cont.) . . . . . . . . . . . . . 74523.83Internal Format Dependent Values . . . . . . . . . . . . . . . . . 74623.84Implementation Dependent Transform Feedback Limits . . . . . . 74723.85Framebuffer Dependent Values . . . . . . . . . . . . . . . . . . . 74823.86Framebuffer Dependent Values (cont.) . . . . . . . . . . . . . . . 74923.87Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750

    C.1 Mode-dependent BPTC parameters . . . . . . . . . . . . . . . . . 769C.2 Partition table for 2 subset . . . . . . . . . . . . . . . . . . . . . 770C.3 Partition table for 3 subset . . . . . . . . . . . . . . . . . . . . . 771C.4 Anchor index values for the second subset of two-subset partitioning772C.5 Anchor index values for the second subset of three-subset partitioning772C.6 Anchor index values for the third subset of three-subset partitioning 772C.7 Endpoint and partition parameters for block modes . . . . . . . . 775C.8 Block formats for block modes . . . . . . . . . . . . . . . . . . . 776

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • LIST OF TABLES xxii

    C.9 Pixel layout for a 8 × 8 texture using four COMPRESSED_RGB8_-ETC2 compressed blocks. . . . . . . . . . . . . . . . . . . . . . . 778

    C.10 Pixel layout for an COMPRESSED_RGB8_ETC2 compressed block. 779C.11 Texel Data format for RGB8_ETC2 compressed textures formats . 780C.12 Two 2× 4-pixel subblocks side-by-side. . . . . . . . . . . . . . . 781C.13 Two 4× 2-pixel subblocks on top of each other. . . . . . . . . . . 781C.14 Intensity modifier sets for ‘individual’ and ‘differential’ modes: . . 783C.15 Mapping from pixel index values to modifier values for

    COMPRESSED_RGB8_ETC2 compressed textures . . . . . . . . . . 783C.16 Distance table for ‘T’ and ‘H’ modes. . . . . . . . . . . . . . . . 784C.17 Texel Data format for alpha part of COMPRESSED_RGBA8_ETC2_-

    EAC compressed textures. . . . . . . . . . . . . . . . . . . . . . . 787C.18 Intensity modifier sets for alpha component. . . . . . . . . . . . . 788C.19 Texel Data format for RGB8_PUNCHTHROUGH_ALPHA1_ETC2

    compressed textures formats . . . . . . . . . . . . . . . . . . . . 797C.20 Intensity modifier sets if ‘opaque’ is set and if ‘opaque’ is unset. . 799C.21 Mapping from pixel index values to modifier values for

    COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 compressedtextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 800

    E.1 New token names . . . . . . . . . . . . . . . . . . . . . . . . . . 813

    F.1 New token names . . . . . . . . . . . . . . . . . . . . . . . . . . 821

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • Chapter 1

    Introduction

    This document, referred to as the “OpenGL Specification” or just “Specification”hereafter, describes the OpenGL graphics system: what it is, how it acts, and whatis required to implement it. We assume that the reader has at least a rudimentaryunderstanding of computer graphics. This means familiarity with the essentialsof computer graphics algorithms and terminology as well as with modern GPUs(Graphic Processing Units).

    The canonical version of the Specification is available in the official OpenGLRegistry, located at URL

    http://www.opengl.org/registry/

    1.1 Formatting of the OpenGL Specification

    Starting with version 4.3, the OpenGL Specification has undergone major restruc-turing to focus on programmable shading, and to describe important concepts andobjects in the context of the entire API before describing details of their use in thegraphics pipeline.

    1.1.1 Formatting of the Compatibility Profile

    Material which is present only in the compatibility profile Specification and not inthe core Specification (see appendix D) is typeset in orange, like this paragraph.

    1.1.2 Formatting of Optional Features

    Some features in the Specification are considered optional; an OpenGL implemen-tation may or may not choose to provide them (see section 8.4.2).

    1

    http://www.opengl.org/registry/

  • 1.2. WHAT IS THE OPENGL GRAPHICS SYSTEM? 2

    Portions of the Specification which are optional are so described where theoptional features are first defined (see section 8.4.2). State table entries which areoptional are typeset against a gray background .

    1.2 What is the OpenGL Graphics System?

    OpenGL (for “Open Graphics Library”) is an API (Application Programming Inter-face) to graphics hardware. The API consists of a set of several hundred proceduresand functions that allow a programmer to specify the shader programs, objects, andoperations involved in producing high-quality graphical images, specifically colorimages of three-dimensional objects.

    Most of OpenGL requires that the graphics hardware contain a framebuffer.Many OpenGL calls control drawing geometric objects such as points, lines, andpolygons, but the way that some of this drawing occurs (such as when antialiasingor multisampling is in use) relies on the existence of a framebuffer and its proper-ties. Some commands explicitly manage the framebuffer.

    1.2.1 Programmer’s View of OpenGL

    To the programmer, OpenGL is a set of commands that allow the specification ofshader programs or shaders, data used by shaders, and state controlling aspects ofOpenGL outside the scope of shaders. Typically the data represent geometry in twoor three dimensions and texture images, while the shaders control the geometricprocessing, rasterization of geometry and the lighting and shading of fragmentsgenerated by rasterization, resulting in rendering geometry into the framebuffer.

    A typical program that uses OpenGL begins with calls to open a window intothe framebuffer into which the program will draw. Then, calls are made to allocatean OpenGL context and associate it with the window. Once a context is allocated,OpenGL commands to define shaders, geometry, and textures are made, followedby commands which draw geometry by transferring specified portions of the geom-etry to the shaders. Drawing commands specify simple geometric objects such aspoints, line segments, and polygons, which can be further manipulated by shaders.There are also commands which directly control the framebuffer by reading andwriting pixels.

    1.2.2 Implementor’s View of OpenGL

    To the implementor, OpenGL is a set of commands that control the operation ofthe GPU. Modern GPUs accelerate almost all OpenGL operations, storing dataand framebuffer images in GPU memory and executing shaders in dedicated GPU

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 1.2. WHAT IS THE OPENGL GRAPHICS SYSTEM? 3

    processors. However, OpenGL may be implemented on less capable GPUs, or evenwithout a GPU, by moving some or all operations into the host CPU.

    The implementor’s task is to provide a software library on the CPU whichimplements the OpenGL API, while dividing the work for each OpenGL commandbetween the CPU and the graphics hardware as appropriate for the capabilities ofthe GPU.

    OpenGL contains a considerable amount of information including many typesof objects representing programmable shaders and the data they consume andgenerate, as well as other context state controlling non-programmable aspects ofOpenGL. Most of these objects and state are available to the programmer, who canset, manipulate, and query their values through OpenGL commands. Some of it,however, is derived state visible only by the effect it has on how OpenGL oper-ates. One of the main goals of this Specification is to describe OpenGL objectsand context state explicitly, to elucidate how they change in response to OpenGLcommands, and to indicate what their effects are.

    1.2.3 Our View

    We view OpenGL as a pipeline having some programmable stages and some state-driven fixed-function stages that are invoked by a set of specific drawing opera-tions. This model should engender a specification that satisfies the needs of bothprogrammers and implementors. It does not, however, necessarily provide a modelfor implementation. An implementation must produce results conforming to thoseproduced by the specified methods, but there may be ways to carry out a particularcomputation that are more efficient than the one specified.

    1.2.4 Fixed-function Hardware and the Compatibility Profile

    Older generations of graphics hardware were not programmable using shaders,although they were configurable by setting state controlling specific details of theiroperation. The compatibility profile of OpenGL continues to support the legacyOpenGL commands developed for such fixed-function hardware, although theyare typically implemented by writing shaders which reproduce the operation ofsuch hardware. Fixed-function OpenGL commands and operations are describedas alternative interfaces following descriptions of the corresponding shader stages.

    1.2.5 The Deprecation Model

    Features marked as deprecated in one version of the Specification are expected tobe removed in a future version, allowing applications time to transition away from

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 1.3. RELATED APIS 4

    use of deprecated features. The deprecation model is described in more detail,together with a summary of the commands and state deprecated from this versionof the API, in appendix D.

    1.3 Related APIs

    Other APIs related to OpenGL are described below. Most of the specifications forthese APIs are available on the Khronos Group websites, although some vendor-specific APIs are documented on that vendor’s developer website.

    1.3.1 OpenGL Shading Language

    The OpenGL Specification should be read together with a companion documenttitled The OpenGL Shading Language. The latter document (referred to as theOpenGL Shading Language Specification hereafter) defines the syntax and seman-tics of the programming language used to write shaders (see chapter 7). Descrip-tions of shaders later in this document may include references to concepts andterms (such as shading language variable types) defined in the OpenGL ShadingLanguage Specification.

    OpenGL 4.4 implementations are guaranteed to support version 4.40 of theOpenGL Shading Language. All references to sections of that specification refer tothat version. The latest supported version of the shading language may be queriedas described in section 22.2.

    The compatibility profile of OpenGL 4.4 is also guaranteed to support all pre-vious versions of the OpenGL Shading Language back to version 1.10. The#version strings for all supported versions of the OpenGL Shading Languagemay be queried as described in section 22.2.

    The OpenGL Shading Language Specification is available in the OpenGL Reg-istry.

    1.3.2 OpenGL ES

    OpenGL ES is a royalty-free, cross-platform API for full-function 2D and 3Dgraphics on embedded systems such as mobile phones, game consoles, and ve-hicles. It consists of well-defined subsets of OpenGL. OpenGL ES version 1.1implements a subset of the OpenGL 1.5 fixed-function API, OpenGL ES 2.0 im-plements a subset of the OpenGL 2.0 shader-based API, and OpenGL ES 3.0 imple-ments a subset of OpenGL 3.3. OpenGL ES versions also include some additionalfunctionality taken from later OpenGL versions or specific to OpenGL ES. It is

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 1.3. RELATED APIS 5

    straightforward to port code written for OpenGL ES to corresponding versions ofOpenGL.

    OpenGL and OpenGL ES are developed in parallel within the Khronos Group,which controls both standards.

    OpenGL 4.3 includes functionality initially defined in OpenGL ES 3.0, forincreased compatibility between OpenGL and OpenGL ES implementations.

    The OpenGL ES Specifications are available in the Khronos API Registry atURL

    http://www.khronos.org/registry/

    1.3.3 OpenGL ES Shading Language

    The Specification should also be read together with companion documents titledThe OpenGL ES Shading Language. Both versions 1.00 and 3.00 should be read.These documents define versions of the OpenGL Shading Language designed forimplementations of OpenGL ES 2.0 and 3.0 respectively, but also supported byOpenGL implementations. References to the OpenGL Shading Language Speci-fication hereafter include both OpenGL and OpenGL ES versions of the ShadingLanguage; references to specific sections are to those sections in version 4.40 ofthe OpenGL Shading Language Specification.

    OpenGL 4.4 implementations are guaranteed to support both versions 1.00 and3.00 of the OpenGL ES Shading Language.

    The #version strings for all supported versions of the OpenGL Shading Lan-guage may be queried as described in section 22.2.

    The OpenGL ES Shading Language Specifications are available in the KhronosAPI Registry.

    1.3.4 WebGL

    WebGL is a cross-platform, royalty-free web standard for a low-level 3D graph-ics API based on OpenGL ES 2.0. Developers familiar with OpenGL ES 2.0 willrecognize WebGL as a shader-based API using a form of the OpenGL ShadingLanguage, with constructs that are semantically similar to those of the underly-ing OpenGL ES 2.0 API. It stays very close to the OpenGL ES 2.0 specification,with some concessions made for what developers expect out of memory-managedlanguages such as JavaScript.

    The WebGL Specification and related documentation are available in theKhronos API Registry.

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

    http://www.khronos.org/registry/

  • 1.3. RELATED APIS 6

    1.3.5 Window System Bindings

    OpenGL requires a companion API to create and manage graphics contexts, win-dows to render into, and other resources beyond the scope of this Specification.There are several such APIs supporting different operating and window systems.

    1.3.5.1 GLX - X Window System Bindings

    OpenGL Graphics with the X Window System, referred to as the GLX Specificationhereafter, describes the GLX API for use of OpenGL in the X Window System. It isprimarily directed at Linux and Unix systems, but GLX implementations also existfor Microsoft Windows, MacOS X, and some other platforms where X is available.The GLX Specification is available in the OpenGL Registry.

    1.3.5.2 WGL - Microsoft Windows Bindings

    The WGL API supports use of OpenGL with Microsoft Windows. WGL is docu-mented in Microsoft’s MSDN system, although no full specification exists.

    1.3.5.3 MacOS X Window System Bindings

    Several APIs exist supporting use of OpenGL with Quartz, the MacOS X windowsystem, including CGL, AGL, and NSOpenGLView. These APIs are documentedon Apple’s developer website.

    1.3.5.4 EGL - Mobile and Embedded Device Bindings

    The Khronos Native Platform Graphics Interface or “EGL Specification” describesthe EGL API for use of OpenGL ES on mobile and embedded devices. EGL im-plementations supporting OpenGL may be available on some desktop platforms aswell. The EGL Specification is available in the Khronos API Registry.

    1.3.6 OpenCL

    OpenCL is an open, royalty-free standard for cross-platform, general-purpose par-allel programming of processors found in personal computers, servers, and mobiledevices, including GPUs. OpenCL defines interop methods to share OpenCL mem-ory and image objects with corresponding OpenGL buffer and texture objects, andto coordinate control of and transfer of data between OpenCL and OpenGL. Thisallows applications to split processing of data between OpenCL and OpenGL; forexample, by using OpenCL to implement a physics model and then rendering andinteracting with the resulting dynamic geometry using OpenGL.

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 1.4. FILING BUG REPORTS 7

    The OpenCL Specification is available in the Khronos API Registry.

    1.4 Filing Bug Reports

    Bug reports on the OpenGL and OpenGL Shading Language Specifications can befiled in the Khronos Public Bugzilla, located at URL

    http://www.khronos.org/bugzilla/Please file bugs against Product: OpenGL, Component: Specification, and the

    appropriate version of the specification. It is best to file bugs against the most re-cently released versions, since older versions are usually not updated for bugfixes.

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

    http://www.khronos.org/bugzilla/

  • Chapter 2

    OpenGL Fundamentals

    This chapter introduces fundamental concepts including the OpenGL executionmodel, API syntax, contexts and threads, numeric representation, context state andstate queries, and the different types of objects and shaders. It provides a frame-work for interpreting more specific descriptions of commands and behavior in theremainder of the Specification.

    2.1 Execution Model

    OpenGL (henceforth, “the GL”) is concerned only with processing data in GPUmemory, including rendering into a framebuffer and reading values stored in thatframebuffer. There is no support for other input or output devices. Programmersmust rely on other mechanisms to obtain user input.

    The GL draws primitives processed by a variety of shader programs and fixed-function processing units controlled by context state. Each primitive is a point,line segment, patch, pixel rectangle, or polygon. Context state may be changedindependently; the setting of one piece of state does not affect the settings of others(although state and shader all interact to determine what eventually ends up in theframebuffer). State is set, primitives drawn, and other GL operations described bysending commands in the form of function or procedure calls.

    Primitives are defined by a group of one or more vertices. A vertex definesa point, an endpoint of a line segment, or a corner of a polygon where two edgesmeet. Data such as positional coordinates, colors, normals, texture coordinates, etc.are associated with a vertex and each vertex is processed independently, in order,and in the same way. The only exception to this rule is if the group of verticesmust be clipped so that the indicated primitive fits within a specified region; in thiscase vertex data may be modified and new vertices created. The type of clipping

    8

  • 2.1. EXECUTION MODEL 9

    depends on which primitive the group of vertices represents.Commands are always processed in the order in which they are received, al-

    though there may be an indeterminate delay before the effects of a command arerealized. This means, for example, that one primitive must be drawn completelybefore any subsequent one can affect the framebuffer. It also means that queriesand pixel read operations return state consistent with complete execution of allpreviously invoked GL commands, except where explicitly specified otherwise. Ingeneral, the effects of a GL command on either GL state or the framebuffer mustbe complete before any subsequent command can have any such effects.

    Data binding occurs on call. This means that data passed to a GL commandare interpreted when that command is received. Even if the command requires apointer to data, those data are interpreted when the call is made, and any subsequentchanges to the data have no effect on the GL (unless the same pointer is used in asubsequent command).

    The GL provides direct control over the fundamental operations of 3D and 2Dgraphics. This includes specification of parameters of application-defined shaderprograms performing transformation, lighting, texturing, and shading operations,as well as built-in functionality such as antialiasing and texture filtering. It does notprovide a means for describing or modeling complex geometric objects, althoughshaders can be written to generate such objects. In other words, OpenGL providesmechanisms to describe how complex geometric objects are to be rendered, ratherthan mechanisms to describe the complex objects themselves.

    The model for interpretation of GL commands is client-server. That is, a pro-gram (the client) issues commands, and these commands are interpreted and pro-cessed by the GL (the server). The server may or may not operate on the samecomputer or in the same address space as the client. In this sense, the GL is net-work transparent. A server may maintain a number of GL contexts, each of whichis an encapsulation of current GL state and objects. A client may choose to bemade current to any one of these contexts.

    Issuing GL commands when a program is not current to a context results inundefined behavior.

    There are two classes of framebuffers: a window system-provided framebufferassociated with a context when the context is made current, and application-createdframebuffers. The window system-provided framebuffer is referred to as the de-fault framebuffer. Application-created framebuffers, referred to as framebuffer ob-jects, may be created as desired, A context may be associated with two frame-buffers, one for each of reading and drawing operations. The default framebufferand framebuffer objects are distinguished primarily by the interfaces for configur-ing and managing their state.

    The effects of GL commands on the default framebuffer are ultimately con-

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 2.2. COMMAND SYNTAX 10

    trolled by the window system, which allocates framebuffer resources, determineswhich portions of the default framebuffer the GL may access at any given time, andcommunicates to the GL how those portions are structured. Therefore, there areno GL commands to initialize a GL context or configure the default framebuffer.Similarly, display of framebuffer contents on a physical display device (includingthe transformation of individual framebuffer values by such techniques as gammacorrection) is not addressed by the GL.

    Allocation and configuration of the default framebuffer occurs outside of theGL in conjunction with the window system, using companion APIs described insection 1.3.5.

    Allocation and initialization of GL contexts is also done using these companionAPIs. GL contexts can be associated with different default framebuffers, and somecontext state is determined at the time this association is performed.

    It is possible to use a GL context without a default framebuffer, in which casea framebuffer object must be used to perform all rendering. This is useful forapplications needing to perform offscreen rendering.

    OpenGL is designed to be run on a range of platforms with varying capabilities,memory, and performance. To accommodate this variety, we specify ideal behaviorinstead of actual behavior for certain GL operations. In cases where deviation fromthe ideal is allowed, we also specify the rules that an implementation must obeyif it is to approximate the ideal behavior usefully. This allowed variation in GLbehavior implies that two distinct GL implementations may not agree pixel forpixel when presented with the same input, even when run on identical framebufferconfigurations.

    Finally, command names, constants, and types are prefixed in the C languagebinding to OpenGL (by gl, GL_, and GL, respectively), to reduce name clashes withother packages. The prefixes are omitted in this document for clarity.

    2.2 Command Syntax

    The Specification describes OpenGL commands as functions or procedures usingANSI C syntax. Languages such as C++ and Javascript which allow passingof argument type information permit language bindings with simpler declarationsand fewer entry points.

    Various groups of GL commands perform the same operation but differ in howarguments are supplied to them. To conveniently accommodate this variation, weadopt a notation for describing commands and their arguments.

    GL commands are formed from a name which may be followed, depending onthe particular command, by a sequence of characters describing a parameter to the

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 2.2. COMMAND SYNTAX 11

    command. If present, a digit indicates the required length (number of values) of theindicated type. Next, a string of characters making up one of the type descriptorsfrom table 2.1 indicates the specific size and data type of parameter values. Afinal v character, if present, indicates that the command takes a pointer to an array(a vector) of values rather than a series of individual arguments. Two specificexamples are:

    void Uniform4f( int location, float v0, float v1,float v2, float v3 );

    and

    void GetFloatv( enum pname, float *data );

    In general, a command declaration has the form

    rtype Name{�1234}{� b s i i64 f d ub us ui ui64}{�v}( [args ,] T arg1, . . ., T argN [, args] );

    rtype is the return type of the function. The braces ({}) enclose a series of typedescriptors (see table 2.1), of which one is selected. � indicates no type descriptor.The arguments enclosed in brackets ([args ,] and [, args]) may or may not bepresent. The N arguments arg1 through argN have type T, which corresponds toone of the type descriptors indicated in table 2.1 (if there are no letters, then thearguments’ type is given explicitly). If the final character is not v, then N is givenby the digit 1, 2, 3, or 4 (if there is no digit, then the number of arguments is fixed).If the final character is v, then only arg1 is present and it is an array of N values ofthe indicated type.

    For example,

    void Uniform{1234}{if}( int location, T value );

    indicates the eight declarations

    void Uniform1i( int location, int value );void Uniform1f( int location, float value );void Uniform2i( int location, int v0, int v1 );void Uniform2f( int location, float v0, float v1 );void Uniform3i( int location, int v0, int v1, int v2 );void Uniform3f( int location, float v0, float v1,

    float v3 );

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 2.2. COMMAND SYNTAX 12

    Type Descriptor Corresponding GL Typeb bytes shorti int

    i64 int64f floatd double

    ub ubyteus ushortui uint

    ui64 uint64

    Table 2.1: Correspondence of command suffix type descriptors to GL argumenttypes. Refer to table 2.2 for definitions of the GL types.

    void Uniform4i( int location, int v0, int v1, int v2,int v3 );

    void Uniform4f( int location, float v0, float v1,float v2, float v3 );

    Arguments whose type is fixed (i.e. not indicated by a suffix on the command)are of one of the GL data types summarized in table 2.2, or pointers to one of thesetypes. Since many GL operations represent bitfields within these types, transferblocks of data in these types to graphics hardware which uses the same data types,or otherwise requires these sizes, it is not possible to implement the GL API on anarchitecture which cannot satisfy the exact bit width requirements in table 2.2.

    The types clampf and clampd are no longer used, replaced by floatand double respectively together with specification language requiring param-eter clamping1.

    2.2.1 Data Conversion For State-Setting Commands

    Many GL commands specify a value or values to which GL state of a specific type(boolean, enum, integer, or floating-point) is to be set. When multiple versions ofsuch a command exist, using the type descriptor syntax described above, any suchversion may be used to set the state value. When state values are specified using

    1 These changes are backwards-compatible at the compilation and linking levels, and are beingpropagated to man pages and header files as well.

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 2.2. COMMAND SYNTAX 13

    GL Type DescriptionBit Width

    boolean 1 or more Booleanbyte 8 Signed two’s complement binary inte-

    gerubyte 8 Unsigned binary integerchar 8 Characters making up stringsshort 16 Signed two’s complement binary inte-

    gerushort 16 Unsigned binary integerint 32 Signed two’s complement binary inte-

    geruint 32 Unsigned binary integerfixed 32 Signed two’s complement 16.16

    scaled integerint64 64 Signed two’s complement binary inte-

    geruint64 64 Unsigned binary integersizei 32 Non-negative binary integer sizeenum 32 Enumerated binary integer valueintptr ptrbits Signed twos complement binary inte-

    gersizeiptr ptrbits Non-negative binary integer sizesync ptrbits Sync object handle (see section 4.1)bitfield 32 Bit fieldhalf 16 Half-precision floating-point value

    encoded in an unsigned scalarfloat 32 Floating-point valueclampf 32 Floating-point value clamped to [0, 1]double 64 Floating-point valueclampd 64 Floating-point value clamped to [0, 1]

    Table 2.2: GL data types. GL types are not C types. Thus, for example, GLtype int is referred to as GLint outside this document, and is not necessarilyequivalent to the C type int. An implementation must use exactly the number ofbits indicated in the table to represent a GL type.ptrbits is the number of bits required to represent a pointer type; in other words,types intptr, sizeiptr, and sync must be large enough to store any CPU ad-dress. sync is defined as an anonymous struct pointer in the C language bindingswhile intptr and sizeiptr are defined as integer types large enough to holda pointer.

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 2.2. COMMAND SYNTAX 14

    a different parameter type than the actual type of that state, data conversions areperformed as follows:

    • When the type of internal state is boolean, zero integer or floating-point val-ues are converted to FALSE and non-zero values are converted to TRUE.

    • When the type of internal state is integer or enum, boolean values of FALSEand TRUE are converted to 0 and 1, respectively. Floating-point values arerounded to the nearest integer. If the resulting value is so large in magnitudethat it cannot be represented by the internal state variable, the internal statevalue is undefined.

    • When the type of internal state is floating-point, boolean values of FALSEand TRUE are converted to 0.0 and 1.0, respectively. Integer values are con-verted to floating-point, with or without normalization as described for spe-cific commands.

    For commands taking arrays of the specified type, these conversions are per-formed for each element of the passed array.

    Each command following these conversion rules refers back to this section.Some commands have additional conversion rules specific to certain state valuesand data types, which are described following the reference.

    Validation of values performed by state-setting commands is performed afterconversion, unless specified otherwise for a specific command.

    2.2.2 Data Conversions For State Query Commands

    Query commands (commands whose name begins with Get) return a value or val-ues to which GL state has been set. Some of these commands exist in multipleversions returning different data types. When a query command is issued that re-turns data types different from the actual type of that state, data conversions areperformed as follows:

    • If a command returning boolean data is called, such as GetBooleanv, afloating-point or integer value converts to FALSE if and only if it is zero.Otherwise it converts to TRUE.

    • If a command returning integer data is called, such as GetIntegerv or Get-Integer64v, a boolean value of TRUE or FALSE is interpreted as one or zero,respectively. A floating-point value is rounded to the nearest integer, unlessthe value is an RGBA color component, a normal coordinate, a DepthRange

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 2.3. COMMAND EXECUTION 15

    value, or a depth buffer clear value. In these cases, the query command con-verts the floating-point value to an integer according to the INT entry oftable 18.2; a value not in [−1, 1] converts to an undefined value.

    • If a command returning floating-point data is called, such as GetFloatv orGetDoublev, a boolean value of TRUE or FALSE is interpreted as 1.0 or0.0, respectively. An integer value is coerced to floating-point. Single- anddouble-precision floating-point values are converted as necessary.

    If a value is so large in magnitude that it cannot be represented by the returneddata type, then the nearest value representable using the requested type is returned.

    When querying bitmasks (such as SAMPLE_MASK_VALUE or STENCIL_-WRITEMASK) with GetIntegerv, the mask value is treated as a signed integer, sothat mask values with the high bit set will not be clamped when returned as signedintegers.

    Unless otherwise indicated, multi-valued state variables return their multiplevalues in the same order as they are given as arguments to the commands that setthem. For instance, the two DepthRange parameters are returned in the order nfollowed by f. Similarly, points for evaluator maps are returned in the order thatthey appeared when passed to Map1. Map2 returns Rij in the [(uorder)i + j]thblock of values (see page 624 for i, j, uorder, and Rij).

    2.3 Command Execution

    Most of the Specification discusses the behavior of a single context bound to asingle CPU thread. It is also possible for multiple contexts to share GL objectsand for each such context to be bound to a different thread. This section introducesconcepts related to GL command execution including error reporting, commandqueue flushing, and synchronization between command streams. Using these toolscan increase performance and utilization of the GPU by separating loosely relatedtasks into different contexts.

    Methods to create, manage, and destroy CPU threads are defined by the hostCPU operating system and are not described in the Specification. Binding of GLcontexts to CPU threads is controlled through a window system binding layer suchas those described in section 1.3.5.

    2.3.1 Errors

    The GL detects only a subset of those conditions that could be considered errors.This is because in many cases error checking would adversely impact the perfor-mance of an error-free program.

    OpenGL 4.4 (Compatibility Profile) - March 19, 2014

  • 2.3. COMMAND EXECUTION 16

    The command

    enum GetError( void );

    is used to obtain error information. Each detectable error is assigned a numericcode. When an error is detected, a flag is set and the code is recorded. Furthererrors, if they occur, do not affect this recorded code. When GetError is called,the code is returned and the flag is cleared, so that a further error will again recordits code. If a call to GetError returns NO_ERROR, then there has been no detectableerror since the last call to GetError (or since the GL was initialized).

    To allow for distributed implementations, there may be several flag-code pairs.In this case, after a call to GetError returns a value other than NO_ERROR eachsubsequent call returns the non-zero code of a distinct flag-code pair (in unspecifiedorder), until all non-NO_ERROR codes have been returned. When there are no morenon-NO_ERROR error codes, all flags are reset. This scheme requires some positivenumber of pairs of a flag bit and an integer. The initial state of all flags is clearedand the initial value of all codes is NO_ERROR.

    Table 2.3 summarizes GL errors. Currently, when an error flag is set, resultsof GL operation are undefined only if an OUT_OF_MEMORY error has occurred. Inother cases, there are no side effects unless otherwise noted; the command whichgenerates the error is ignored so that it has no effect on GL state or framebuffercontents. Except as otherwise noted, if the generating command returns a value, itreturns zero. If the generating command modifies values through a pointer argu-ment, no change is made to these values.