The OpenGL R
Graphics System:
A Specification
(Version 4.4 (Core Profile) - March 19, 2014)
Mark Segal
Kurt Akeley
Editor (v...
Copyright c 2006-2014 The Khronos Group Inc. All Rights Reserved.
This specification is protected by copyright laws and con...
Contents
1 Introduction 1
1.1 Formatting of the OpenGL Specification . . . . . . . . . . . . . . 1
1.1.1 . . . . . . . . . ...
CONTENTS ii
2.4 Rendering Commands . . . . . . . . . . . . . . . . . . . . . . . 24
2.5 Context State . . . . . . . . . . ...
CONTENTS iii
6 Buffer Objects 53
6.1 Creating and Binding Buffer Objects . . . . . . . . . . . . . . . . 54
6.1.1 Binding ...
CONTENTS iv
8 Textures and Samplers 159
8.1 Texture Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
8.2 ...
CONTENTS v
8.18 Texture Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
8.19 Immutable-Format Texture Im...
CONTENTS vi
10 Vertex Specification and Drawing Commands 300
10.1 Primitive Types . . . . . . . . . . . . . . . . . . . . ....
CONTENTS vii
10.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
10.9 . . . . . . . . . . . . ....
CONTENTS viii
14.3.1 Multisampling . . . . . . . . . . . . . . . . . . . . . . . 414
14.4 Points . . . . . . . . . . . . ....
CONTENTS ix
17.3.5 Stencil Test . . . . . . . . . . . . . . . . . . . . . . . . . 450
17.3.6 Depth Buffer Test . . . . . ....
CONTENTS x
20.5 Externally Generated Messages . . . . . . . . . . . . . . . . . . . 500
20.6 Debug Groups . . . . . . . . ...
CONTENTS xi
C.2.1 Formats COMPRESSED_RGBA_BPTC_UNORM and
COMPRESSED_SRGB_ALPHA_BPTC_UNORM . . . . . . . . 613
C.2.2 Format...
CONTENTS xii
G Version 4.4 677
G.1 New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
G.2 Deprecatio...
List of Figures
3.1 Block diagram of the GL pipeline. . . . . . . . . . . . . . . . . . 31
8.1 Transfer of pixel rectangle...
List of Tables
2.1 GL command suffixes . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2 GL data types . . . . . . . ....
LIST OF TABLES xv
8.6 UNSIGNED_BYTE formats. Bit numbers are indicated for each
component. . . . . . . . . . . . . . . . ....
LIST OF TABLES xvi
11.2 Generic attributes and vector types used by column vectors of ma-
trix variables bound to generic ...
LIST OF TABLES xvii
23.9 Rasterization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
23.10Rasterization (con...
LIST OF TABLES xviii
23.48Transform Feedback State . . . . . . . . . . . . . . . . . . . . . 573
23.49Uniform Buffer Bindi...
LIST OF TABLES xix
C.8 Block formats for block modes . . . . . . . . . . . . . . . . . . . 622
C.9 Pixel layout for a 8 × ...
Chapter 1
Introduction
This document, referred to as the “OpenGL Specification” or just “Specification”
hereafter, describes...
1.2. WHAT IS THE OPENGL GRAPHICS SYSTEM? 2
1.2 What is the OpenGL Graphics System?
OpenGL (for “Open Graphics Library”) is...
1.2. WHAT IS THE OPENGL GRAPHICS SYSTEM? 3
between the CPU and the graphics hardware as appropriate for the capabilities o...
1.3. RELATED APIS 4
1.3 Related APIs
Other APIs related to OpenGL are described below. Most of the specifications for
these...
1.3. RELATED APIS 5
straightforward to port code written for OpenGL ES to corresponding versions of
OpenGL.
OpenGL and Ope...
1.3. RELATED APIS 6
1.3.5 Window System Bindings
OpenGL requires a companion API to create and manage graphics contexts, w...
1.4. FILING BUG REPORTS 7
The OpenCL Specification is available in the Khronos API Registry.
1.4 Filing Bug Reports
Bug rep...
Chapter 2
OpenGL Fundamentals
This chapter introduces fundamental concepts including the OpenGL execution
model, API synta...
2.1. EXECUTION MODEL 9
depends on which primitive the group of vertices represents.
Commands are always processed in the o...
2.2. COMMAND SYNTAX 10
trolled by the window system, which allocates framebuffer resources, determines
which portions of t...
2.2. COMMAND SYNTAX 11
command. If present, a digit indicates the required length (number of values) of the
indicated type...
2.2. COMMAND SYNTAX 12
Type Descriptor Corresponding GL Type
b byte
s short
i int
i64 int64
f float
d double
ub ubyte
us u...
2.2. COMMAND SYNTAX 13
GL Type Description
Bit Width
boolean 1 or more Boolean
byte 8 Signed two’s complement binary inte-...
2.2. COMMAND SYNTAX 14
a different parameter type than the actual type of that state, data conversions are
performed as fo...
2.3. COMMAND EXECUTION 15
buffer clear value. In these cases, the query command converts the floating-
point value to an in...
2.3. COMMAND EXECUTION 16
enum GetError( void );
is used to obtain error information. Each detectable error is assigned a ...
2.3. COMMAND EXECUTION 17
Error Description Offending com-
mand ignored?
INVALID_ENUM enum argument out of range Yes
INVAL...
2.3. COMMAND EXECUTION 18
Such error summaries are set in a distinct style, like this sentence.
In some cases, however, er...
2.3. COMMAND EXECUTION 19
per-fragment operations. Range and precision requirements during shader execu-
tion differ and a...
2.3. COMMAND EXECUTION 20
If the floating-point number is interpreted as an unsigned 16-bit integer N, then
S =
N mod 65536...
2.3. COMMAND EXECUTION 21
Any representable unsigned 11-bit floating-point value is legal as input to a
GL command that acc...
2.3. COMMAND EXECUTION 22
2.3.3.5 Fixed-Point Computation
Vertex attributes may be specified using a 32-bit two’s-complemen...
2.3. COMMAND EXECUTION 23
floating-point value f is performed using
f = max
c
2b−1 − 1
, −1.0 . (2.2)
Only the range [−2b−1...
2.4. RENDERING COMMANDS 24
2.4 Rendering Commands
GL commands performing rendering into a framebuffer are sometimes treate...
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
OpenGL Spec 4.4 Core
Upcoming SlideShare
Loading in …5
×

OpenGL Spec 4.4 Core

3,705 views

Published on

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

Published in: Technology, Art & Photos

OpenGL Spec 4.4 Core

  1. 1. The OpenGL R Graphics System: A Specification (Version 4.4 (Core Profile) - March 19, 2014) Mark Segal Kurt Akeley Editor (version 1.1): Chris Frazier Editor (versions 1.2-4.4 ): Jon Leech Editor (version 2.0): Pat Brown
  2. 2. Copyright c 2006-2014 The Khronos Group Inc. All Rights Reserved. This specification is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. It or any components may not be reproduced, repub- lished, distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the express prior written permission of Khronos Group. You may use this specification for implementing the functionality therein, without altering or removing any trademark, copyright or other notice from the specification, but the receipt 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 it may describe, in whole or in part. Khronos Group grants express permission to any current Promoter, Contributor or Adopter member of Khronos to copy and redistribute UNMODIFIED versions of this specification in any fashion, provided that NO CHARGE is made for the specification and the latest available update of the specification for any version of 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 any way. The specification may be incorporated into a product that is sold as long as such product includes significant independent work developed by the seller. A link to the current version of this specification on the Khronos Group web-site should be 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 purpose or non-infringement of any intellectual property. Khronos Group makes no, and expressly disclaims any, warranties, express or implied, regarding the correctness, accuracy, completeness, timeliness, and reliability of the specification. Under no circumstances will the Khronos Group, or any of its Promoters, Contributors or Members 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 in connection 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.
  3. 3. Contents 1 Introduction 1 1.1 Formatting of the OpenGL Specification . . . . . . . . . . . . . . 1 1.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 What is the OpenGL Graphics System? . . . . . . . . . . . . . . 2 1.2.1 Programmer’s View of OpenGL . . . . . . . . . . . . . . 2 1.2.2 Implementor’s View of OpenGL . . . . . . . . . . . . . . 2 1.2.3 Our View . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2.4 Fixed-function Hardware and the Compatibility Profile . . 3 1.2.5 The Deprecation Model . . . . . . . . . . . . . . . . . . 3 1.3 Related APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.1 OpenGL Shading Language . . . . . . . . . . . . . . . . 4 1.3.2 OpenGL ES . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.3 OpenGL ES Shading Language . . . . . . . . . . . . . . 5 1.3.4 WebGL . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3.5 Window System Bindings . . . . . . . . . . . . . . . . . 6 1.3.6 OpenCL . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.4 Filing Bug Reports . . . . . . . . . . . . . . . . . . . . . . . . . 7 2 OpenGL Fundamentals 8 2.1 Execution Model . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2 Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2.1 Data Conversion For State-Setting Commands . . . . . . 12 2.2.2 Data Conversions For State Query Commands . . . . . . 14 2.3 Command Execution . . . . . . . . . . . . . . . . . . . . . . . . 15 2.3.1 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.3.2 Flush and Finish . . . . . . . . . . . . . . . . . . . . . . 18 2.3.3 Numeric Representation and Computation . . . . . . . . . 18 2.3.4 Fixed-Point Data Conversions . . . . . . . . . . . . . . . 22 i
  4. 4. CONTENTS ii 2.4 Rendering Commands . . . . . . . . . . . . . . . . . . . . . . . 24 2.5 Context State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.5.1 Generic Context State Queries . . . . . . . . . . . . . . . 24 2.6 Objects and the Object Model . . . . . . . . . . . . . . . . . . . 25 2.6.1 Object Management . . . . . . . . . . . . . . . . . . . . 25 2.6.2 Buffer Objects . . . . . . . . . . . . . . . . . . . . . . . 26 2.6.3 Shader Objects . . . . . . . . . . . . . . . . . . . . . . . 27 2.6.4 Program Objects . . . . . . . . . . . . . . . . . . . . . . 27 2.6.5 Program Pipeline Objects . . . . . . . . . . . . . . . . . 27 2.6.6 Texture Objects . . . . . . . . . . . . . . . . . . . . . . . 27 2.6.7 Sampler Objects . . . . . . . . . . . . . . . . . . . . . . 28 2.6.8 Renderbuffer Objects . . . . . . . . . . . . . . . . . . . . 28 2.6.9 Framebuffer Objects . . . . . . . . . . . . . . . . . . . . 28 2.6.10 Vertex Array Objects . . . . . . . . . . . . . . . . . . . . 28 2.6.11 Transform Feedback Objects . . . . . . . . . . . . . . . . 29 2.6.12 Query Objects . . . . . . . . . . . . . . . . . . . . . . . 29 2.6.13 Sync Objects . . . . . . . . . . . . . . . . . . . . . . . . 29 2.6.14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3 Dataflow Model 30 4 Event Model 33 4.1 Sync Objects and Fences . . . . . . . . . . . . . . . . . . . . . . 33 4.1.1 Waiting for Sync Objects . . . . . . . . . . . . . . . . . . 35 4.1.2 Signaling . . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.1.3 Sync Object Queries . . . . . . . . . . . . . . . . . . . . 37 4.2 Query Objects and Asynchronous Queries . . . . . . . . . . . . . 38 4.2.1 Query Object Queries . . . . . . . . . . . . . . . . . . . 42 4.3 Time Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 5 Shared Objects and Multiple Contexts 47 5.1 Object Deletion Behavior . . . . . . . . . . . . . . . . . . . . . . 48 5.1.1 Side Effects of Shared Context Destruction . . . . . . . . 48 5.1.2 Automatic Unbinding of Deleted Objects . . . . . . . . . 48 5.1.3 Deleted Object and Object Name Lifetimes . . . . . . . . 48 5.2 Sync Objects and Multiple Contexts . . . . . . . . . . . . . . . . 49 5.3 Propagating Changes to Objects . . . . . . . . . . . . . . . . . . 49 5.3.1 Determining Completion of Changes to an object . . . . . 50 5.3.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 51 5.3.3 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 OpenGL 4.4 (Core Profile) - March 19, 2014
  5. 5. CONTENTS iii 6 Buffer Objects 53 6.1 Creating and Binding Buffer Objects . . . . . . . . . . . . . . . . 54 6.1.1 Binding Buffer Objects to Indexed Targets . . . . . . . . . 56 6.2 Creating and Modifying Buffer Object Data Stores . . . . . . . . 59 6.2.1 Clearing Buffer Object Data Stores . . . . . . . . . . . . 64 6.3 Mapping and Unmapping Buffer Data . . . . . . . . . . . . . . . 65 6.3.1 Unmapping Buffers . . . . . . . . . . . . . . . . . . . . . 70 6.3.2 Effects of Mapping Buffers on Other GL Commands . . . 70 6.4 Effects of Accessing Outside Buffer Bounds . . . . . . . . . . . . 71 6.5 Invalidating Buffer Data . . . . . . . . . . . . . . . . . . . . . . 71 6.6 Copying Between Buffers . . . . . . . . . . . . . . . . . . . . . . 72 6.7 Buffer Object Queries . . . . . . . . . . . . . . . . . . . . . . . . 73 6.7.1 Indexed Buffer Object Limits and Binding Queries . . . . 74 6.8 Buffer Object State . . . . . . . . . . . . . . . . . . . . . . . . . 76 7 Programs and Shaders 77 7.1 Shader Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 7.2 Shader Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 7.3 Program Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.3.1 Program Interfaces . . . . . . . . . . . . . . . . . . . . . 89 7.4 Program Pipeline Objects . . . . . . . . . . . . . . . . . . . . . . 108 7.4.1 Shader Interface Matching . . . . . . . . . . . . . . . . . 111 7.4.2 Program Pipeline Object State . . . . . . . . . . . . . . . 114 7.5 Program Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . 114 7.6 Uniform Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 117 7.6.1 Loading Uniform Variables In The Default Uniform Block 124 7.6.2 Uniform Blocks . . . . . . . . . . . . . . . . . . . . . . . 128 7.6.3 Uniform Buffer Object Bindings . . . . . . . . . . . . . . 132 7.7 Atomic Counter Buffers . . . . . . . . . . . . . . . . . . . . . . . 133 7.7.1 Atomic Counter Buffer Object Storage . . . . . . . . . . 133 7.7.2 Atomic Counter Buffer Bindings . . . . . . . . . . . . . . 134 7.8 Shader Buffer Variables and Shader Storage Blocks . . . . . . . . 134 7.9 Subroutine Uniform Variables . . . . . . . . . . . . . . . . . . . 136 7.10 Samplers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 7.11 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 7.12 Shader Memory Access . . . . . . . . . . . . . . . . . . . . . . . 142 7.12.1 Shader Memory Access Ordering . . . . . . . . . . . . . 142 7.12.2 Shader Memory Access Synchronization . . . . . . . . . 144 7.13 Shader, Program, and Program Pipeline Queries . . . . . . . . . . 148 7.14 Required State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 OpenGL 4.4 (Core Profile) - March 19, 2014
  6. 6. CONTENTS iv 8 Textures and Samplers 159 8.1 Texture Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 8.2 Sampler Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 8.3 Sampler Object Queries . . . . . . . . . . . . . . . . . . . . . . . 168 8.4 Pixel Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 8.4.1 Pixel Storage Modes and Pixel Buffer Objects . . . . . . . 169 8.4.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 8.4.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 8.4.4 Transfer of Pixel Rectangles . . . . . . . . . . . . . . . . 170 8.4.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 8.5 Texture Image Specification . . . . . . . . . . . . . . . . . . . . 183 8.5.1 Required Texture Formats . . . . . . . . . . . . . . . . . 186 8.5.2 Encoding of Special Internal Formats . . . . . . . . . . . 187 8.5.3 Texture Image Structure . . . . . . . . . . . . . . . . . . 191 8.6 Alternate Texture Image Specification Commands . . . . . . . . . 196 8.6.1 Texture Copying Feedback Loops . . . . . . . . . . . . . 204 8.7 Compressed Texture Images . . . . . . . . . . . . . . . . . . . . 204 8.8 Multisample Textures . . . . . . . . . . . . . . . . . . . . . . . . 211 8.9 Buffer Textures . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 8.10 Texture Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 216 8.11 Texture Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 8.11.1 Active Texture . . . . . . . . . . . . . . . . . . . . . . . 219 8.11.2 Texture Parameter Queries . . . . . . . . . . . . . . . . . 219 8.11.3 Texture Level Parameter Queries . . . . . . . . . . . . . . 220 8.11.4 Texture Image Queries . . . . . . . . . . . . . . . . . . . 222 8.12 Depth Component Textures . . . . . . . . . . . . . . . . . . . . . 225 8.13 Cube Map Texture Selection . . . . . . . . . . . . . . . . . . . . 225 8.13.1 Seamless Cube Map Filtering . . . . . . . . . . . . . . . 226 8.14 Texture Minification . . . . . . . . . . . . . . . . . . . . . . . . 227 8.14.1 Scale Factor and Level of Detail . . . . . . . . . . . . . . 227 8.14.2 Coordinate Wrapping and Texel Selection . . . . . . . . . 229 8.14.3 Mipmapping . . . . . . . . . . . . . . . . . . . . . . . . 234 8.14.4 Manual Mipmap Generation . . . . . . . . . . . . . . . . 236 8.14.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 8.15 Texture Magnification . . . . . . . . . . . . . . . . . . . . . . . . 237 8.16 Combined Depth/Stencil Textures . . . . . . . . . . . . . . . . . 238 8.17 Texture Completeness . . . . . . . . . . . . . . . . . . . . . . . . 238 8.17.1 Effects of Sampler Objects on Texture Completeness . . . 239 8.17.2 Effects of Completeness on Texture Application . . . . . . 239 8.17.3 Effects of Completeness on Texture Image Specification . 240 OpenGL 4.4 (Core Profile) - March 19, 2014
  7. 7. CONTENTS v 8.18 Texture Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 8.19 Immutable-Format Texture Images . . . . . . . . . . . . . . . . . 244 8.20 Invalidating Texture Image Data . . . . . . . . . . . . . . . . . . 249 8.21 Clearing Texture Image Data . . . . . . . . . . . . . . . . . . . . 250 8.22 Texture State and Proxy State . . . . . . . . . . . . . . . . . . . . 252 8.23 Texture Comparison Modes . . . . . . . . . . . . . . . . . . . . . 255 8.23.1 Depth Texture Comparison Mode . . . . . . . . . . . . . 255 8.24 sRGB Texture Color Conversion . . . . . . . . . . . . . . . . . . 255 8.25 Shared Exponent Texture Color Conversion . . . . . . . . . . . . 256 8.26 Texture Image Loads and Stores . . . . . . . . . . . . . . . . . . 257 8.26.1 Image Unit Queries . . . . . . . . . . . . . . . . . . . . . 266 9 Framebuffers and Framebuffer Objects 267 9.1 Framebuffer Overview . . . . . . . . . . . . . . . . . . . . . . . 267 9.2 Binding and Managing Framebuffer Objects . . . . . . . . . . . . 269 9.2.1 Framebuffer Object Parameters . . . . . . . . . . . . . . 272 9.2.2 Attaching Images to Framebuffer Objects . . . . . . . . . 274 9.2.3 Framebuffer Object Queries . . . . . . . . . . . . . . . . 275 9.2.4 Renderbuffer Objects . . . . . . . . . . . . . . . . . . . . 278 9.2.5 Required Renderbuffer Formats . . . . . . . . . . . . . . 281 9.2.6 Renderbuffer Object Queries . . . . . . . . . . . . . . . . 281 9.2.7 Attaching Renderbuffer Images to a Framebuffer . . . . . 282 9.2.8 Attaching Texture Images to a Framebuffer . . . . . . . . 284 9.3 Feedback Loops Between Textures and the Framebuffer . . . . . . 288 9.3.1 Rendering Feedback Loops . . . . . . . . . . . . . . . . . 288 9.3.2 Texture Copying Feedback Loops . . . . . . . . . . . . . 290 9.4 Framebuffer Completeness . . . . . . . . . . . . . . . . . . . . . 290 9.4.1 Framebuffer Attachment Completeness . . . . . . . . . . 291 9.4.2 Whole Framebuffer Completeness . . . . . . . . . . . . . 292 9.4.3 Required Framebuffer Formats . . . . . . . . . . . . . . . 295 9.4.4 Effects of Framebuffer Completeness on Framebuffer Op- erations . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 9.4.5 Effects of Framebuffer State on Framebuffer Dependent Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 9.5 Mapping between Pixel and Element in Attached Image . . . . . . 296 9.6 Conversion to Framebuffer-Attachable Image Components . . . . 297 9.7 Conversion to RGBA Values . . . . . . . . . . . . . . . . . . . . 297 9.8 Layered Framebuffers . . . . . . . . . . . . . . . . . . . . . . . . 297 OpenGL 4.4 (Core Profile) - March 19, 2014
  8. 8. CONTENTS vi 10 Vertex Specification and Drawing Commands 300 10.1 Primitive Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 10.1.1 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 10.1.2 Line Strips . . . . . . . . . . . . . . . . . . . . . . . . . 302 10.1.3 Line Loops . . . . . . . . . . . . . . . . . . . . . . . . . 302 10.1.4 Separate Lines . . . . . . . . . . . . . . . . . . . . . . . 302 10.1.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 10.1.6 Triangle Strips . . . . . . . . . . . . . . . . . . . . . . . 303 10.1.7 Triangle Fans . . . . . . . . . . . . . . . . . . . . . . . . 304 10.1.8 Separate Triangles . . . . . . . . . . . . . . . . . . . . . 304 10.1.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 10.1.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 10.1.11 Lines with Adjacency . . . . . . . . . . . . . . . . . . . 304 10.1.12 Line Strips with Adjacency . . . . . . . . . . . . . . . . . 306 10.1.13 Triangles with Adjacency . . . . . . . . . . . . . . . . . 306 10.1.14 Triangle Strips with Adjacency . . . . . . . . . . . . . . . 307 10.1.15 Separate Patches . . . . . . . . . . . . . . . . . . . . . . 308 10.1.16 General Considerations For Polygon Primitives . . . . . . 309 10.1.17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 10.2 Current Vertex Attribute Values . . . . . . . . . . . . . . . . . . . 309 10.2.1 Current Generic Attributes . . . . . . . . . . . . . . . . . 309 10.2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 10.2.3 Vertex Attribute Queries . . . . . . . . . . . . . . . . . . 312 10.2.4 Required State . . . . . . . . . . . . . . . . . . . . . . . 312 10.3 Vertex Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 10.3.1 Specifying Arrays for Generic Vertex Attributes . . . . . . 312 10.3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 10.3.3 Vertex Attribute Divisors . . . . . . . . . . . . . . . . . . 318 10.3.4 Transferring Array Elements . . . . . . . . . . . . . . . . 319 10.3.5 Primitive Restart . . . . . . . . . . . . . . . . . . . . . . 319 10.3.6 Robust Buffer Access . . . . . . . . . . . . . . . . . . . . 320 10.3.7 Packed Vertex Data Formats . . . . . . . . . . . . . . . . 321 10.3.8 Vertex Arrays in Buffer Objects . . . . . . . . . . . . . . 321 10.3.9 Array Indices in Buffer Objects . . . . . . . . . . . . . . 322 10.3.10 Indirect Commands in Buffer Objects . . . . . . . . . . . 323 10.4 Vertex Array Objects . . . . . . . . . . . . . . . . . . . . . . . . 323 10.5 Drawing Commands Using Vertex Arrays . . . . . . . . . . . . . 325 10.5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 10.6 Vertex Array and Vertex Array Object Queries . . . . . . . . . . . 335 10.7 Required State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 OpenGL 4.4 (Core Profile) - March 19, 2014
  9. 9. CONTENTS vii 10.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 10.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 10.10Conditional Rendering . . . . . . . . . . . . . . . . . . . . . . . 338 11 Programmable Vertex Processing 340 11.1 Vertex Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 11.1.1 Vertex Attributes . . . . . . . . . . . . . . . . . . . . . . 340 11.1.2 Vertex Shader Variables . . . . . . . . . . . . . . . . . . 346 11.1.3 Shader Execution . . . . . . . . . . . . . . . . . . . . . . 351 11.2 Tessellation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 11.2.1 Tessellation Control Shaders . . . . . . . . . . . . . . . . 363 11.2.2 Tessellation Primitive Generation . . . . . . . . . . . . . 368 11.2.3 Tessellation Evaluation Shaders . . . . . . . . . . . . . . 377 11.3 Geometry Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . 382 11.3.1 Geometry Shader Input Primitives . . . . . . . . . . . . . 383 11.3.2 Geometry Shader Output Primitives . . . . . . . . . . . . 384 11.3.3 Geometry Shader Variables . . . . . . . . . . . . . . . . . 385 11.3.4 Geometry Shader Execution Environment . . . . . . . . . 385 12 392 13 Fixed-Function Vertex Post-Processing 393 13.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 13.2 Transform Feedback . . . . . . . . . . . . . . . . . . . . . . . . 394 13.2.1 Transform Feedback Objects . . . . . . . . . . . . . . . . 394 13.2.2 Transform Feedback Primitive Capture . . . . . . . . . . 396 13.2.3 Transform Feedback Draw Operations . . . . . . . . . . . 400 13.3 Primitive Queries . . . . . . . . . . . . . . . . . . . . . . . . . . 402 13.4 Flatshading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 13.5 Primitive Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . 404 13.5.1 Clipping Shader Outputs . . . . . . . . . . . . . . . . . . 405 13.5.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 13.6 Coordinate Transformations . . . . . . . . . . . . . . . . . . . . 406 13.6.1 Controlling the Viewport . . . . . . . . . . . . . . . . . . 406 13.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 14 Fixed-Function Primitive Assembly and Rasterization 411 14.1 Discarding Primitives Before Rasterization . . . . . . . . . . . . 412 14.2 Invariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 14.3 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 OpenGL 4.4 (Core Profile) - March 19, 2014
  10. 10. CONTENTS viii 14.3.1 Multisampling . . . . . . . . . . . . . . . . . . . . . . . 414 14.4 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 14.4.1 Basic Point Rasterization . . . . . . . . . . . . . . . . . . 418 14.4.2 Point Rasterization State . . . . . . . . . . . . . . . . . . 419 14.4.3 Point Multisample Rasterization . . . . . . . . . . . . . . 419 14.5 Line Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 14.5.1 Basic Line Segment Rasterization . . . . . . . . . . . . . 420 14.5.2 Other Line Segment Features . . . . . . . . . . . . . . . . 422 14.5.3 Line Rasterization State . . . . . . . . . . . . . . . . . . 425 14.5.4 Line Multisample Rasterization . . . . . . . . . . . . . . 425 14.6 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 14.6.1 Basic Polygon Rasterization . . . . . . . . . . . . . . . . 425 14.6.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 14.6.3 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . 428 14.6.4 Options Controlling Polygon Rasterization . . . . . . . . 429 14.6.5 Depth Offset . . . . . . . . . . . . . . . . . . . . . . . . 429 14.6.6 Polygon Multisample Rasterization . . . . . . . . . . . . 430 14.6.7 Polygon Rasterization State . . . . . . . . . . . . . . . . 431 14.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 14.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 14.9 Early Per-Fragment Tests . . . . . . . . . . . . . . . . . . . . . . 432 15 Programmable Fragment Processing 433 15.1 Fragment Shader Variables . . . . . . . . . . . . . . . . . . . . . 433 15.2 Shader Execution . . . . . . . . . . . . . . . . . . . . . . . . . . 434 15.2.1 Texture Access . . . . . . . . . . . . . . . . . . . . . . . 435 15.2.2 Shader Inputs . . . . . . . . . . . . . . . . . . . . . . . . 436 15.2.3 Shader Outputs . . . . . . . . . . . . . . . . . . . . . . . 438 15.2.4 Early Fragment Tests . . . . . . . . . . . . . . . . . . . . 442 16 443 17 Writing Fragments and Samples to the Framebuffer 444 17.1 Antialiasing Application . . . . . . . . . . . . . . . . . . . . . . 444 17.2 Multisample Point Fade . . . . . . . . . . . . . . . . . . . . . . . 444 17.3 Per-Fragment Operations . . . . . . . . . . . . . . . . . . . . . . 445 17.3.1 Pixel Ownership Test . . . . . . . . . . . . . . . . . . . . 445 17.3.2 Scissor Test . . . . . . . . . . . . . . . . . . . . . . . . . 446 17.3.3 Multisample Fragment Operations . . . . . . . . . . . . . 448 17.3.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450 OpenGL 4.4 (Core Profile) - March 19, 2014
  11. 11. CONTENTS ix 17.3.5 Stencil Test . . . . . . . . . . . . . . . . . . . . . . . . . 450 17.3.6 Depth Buffer Test . . . . . . . . . . . . . . . . . . . . . . 451 17.3.7 Occlusion Queries . . . . . . . . . . . . . . . . . . . . . 452 17.3.8 Blending . . . . . . . . . . . . . . . . . . . . . . . . . . 453 17.3.9 sRGB Conversion . . . . . . . . . . . . . . . . . . . . . 460 17.3.10 Dithering . . . . . . . . . . . . . . . . . . . . . . . . . . 460 17.3.11 Logical Operation . . . . . . . . . . . . . . . . . . . . . 461 17.3.12 Additional Multisample Fragment Operations . . . . . . . 463 17.4 Whole Framebuffer Operations . . . . . . . . . . . . . . . . . . . 464 17.4.1 Selecting Buffers for Writing . . . . . . . . . . . . . . . . 464 17.4.2 Fine Control of Buffer Updates . . . . . . . . . . . . . . 468 17.4.3 Clearing the Buffers . . . . . . . . . . . . . . . . . . . . 470 17.4.4 Invalidating Framebuffer Contents . . . . . . . . . . . . . 473 17.4.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 18 Reading and Copying Pixels 475 18.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 18.2 Reading Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 18.2.1 Selecting Buffers for Reading . . . . . . . . . . . . . . . 475 18.2.2 ReadPixels . . . . . . . . . . . . . . . . . . . . . . . . . 477 18.2.3 Obtaining Pixels from the Framebuffer . . . . . . . . . . 477 18.2.4 Conversion of RGBA values . . . . . . . . . . . . . . . . 480 18.2.5 Conversion of Depth values . . . . . . . . . . . . . . . . 480 18.2.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480 18.2.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480 18.2.8 Final Conversion . . . . . . . . . . . . . . . . . . . . . . 480 18.2.9 Placement in Pixel Pack Buffer or Client Memory . . . . . 481 18.3 Copying Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 18.3.1 Blitting Pixel Rectangles . . . . . . . . . . . . . . . . . . 483 18.3.2 Copying Between Images . . . . . . . . . . . . . . . . . 487 18.4 Pixel Draw and Read State . . . . . . . . . . . . . . . . . . . . . 489 19 Compute Shaders 491 19.1 Compute Shader Variables . . . . . . . . . . . . . . . . . . . . . 493 20 Debug Output 494 20.1 Debug Messages . . . . . . . . . . . . . . . . . . . . . . . . . . 495 20.2 Debug Message Callback . . . . . . . . . . . . . . . . . . . . . . 497 20.3 Debug Message Log . . . . . . . . . . . . . . . . . . . . . . . . 498 20.4 Controlling Debug Messages . . . . . . . . . . . . . . . . . . . . 498 OpenGL 4.4 (Core Profile) - March 19, 2014
  12. 12. CONTENTS x 20.5 Externally Generated Messages . . . . . . . . . . . . . . . . . . . 500 20.6 Debug Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 20.7 Debug Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 20.8 Asynchronous and Synchronous Debug Output . . . . . . . . . . 503 20.9 Debug Output Queries . . . . . . . . . . . . . . . . . . . . . . . 504 21 Special Functions 507 21.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 21.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 21.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 21.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 21.5 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 21.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 22 Context State Queries 509 22.1 Simple Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 22.2 String Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511 22.3 Internal Format Queries . . . . . . . . . . . . . . . . . . . . . . . 513 22.3.1 Supported Operation Queries . . . . . . . . . . . . . . . . 514 22.3.2 Other Internal Format Queries . . . . . . . . . . . . . . . 517 23 State Tables 525 A Invariance 600 A.1 Repeatability . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 A.2 Multi-pass Algorithms . . . . . . . . . . . . . . . . . . . . . . . 601 A.3 Invariance Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 601 A.4 Tessellation Invariance . . . . . . . . . . . . . . . . . . . . . . . 603 A.5 Atomic Counter Invariance . . . . . . . . . . . . . . . . . . . . . 605 A.6 What All This Means . . . . . . . . . . . . . . . . . . . . . . . . 606 B Corollaries 607 C Compressed Texture Image Formats 609 C.1 RGTC Compressed Texture Image Formats . . . . . . . . . . . . 609 C.1.1 Format COMPRESSED_RED_RGTC1 . . . . . . . . . . . . 610 C.1.2 Format COMPRESSED_SIGNED_RED_RGTC1 . . . . . . . 611 C.1.3 Format COMPRESSED_RG_RGTC2 . . . . . . . . . . . . . 611 C.1.4 Format COMPRESSED_SIGNED_RG_RGTC2 . . . . . . . . 612 C.2 BPTC Compressed Texture Image Formats . . . . . . . . . . . . 612 OpenGL 4.4 (Core Profile) - March 19, 2014
  13. 13. CONTENTS xi C.2.1 Formats COMPRESSED_RGBA_BPTC_UNORM and COMPRESSED_SRGB_ALPHA_BPTC_UNORM . . . . . . . . 613 C.2.2 Formats COMPRESSED_RGB_BPTC_SIGNED_FLOAT and COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT . . . . . . 619 C.3 ETC Compressed Texture Image Formats . . . . . . . . . . . . . 621 C.3.1 Format COMPRESSED_RGB8_ETC2 . . . . . . . . . . . . 625 C.3.2 Format COMPRESSED_SRGB8_ETC2 . . . . . . . . . . . . 632 C.3.3 Format COMPRESSED_RGBA8_ETC2_EAC . . . . . . . . . 632 C.3.4 Format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC . . . . 635 C.3.5 Format COMPRESSED_R11_EAC . . . . . . . . . . . . . . 635 C.3.6 Format COMPRESSED_RG11_EAC . . . . . . . . . . . . . 638 C.3.7 Format COMPRESSED_SIGNED_R11_EAC . . . . . . . . . 639 C.3.8 Format COMPRESSED_SIGNED_RG11_EAC . . . . . . . . 642 C.3.9 Format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 . . 642 C.3.10 Format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 . 649 D Profiles and the Deprecation Model 650 D.1 Core and Compatibility Profiles . . . . . . . . . . . . . . . . . . 651 D.2 Deprecated and Removed Features . . . . . . . . . . . . . . . . . 651 D.2.1 Deprecated But Still Supported Features . . . . . . . . . . 651 D.2.2 Removed Features . . . . . . . . . . . . . . . . . . . . . 652 E Version 4.2 657 E.1 New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 E.2 Deprecation Model . . . . . . . . . . . . . . . . . . . . . . . . . 658 E.3 Changed Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . 658 E.4 Change Log for Released Specifications . . . . . . . . . . . . . . 659 E.5 Credits and Acknowledgements . . . . . . . . . . . . . . . . . . 661 F Version 4.3 664 F.1 Restructuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664 F.2 New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665 F.3 Deprecation Model . . . . . . . . . . . . . . . . . . . . . . . . . 666 F.4 Changed Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . 666 F.5 Change Log for Released Specifications . . . . . . . . . . . . . . 667 F.6 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674 F.7 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . 676 OpenGL 4.4 (Core Profile) - March 19, 2014
  14. 14. CONTENTS xii G Version 4.4 677 G.1 New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677 G.2 Deprecation Model . . . . . . . . . . . . . . . . . . . . . . . . . 678 G.3 Change Log for Released Specifications . . . . . . . . . . . . . . 678 G.4 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689 G.5 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . 690 H OpenGL Registry, Header Files, and ARB Extensions 691 H.1 OpenGL Registry . . . . . . . . . . . . . . . . . . . . . . . . . . 691 H.2 Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691 H.3 ARB and Khronos Extensions . . . . . . . . . . . . . . . . . . . 692 H.3.1 Naming Conventions . . . . . . . . . . . . . . . . . . . . 693 H.3.2 Promoting Extensions to Core Features . . . . . . . . . . 693 H.3.3 Extension Summaries . . . . . . . . . . . . . . . . . . . 693 H.3.4 Bindless Textures . . . . . . . . . . . . . . . . . . . . . . 717 H.3.5 Compute Variable Group Size . . . . . . . . . . . . . . . 717 H.3.6 Indirect Parameters . . . . . . . . . . . . . . . . . . . . . 717 H.3.7 Seamless Cubemap per Texture . . . . . . . . . . . . . . 717 H.3.8 Shader Draw Parameters . . . . . . . . . . . . . . . . . . 717 H.3.9 Shader Group Vote . . . . . . . . . . . . . . . . . . . . . 717 H.3.10 Sparse Textures . . . . . . . . . . . . . . . . . . . . . . . 718 OpenGL 4.4 (Core Profile) - March 19, 2014
  15. 15. List of Figures 3.1 Block diagram of the GL pipeline. . . . . . . . . . . . . . . . . . 31 8.1 Transfer of pixel rectangles. . . . . . . . . . . . . . . . . . . . . 170 8.2 Selecting a subimage from an image . . . . . . . . . . . . . . . . 175 8.3 A texture image and the coordinates used to access it. . . . . . . . 196 8.4 Example of the components returned for textureGather. . . . . 232 10.1 Vertex processing and primitive assembly. . . . . . . . . . . . . . 300 10.2 Triangle strips, fans, and independent triangles. . . . . . . . . . . 303 10.3 Lines with adjacency. . . . . . . . . . . . . . . . . . . . . . . . . 304 10.4 Triangles with adjacency. . . . . . . . . . . . . . . . . . . . . . . 306 10.5 Triangle strips with adjacency. . . . . . . . . . . . . . . . . . . . 307 11.1 Domain parameterization for tessellation. . . . . . . . . . . . . . 368 11.2 Inner triangle tessellation. . . . . . . . . . . . . . . . . . . . . . . 372 11.3 Inner quad tessellation. . . . . . . . . . . . . . . . . . . . . . . . 375 11.4 Isoline tessellation. . . . . . . . . . . . . . . . . . . . . . . . . . 377 14.1 Rasterization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 14.2 Visualization of Bresenham’s algorithm. . . . . . . . . . . . . . . 421 14.3 Rasterization of non-antialiased wide lines. . . . . . . . . . . . . 423 14.4 The region used in rasterizing an antialiased line segment. . . . . 424 17.1 Per-fragment operations. . . . . . . . . . . . . . . . . . . . . . . 445 18.1 Operation of ReadPixels. . . . . . . . . . . . . . . . . . . . . . . 475 xiii
  16. 16. List of Tables 2.1 GL command suffixes . . . . . . . . . . . . . . . . . . . . . . . . 12 2.2 GL data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.3 Summary of GL errors . . . . . . . . . . . . . . . . . . . . . . . 17 4.1 Initial properties of a sync object created with FenceSync. . . . . 34 6.1 Buffer object binding targets. . . . . . . . . . . . . . . . . . . . . 55 6.2 Buffer object parameters and their values. . . . . . . . . . . . . . 55 6.3 Buffer object state. . . . . . . . . . . . . . . . . . . . . . . . . . 61 6.4 Buffer object state set by MapBufferRange. . . . . . . . . . . . 68 6.5 Indexed buffer object limits and binding queries . . . . . . . . . . 75 7.1 CreateShader type values and the corresponding shader stages. . 79 7.2 GetProgramResourceiv properties and supported interfaces . . . 99 7.3 OpenGL Shading Language type tokens . . . . . . . . . . . . . . 106 7.4 Query targets for default uniform block storage, in components. . 118 7.5 Query targets for combined uniform block storage, in components. 118 7.6 GetProgramResourceiv properties used by GetActiveUniformsiv. 122 7.7 GetProgramResourceiv properties used by GetActiveUniform- Blockiv. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 7.8 GetProgramResourceiv properties used by GetActiveAtomic- CounterBufferiv. . . . . . . . . . . . . . . . . . . . . . . . . . . 125 7.9 Interfaces for active subroutines . . . . . . . . . . . . . . . . . . 138 7.10 Interfaces for active subroutine uniforms . . . . . . . . . . . . . . 138 8.1 PixelStore* parameters. . . . . . . . . . . . . . . . . . . . . . . 169 8.2 Pixel data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 8.3 Pixel data formats. . . . . . . . . . . . . . . . . . . . . . . . . . 174 8.4 Swap Bytes bit ordering. . . . . . . . . . . . . . . . . . . . . . . 174 8.5 Packed pixel formats. . . . . . . . . . . . . . . . . . . . . . . . . 177 xiv
  17. 17. LIST OF TABLES xv 8.6 UNSIGNED_BYTE formats. Bit numbers are indicated for each component. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 8.7 UNSIGNED_SHORT formats . . . . . . . . . . . . . . . . . . . . . 179 8.8 UNSIGNED_INT formats . . . . . . . . . . . . . . . . . . . . . . 180 8.9 FLOAT_UNSIGNED_INT formats . . . . . . . . . . . . . . . . . . 181 8.10 Packed pixel field assignments. . . . . . . . . . . . . . . . . . . . 182 8.11 Conversion from RGBA, depth, and stencil pixel components to internal texture components. . . . . . . . . . . . . . . . . . . . . 185 8.12 Sized internal color formats. . . . . . . . . . . . . . . . . . . . . 190 8.13 Sized internal depth and stencil formats. . . . . . . . . . . . . . . 191 8.14 Generic and specific compressed internal formats. . . . . . . . . . 192 8.15 Internal formats for buffer textures . . . . . . . . . . . . . . . . . 215 8.16 Texture parameters and their values. . . . . . . . . . . . . . . . . 218 8.17 Texture, table, and filter return values. . . . . . . . . . . . . . . . 224 8.18 Selection of cube map images. . . . . . . . . . . . . . . . . . . . 226 8.19 Texel location wrap mode application. . . . . . . . . . . . . . . . 230 8.20 Legal texture targets for TextureView. . . . . . . . . . . . . . . . 241 8.21 Compatible internal formats for TextureView . . . . . . . . . . . 242 8.22 Depth texture comparison functions. . . . . . . . . . . . . . . . . 256 8.23 sRGB texture internal formats. . . . . . . . . . . . . . . . . . . . 257 8.24 Mapping of image load, store, and atomic texel coordinate compo- nents to texel numbers. . . . . . . . . . . . . . . . . . . . . . . . 261 8.25 Supported image unit formats, with equivalent format layout qual- ifiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 8.26 Texel sizes, compatibility classes, and pixel format/type combina- tions for each image format. . . . . . . . . . . . . . . . . . . . . 266 9.1 Framebuffer attachment points. . . . . . . . . . . . . . . . . . . . 283 9.2 Layer numbers for cube map texture faces. . . . . . . . . . . . . . 298 10.1 Triangles generated by triangle strips with adjacency. . . . . . . . 308 10.2 Vertex array sizes (values per vertex) and data types for generic vertex attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 10.3 Packed component layout for non-BGRA formats. . . . . . . . . . 321 10.4 Packed component layout for BGRA format. . . . . . . . . . . . . 321 10.5 Packed component layout for UNSIGNED_INT_10F_11F_11F_- REV format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 10.6 Indirect commands and corresponding indirect buffer targets. . . . 323 11.1 Generic attribute components accessed by attribute variables. . . . 341 OpenGL 4.4 (Core Profile) - March 19, 2014
  18. 18. LIST OF TABLES xvi 11.2 Generic attributes and vector types used by column vectors of ma- trix variables bound to generic attribute index i. . . . . . . . . . . 342 11.3 Scalar and vector vertex attribute types . . . . . . . . . . . . . . . 342 13.1 Transform feedback modes . . . . . . . . . . . . . . . . . . . . . 398 13.2 Provoking vertex selection. . . . . . . . . . . . . . . . . . . . . . 403 15.1 Correspondence of filtered texture components to texture base components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 17.1 RGB and alpha blend equations. . . . . . . . . . . . . . . . . . . 456 17.2 Blending functions. . . . . . . . . . . . . . . . . . . . . . . . . . 458 17.3 Logical operations . . . . . . . . . . . . . . . . . . . . . . . . . 462 17.4 Buffer selection for the default framebuffer . . . . . . . . . . . . 465 17.5 Buffer selection for a framebuffer object . . . . . . . . . . . . . . 465 17.6 DrawBuffers buffer selection for the default framebuffer . . . . . 466 18.1 PixelStore parameters. . . . . . . . . . . . . . . . . . . . . . . . 478 18.2 ReadPixels GL data types and reversed component conversion for- mulas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 18.3 ReadPixels index masks. . . . . . . . . . . . . . . . . . . . . . . 483 18.4 Compatible internal formats for copying . . . . . . . . . . . . . . 489 20.1 Sources of debug output messages . . . . . . . . . . . . . . . . . 495 20.2 Types of debug output messages . . . . . . . . . . . . . . . . . . 496 20.3 Severity levels of messages . . . . . . . . . . . . . . . . . . . . . 496 20.4 Object namespace identifiers . . . . . . . . . . . . . . . . . . . . 502 21.1 Hint targets and descriptions . . . . . . . . . . . . . . . . . . . . 508 22.1 Context profile bits . . . . . . . . . . . . . . . . . . . . . . . . . 512 22.2 Internal format targets . . . . . . . . . . . . . . . . . . . . . . . . 514 23.1 State Variable Types . . . . . . . . . . . . . . . . . . . . . . . . . 526 23.2 Current Values and Associated Data . . . . . . . . . . . . . . . . 527 23.3 Vertex Array Object State (cont.) . . . . . . . . . . . . . . . . . . 528 23.4 Vertex Array Object State (cont.) † The ith attribute defaults to a value of i. . . . . . . . . . . . 529 23.5 Vertex Array Data (not in Vertex Array objects) . . . . . . . . . . 530 23.6 Buffer Object State . . . . . . . . . . . . . . . . . . . . . . . . . 531 23.7 Transformation state . . . . . . . . . . . . . . . . . . . . . . . . 532 23.8 Coloring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 OpenGL 4.4 (Core Profile) - March 19, 2014
  19. 19. LIST OF TABLES xvii 23.9 Rasterization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534 23.10Rasterization (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . 535 23.11Multisampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536 23.12Textures (state per texture unit) . . . . . . . . . . . . . . . . . . . 537 23.13Textures (state per texture unit (cont.) . . . . . . . . . . . . . . . 538 23.14Textures (state per texture object) . . . . . . . . . . . . . . . . . . 539 23.15Textures (state per texture object) (cont.) . . . . . . . . . . . . . . 540 23.16Textures (state per texture image) . . . . . . . . . . . . . . . . . . 541 23.17Textures (state per texture image) (cont.) . . . . . . . . . . . . . . 542 23.18Textures (state per sampler object) . . . . . . . . . . . . . . . . . 543 23.19Texture Environment and Generation . . . . . . . . . . . . . . . . 544 23.20Pixel Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 545 23.21Pixel Operations (cont.) . . . . . . . . . . . . . . . . . . . . . . . 546 23.22Framebuffer Control . . . . . . . . . . . . . . . . . . . . . . . . 547 23.23Framebuffer (state per target binding point) . . . . . . . . . . . . 548 23.24Framebuffer (state per framebuffer object) † This state is queried from the currently bound read framebuffer.549 23.25Framebuffer (state per attachment point) . . . . . . . . . . . . . . 550 23.26Renderbuffer (state per target and binding point) . . . . . . . . . . 551 23.27Renderbuffer (state per renderbuffer object) . . . . . . . . . . . . 552 23.28Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553 23.29Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554 23.30Shader Object State . . . . . . . . . . . . . . . . . . . . . . . . . 555 23.31Program Pipeline Object State . . . . . . . . . . . . . . . . . . . 556 23.32Program Object State . . . . . . . . . . . . . . . . . . . . . . . . 557 23.33Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 558 23.34Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 559 23.35Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 560 23.36Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 561 23.37Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 562 23.38Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 563 23.39Program Object State (cont.) . . . . . . . . . . . . . . . . . . . . 564 23.40Program Interface State . . . . . . . . . . . . . . . . . . . . . . . 565 23.41Program Object Resource State . . . . . . . . . . . . . . . . . . . 566 23.42Program Object Resource State (cont.) . . . . . . . . . . . . . . . 567 23.43Vertex and Geometry Shader State (not part of program objects) . 568 23.44Query Object State . . . . . . . . . . . . . . . . . . . . . . . . . 569 23.45Image State (state per image unit) . . . . . . . . . . . . . . . . . 570 23.46Atomic Counter Buffer Binding State . . . . . . . . . . . . . . . 571 23.47Shader Storage Buffer Binding State . . . . . . . . . . . . . . . . 572 OpenGL 4.4 (Core Profile) - March 19, 2014
  20. 20. LIST OF TABLES xviii 23.48Transform Feedback State . . . . . . . . . . . . . . . . . . . . . 573 23.49Uniform Buffer Binding State . . . . . . . . . . . . . . . . . . . 574 23.50Sync (state per sync object) . . . . . . . . . . . . . . . . . . . . . 575 23.51Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576 23.52Compute Dispatch State . . . . . . . . . . . . . . . . . . . . . . 577 23.53Implementation Dependent Values . . . . . . . . . . . . . . . . . 578 23.54Implementation Dependent Values (cont.) . . . . . . . . . . . . . 579 23.55Implementation Dependent Values (cont.) . . . . . . . . . . . . . 580 23.56Implementation Dependent Version and Extension Support . . . . 581 23.57Implementation Dependent Vertex Shader Limits . . . . . . . . . 582 23.58Implementation Dependent Tessellation Shader Limits . . . . . . 583 23.59Implementation Dependent Tessellation Shader Limits (cont.) . . 584 23.60Implementation Dependent Geometry Shader Limits . . . . . . . 585 23.61Implementation Dependent Fragment Shader Limits . . . . . . . . 586 23.62Implementation Dependent Compute Shader Limits . . . . . . . . 587 23.63Implementation Dependent Aggregate Shader Limits . . . . . . . 588 23.64Implementation Dependent Aggregate Shader Limits (cont.) . . . 589 23.65Implementation Dependent Aggregate Shader Limits (cont.) . . . 590 23.66Implementation Dependent Aggregate Shader Limits (cont.) † The minimum value for each stage is MAX_stage_UNIFORM_BLOCKS × MAX_UNIFORM_BLOCK_SIZE / 4 + MAX_stage_UNIFORM_COMPONENTS . . . . . . . . . . . 591 23.67Debug Output State † The initial value of DEBUG_OUTPUT is TRUE in a debug con- text and FALSE in a non-debug context. . . . . . . . . . . . . . . 592 23.68Implementation Dependent Debug Output State . . . . . . . . . . 593 23.69Implementation Dependent Values (cont.) . . . . . . . . . . . . . 594 23.70Implementation Dependent Values (cont.) . . . . . . . . . . . . . 595 23.71Internal Format Dependent Values . . . . . . . . . . . . . . . . . 596 23.72Implementation Dependent Transform Feedback Limits . . . . . . 597 23.73Framebuffer Dependent Values . . . . . . . . . . . . . . . . . . . 598 23.74Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 C.1 Mode-dependent BPTC parameters . . . . . . . . . . . . . . . . . 615 C.2 Partition table for 2 subset . . . . . . . . . . . . . . . . . . . . . 616 C.3 Partition table for 3 subset . . . . . . . . . . . . . . . . . . . . . 617 C.4 Anchor index values for the second subset of two-subset partitioning618 C.5 Anchor index values for the second subset of three-subset partitioning618 C.6 Anchor index values for the third subset of three-subset partitioning 618 C.7 Endpoint and partition parameters for block modes . . . . . . . . 621 OpenGL 4.4 (Core Profile) - March 19, 2014
  21. 21. LIST OF TABLES xix C.8 Block formats for block modes . . . . . . . . . . . . . . . . . . . 622 C.9 Pixel layout for a 8 × 8 texture using four COMPRESSED_RGB8_- ETC2 compressed blocks. . . . . . . . . . . . . . . . . . . . . . . 624 C.10 Pixel layout for an COMPRESSED_RGB8_ETC2 compressed block. 626 C.11 Texel Data format for RGB8_ETC2 compressed textures formats . 627 C.12 Two 2 × 4-pixel subblocks side-by-side. . . . . . . . . . . . . . . 628 C.13 Two 4 × 2-pixel subblocks on top of each other. . . . . . . . . . . 628 C.14 Intensity modifier sets for ‘individual’ and ‘differential’ modes: . . 629 C.15 Mapping from pixel index values to modifier values for COMPRESSED_RGB8_ETC2 compressed textures . . . . . . . . . . 630 C.16 Distance table for ‘T’ and ‘H’ modes. . . . . . . . . . . . . . . . 631 C.17 Texel Data format for alpha part of COMPRESSED_RGBA8_ETC2_- EAC compressed textures. . . . . . . . . . . . . . . . . . . . . . . 633 C.18 Intensity modifier sets for alpha component. . . . . . . . . . . . . 634 C.19 Texel Data format for RGB8_PUNCHTHROUGH_ALPHA1_ETC2 compressed textures formats . . . . . . . . . . . . . . . . . . . . 643 C.20 Intensity modifier sets if ‘opaque’ is set and if ‘opaque’ is unset. . 645 C.21 Mapping from pixel index values to modifier values for COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 compressed textures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646 E.1 New token names . . . . . . . . . . . . . . . . . . . . . . . . . . 659 F.1 New token names . . . . . . . . . . . . . . . . . . . . . . . . . . 667 OpenGL 4.4 (Core Profile) - March 19, 2014
  22. 22. 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 what is required to implement it. We assume that the reader has at least a rudimentary understanding of computer graphics. This means familiarity with the essentials of 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 OpenGL Registry, 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 and objects in the context of the entire API before describing details of their use in the graphics pipeline. 1.1.1 This subsection is only defined in the compatibility profile. 1.1.2 This subsection is only defined in the compatibility profile. 1
  23. 23. 1.2. WHAT IS THE OPENGL GRAPHICS SYSTEM? 2 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 procedures and functions that allow a programmer to specify the shader programs, objects, and operations involved in producing high-quality graphical images, specifically color images 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, and polygons, but the way that some of this drawing occurs (such as when antialiasing or 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 of shader programs or shaders, data used by shaders, and state controlling aspects of OpenGL outside the scope of shaders. Typically the data represent geometry in two or three dimensions and texture images, while the shaders control the geometric processing, rasterization of geometry and the lighting and shading of fragments generated by rasterization, resulting in rendering geometry into the framebuffer. A typical program that uses OpenGL begins with calls to open a window into the framebuffer into which the program will draw. Then, calls are made to allocate an OpenGL context and associate it with the window. Once a context is allocated, OpenGL commands to define shaders, geometry, and textures are made, followed by commands which draw geometry by transferring specified portions of the geom- etry to the shaders. Drawing commands specify simple geometric objects such as points, line segments, and polygons, which can be further manipulated by shaders. There are also commands which directly control the framebuffer by reading and writing pixels. 1.2.2 Implementor’s View of OpenGL To the implementor, OpenGL is a set of commands that control the operation of the GPU. Modern GPUs accelerate almost all OpenGL operations, storing data and framebuffer images in GPU memory and executing shaders in dedicated GPU processors. However, OpenGL may be implemented on less capable GPUs, or even without 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 which implements the OpenGL API, while dividing the work for each OpenGL command OpenGL 4.4 (Core Profile) - March 19, 2014
  24. 24. 1.2. WHAT IS THE OPENGL GRAPHICS SYSTEM? 3 between the CPU and the graphics hardware as appropriate for the capabilities of the GPU. OpenGL contains a considerable amount of information including many types of objects representing programmable shaders and the data they consume and generate, as well as other context state controlling non-programmable aspects of OpenGL. Most of these objects and state are available to the programmer, who can set, 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 objects and context state explicitly, to elucidate how they change in response to OpenGL commands, 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 both programmers and implementors. It does not, however, necessarily provide a model for implementation. An implementation must produce results conforming to those produced by the specified methods, but there may be ways to carry out a particular computation 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 their operation. The compatibility profile of OpenGL continues to support the legacy OpenGL commands developed for such fixed-function hardware, although they are typically implemented by writing shaders which reproduce the operation of such hardware. Fixed-function OpenGL commands and operations are described as 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 to be removed in a future version, allowing applications time to transition away from use of deprecated features. The deprecation model is described in more detail, together with a summary of the commands and state deprecated from this version of the API, in appendix D. OpenGL 4.4 (Core Profile) - March 19, 2014
  25. 25. 1.3. RELATED APIS 4 1.3 Related APIs Other APIs related to OpenGL are described below. Most of the specifications for these 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 document titled The OpenGL Shading Language. The latter document (referred to as the OpenGL 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 and terms (such as shading language variable types) defined in the OpenGL Shading Language Specification. OpenGL 4.4 implementations are guaranteed to support version 4.40 of the OpenGL Shading Language. All references to sections of that specification refer to that version. The latest supported version of the shading language may be queried as described in section 22.2. The core profile of OpenGL 4.4 is also guaranteed to support all previous ver- sions of the OpenGL Shading Language back to version 1.40. In some implemen- tations the core profile may also support earlier versions of the Shading Language, and may support compatibility profile versions of the Shading Language for ver- sions 1.40 and earlier. In this case, errors will be generated when using language features such as compatibility profile built-ins not supported by the core profile API. The #version strings for all supported versions of the OpenGL Shading Language may 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 3D graphics on embedded systems such as mobile phones, game consoles, and ve- hicles. It consists of well-defined subsets of OpenGL. OpenGL ES version 1.1 implements 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 additional functionality taken from later OpenGL versions or specific to OpenGL ES. It is OpenGL 4.4 (Core Profile) - March 19, 2014
  26. 26. 1.3. RELATED APIS 5 straightforward to port code written for OpenGL ES to corresponding versions of OpenGL. 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, for increased compatibility between OpenGL and OpenGL ES implementations. The OpenGL ES Specifications are available in the Khronos API Registry at URL http://www.khronos.org/registry/ 1.3.3 OpenGL ES Shading Language The Specification should also be read together with companion documents titled The OpenGL ES Shading Language. Both versions 1.00 and 3.00 should be read. These documents define versions of the OpenGL Shading Language designed for implementations of OpenGL ES 2.0 and 3.0 respectively, but also supported by OpenGL implementations. References to the OpenGL Shading Language Speci- fication hereafter include both OpenGL and OpenGL ES versions of the Shading Language; references to specific sections are to those sections in version 4.40 of the OpenGL Shading Language Specification. OpenGL 4.4 implementations are guaranteed to support both versions 1.00 and 3.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 Khronos API 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 will recognize WebGL as a shader-based API using a form of the OpenGL Shading Language, 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-managed languages such as JavaScript. The WebGL Specification and related documentation are available in the Khronos API Registry. OpenGL 4.4 (Core Profile) - March 19, 2014
  27. 27. 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 Specification hereafter, describes the GLX API for use of OpenGL in the X Window System. It is primarily directed at Linux and Unix systems, but GLX implementations also exist for 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 window system, including CGL, AGL, and NSOpenGLView. These APIs are documented on Apple’s developer website. 1.3.5.4 EGL - Mobile and Embedded Device Bindings The Khronos Native Platform Graphics Interface or “EGL Specification” describes the EGL API for use of OpenGL ES on mobile and embedded devices. EGL im- plementations supporting OpenGL may be available on some desktop platforms as well. 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 mobile devices, including GPUs. OpenCL defines interop methods to share OpenCL mem- ory and image objects with corresponding OpenGL buffer and texture objects, and to coordinate control of and transfer of data between OpenCL and OpenGL. This allows applications to split processing of data between OpenCL and OpenGL; for example, by using OpenCL to implement a physics model and then rendering and interacting with the resulting dynamic geometry using OpenGL. OpenGL 4.4 (Core Profile) - March 19, 2014
  28. 28. 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 be filed 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 (Core Profile) - March 19, 2014
  29. 29. Chapter 2 OpenGL Fundamentals This chapter introduces fundamental concepts including the OpenGL execution model, API syntax, contexts and threads, numeric representation, context state and state queries, and the different types of objects and shaders. It provides a frame- work for interpreting more specific descriptions of commands and behavior in the remainder of the Specification. 2.1 Execution Model OpenGL (henceforth, “the GL”) is concerned only with processing data in GPU memory, including rendering into a framebuffer and reading values stored in that framebuffer. There is no support for other input or output devices. Programmers must 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, or polygon. Context state may be changed independently; 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 the framebuffer). State is set, primitives drawn, and other GL operations described by sending commands in the form of function or procedure calls. Primitives are defined by a group of one or more vertices. A vertex defines a point, an endpoint of a line segment, or a corner of a polygon where two edges meet. 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 vertices must be clipped so that the indicated primitive fits within a specified region; in this case vertex data may be modified and new vertices created. The type of clipping 8
  30. 30. 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 are realized. This means, for example, that one primitive must be drawn completely before any subsequent one can affect the framebuffer. It also means that queries and pixel read operations return state consistent with complete execution of all previously invoked GL commands, except where explicitly specified otherwise. In general, the effects of a GL command on either GL state or the framebuffer must be complete before any subsequent command can have any such effects. Data binding occurs on call. This means that data passed to a GL command are interpreted when that command is received. Even if the command requires a pointer to data, those data are interpreted when the call is made, and any subsequent changes to the data have no effect on the GL (unless the same pointer is used in a subsequent command). The GL provides direct control over the fundamental operations of 3D and 2D graphics. This includes specification of parameters of application-defined shader programs performing transformation, lighting, texturing, and shading operations, as well as built-in functionality such as antialiasing and texture filtering. It does not provide a means for describing or modeling complex geometric objects, although shaders can be written to generate such objects. In other words, OpenGL provides mechanisms to describe how complex geometric objects are to be rendered, rather than 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 same computer 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 which is an encapsulation of current GL state and objects. A client may choose to be made current to any one of these contexts. Issuing GL commands when a program is not current to a context results in undefined behavior. There are two classes of framebuffers: a window system-provided framebuffer associated with a context when the context is made current, and application-created framebuffers. 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 framebuffer and 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 (Core Profile) - March 19, 2014
  31. 31. 2.2. COMMAND SYNTAX 10 trolled by the window system, which allocates framebuffer resources, determines which portions of the default framebuffer the GL may access at any given time, and communicates to the GL how those portions are structured. Therefore, there are no GL commands to initialize a GL context or configure the default framebuffer. Similarly, display of framebuffer contents on a physical display device (including the transformation of individual framebuffer values by such techniques as gamma correction) is not addressed by the GL. Allocation and configuration of the default framebuffer occurs outside of the GL in conjunction with the window system, using companion APIs described in section 1.3.5. Allocation and initialization of GL contexts is also done using these companion APIs. GL contexts can be associated with different default framebuffers, and some context state is determined at the time this association is performed. It is possible to use a GL context without a default framebuffer, in which case a framebuffer object must be used to perform all rendering. This is useful for applications 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 behavior instead of actual behavior for certain GL operations. In cases where deviation from the ideal is allowed, we also specify the rules that an implementation must obey if it is to approximate the ideal behavior usefully. This allowed variation in GL behavior implies that two distinct GL implementations may not agree pixel for pixel when presented with the same input, even when run on identical framebuffer configurations. Finally, command names, constants, and types are prefixed in the C language binding to OpenGL (by gl, GL_, and GL, respectively), to reduce name clashes with other packages. The prefixes are omitted in this document for clarity. 2.2 Command Syntax The Specification describes OpenGL commands as functions or procedures using ANSI C syntax. Languages such as C++ and Javascript which allow passing of argument type information permit language bindings with simpler declarations and fewer entry points. Various groups of GL commands perform the same operation but differ in how arguments are supplied to them. To conveniently accommodate this variation, we adopt a notation for describing commands and their arguments. GL commands are formed from a name which may be followed, depending on the particular command, by a sequence of characters describing a parameter to the OpenGL 4.4 (Core Profile) - March 19, 2014
  32. 32. 2.2. COMMAND SYNTAX 11 command. If present, a digit indicates the required length (number of values) of the indicated type. Next, a string of characters making up one of the type descriptors from table 2.1 indicates the specific size and data type of parameter values. A final 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 specific examples 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 type descriptors (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 be present. The N arguments arg1 through argN have type T, which corresponds to one of the type descriptors indicated in table 2.1 (if there are no letters, then the arguments’ type is given explicitly). If the final character is not v, then N is given by 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 of the 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 (Core Profile) - March 19, 2014
  33. 33. 2.2. COMMAND SYNTAX 12 Type Descriptor Corresponding GL Type b byte s short i int i64 int64 f float d double ub ubyte us ushort ui uint ui64 uint64 Table 2.1: Correspondence of command suffix type descriptors to GL argument types. 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 these types. Since many GL operations represent bitfields within these types, transfer blocks 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 an architecture which cannot satisfy the exact bit width requirements in table 2.2. The types clampf and clampd are no longer used, replaced by float and 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 of such a command exist, using the type descriptor syntax described above, any such version 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 being propagated to man pages and header files as well. OpenGL 4.4 (Core Profile) - March 19, 2014
  34. 34. 2.2. COMMAND SYNTAX 13 GL Type Description Bit Width boolean 1 or more Boolean byte 8 Signed two’s complement binary inte- ger ubyte 8 Unsigned binary integer char 8 Characters making up strings short 16 Signed two’s complement binary inte- ger ushort 16 Unsigned binary integer int 32 Signed two’s complement binary inte- ger uint 32 Unsigned binary integer fixed 32 Signed two’s complement 16.16 scaled integer int64 64 Signed two’s complement binary inte- ger uint64 64 Unsigned binary integer sizei 32 Non-negative binary integer size enum 32 Enumerated binary integer value intptr ptrbits Signed twos complement binary inte- ger sizeiptr ptrbits Non-negative binary integer size sync ptrbits Sync object handle (see section 4.1) bitfield 32 Bit field half 16 Half-precision floating-point value encoded in an unsigned scalar float 32 Floating-point value clampf 32 Floating-point value clamped to [0, 1] double 64 Floating-point value clampd 64 Floating-point value clamped to [0, 1] Table 2.2: GL data types. GL types are not C types. Thus, for example, GL type int is referred to as GLint outside this document, and is not necessarily equivalent to the C type int. An implementation must use exactly the number of bits 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 bindings while intptr and sizeiptr are defined as integer types large enough to hold a pointer. OpenGL 4.4 (Core Profile) - March 19, 2014
  35. 35. 2.2. COMMAND SYNTAX 14 a different parameter type than the actual type of that state, data conversions are performed 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 FALSE and TRUE are converted to 0 and 1, respectively. Floating-point values are rounded to the nearest integer. If the resulting value is so large in magnitude that it cannot be represented by the internal state variable, the internal state value is undefined. • When the type of internal state is floating-point, boolean values of FALSE and 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 values and data types, which are described following the reference. Validation of values performed by state-setting commands is performed after conversion, 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 multiple versions 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 are performed as follows: • If a command returning boolean data is called, such as GetBooleanv, a floating-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, unless the value is an RGBA color component, a DepthRange value, or a depth OpenGL 4.4 (Core Profile) - March 19, 2014
  36. 36. 2.3. COMMAND EXECUTION 15 buffer clear value. In these cases, the query command converts the floating- point value to an integer according to the INT entry of table 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 or GetDoublev, a boolean value of TRUE or FALSE is interpreted as 1.0 or 0.0, respectively. An integer value is coerced to floating-point. Single- and double-precision floating-point values are converted as necessary. If a value is so large in magnitude that it cannot be represented by the returned data 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, so that mask values with the high bit set will not be clamped when returned as signed integers. Unless otherwise indicated, multi-valued state variables return their multiple values in the same order as they are given as arguments to the commands that set them. For instance, the two DepthRange parameters are returned in the order n followed by f. 2.3 Command Execution Most of the Specification discusses the behavior of a single context bound to a single CPU thread. It is also possible for multiple contexts to share GL objects and for each such context to be bound to a different thread. This section introduces concepts related to GL command execution including error reporting, command queue flushing, and synchronization between command streams. Using these tools can increase performance and utilization of the GPU by separating loosely related tasks into different contexts. Methods to create, manage, and destroy CPU threads are defined by the host CPU operating system and are not described in the Specification. Binding of GL contexts to CPU threads is controlled through a window system binding layer such as 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. The command OpenGL 4.4 (Core Profile) - March 19, 2014
  37. 37. 2.3. COMMAND EXECUTION 16 enum GetError( void ); is used to obtain error information. Each detectable error is assigned a numeric code. When an error is detected, a flag is set and the code is recorded. Further errors, 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 record its code. If a call to GetError returns NO_ERROR, then there has been no detectable error 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 each subsequent call returns the non-zero code of a distinct flag-code pair (in unspecified order), until all non-NO_ERROR codes have been returned. When there are no more non-NO_ERROR error codes, all flags are reset. This scheme requires some positive number of pairs of a flag bit and an integer. The initial state of all flags is cleared and the initial value of all codes is NO_ERROR. Table 2.3 summarizes GL errors. Currently, when an error flag is set, results of GL operation are undefined only if an OUT_OF_MEMORY error has occurred. In other cases, there are no side effects unless otherwise noted; the command which generates the error is ignored so that it has no effect on GL state or framebuffer contents. Except as otherwise noted, if the generating command returns a value, it returns zero. If the generating command modifies values through a pointer argu- ment, no change is made to these values. These error semantics apply only to GL errors, not to system errors such as memory access errors. This behavior is the current behavior; the action of the GL in the presence of errors is subject to change, and extensions to OpenGL may define behavior currently considered as an error. Several error generation conditions are implicit in the description of every GL command. • If a command that requires an enumerated value is passed a symbolic con- stant that is not one of those specified as allowable for that command, an INVALID_ENUM error is generated. This is the case even if the argument is a pointer to a symbolic constant, if the value or values pointed to are not allowable for the given command. • If a negative number is provided where an argument of type sizei or sizeiptr is specified, an INVALID_VALUE error is generated. • If memory is exhausted as a side effect of the execution of a command, an OUT_OF_MEMORY error may be generated. OpenGL 4.4 (Core Profile) - March 19, 2014
  38. 38. 2.3. COMMAND EXECUTION 17 Error Description Offending com- mand ignored? INVALID_ENUM enum argument out of range Yes INVALID_VALUE Numeric argument out of range Yes INVALID_OPERATION Operation illegal in current state Yes INVALID_FRAMEBUFFER_OPERATION Framebuffer object is not com- plete Yes OUT_OF_MEMORY Not enough memory left to exe- cute command Unknown STACK_OVERFLOW Command would cause a stack overflow Yes STACK_UNDERFLOW Command would cause a stack underflow Yes Table 2.3: Summary of GL errors The Specification attempts to explicitly describe these implicit error conditions (with the exception of OUT_OF_MEMORY2) wherever they apply. However, they ap- ply even if not explicitly described, unless a specific command describes different behavior. For example, certain commands use a sizei parameter to indicate the length of a string, and also use negative values of the parameter to indicate a null- terminated string. These commands do not generate an INVALID_VALUE error, because they explicitly describe different behavior. Otherwise, errors are generated only for conditions that are explicitly described in the Specification. When a command could potentially generate several different errors (for ex- ample, when it is passed separate enum and numeric parameters which are both out of range), the GL implementation may choose to generate any of the applicable errors. When an error is generated, the GL may also generate a debug output message describing its cause (see chapter 20). The message has source DEBUG_SOURCE_- API, type DEBUG_TYPE_ERROR, and an implementation-dependent ID. Most commands include a complete summary of errors at the end of their de- scription, including even the implicit errors described above. 2 OUT_OF_MEMORY is not described because it can potentially be generated by any GL com- mand, even those which do not explicitly allocate GPU memory. OpenGL 4.4 (Core Profile) - March 19, 2014
  39. 39. 2.3. COMMAND EXECUTION 18 Such error summaries are set in a distinct style, like this sentence. In some cases, however, errors may be generated for a single command for reasons not directly related to that command. One such example is that deferred processing for shader programs may result in link errors detected only when at- tempting to draw primitives using vertex specification commands. In such cases, errors generated by a command may be described elsewhere in the specification than the command itself. 2.3.2 Flush and Finish Implementations may buffer multiple commands in a command queue before send- ing them to the GL server for execution. This may happen in places such as the network stack (for network transparent implementations), CPU code executing as part of the GL client or the GL server, or internally to the GPU hardware. Coarse control over command queues is available using the command void Flush( void ); which causes all previously issued GL commands to complete in finite time (al- though such commands may still be executing when Flush returns). The command void Finish( void ); forces all previously issued GL commands to complete. Finish does not return until all effects from such commands on GL client and server state and the frame- buffer are fully realized. Finer control over command execution can be expressed using fence commands and sync objects, as discussed in section 4.1. 2.3.3 Numeric Representation and Computation The GL must perform a number of floating-point operations during the course of its operation. Implementations normally perform computations in floating-point, and must meet the range and precision requirements defined under ”Floating-Point Com- putation” below. These requirements only apply to computations performed in GL operations outside of shader execution, such as texture image specification and sampling, and OpenGL 4.4 (Core Profile) - March 19, 2014
  40. 40. 2.3. COMMAND EXECUTION 19 per-fragment operations. Range and precision requirements during shader execu- tion differ and are specified by the OpenGL Shading Language Specification. In some cases, the representation and/or precision of operations is implicitly limited by the specified format of vertex, texture, or renderbuffer data consumed by the GL. Specific floating-point formats are described later in this section. 2.3.3.1 Floating-Point Computation We do not specify how floating-point numbers are to be represented, or the details of how operations on them are performed. We require simply that numbers’ floating-point parts contain enough bits and that their exponent fields are large enough so that individual results of floating- point operations are accurate to about 1 part in 105. The maximum representable magnitude for all floating-point values must be at least 232. x · 0 = 0 · x = 0 for any non-infinite and non-NaN x. 1 · x = x · 1 = x. x + 0 = 0 + x = x. 00 = 1. (Occasionally further requirements will be specified.) Most single-precision floating-point formats meet these requirements. The special values Inf and −Inf encode values with magnitudes too large to be represented; the special value NaN encodes “Not A Number” values resulting from undefined arithmetic operations such as 0 0. Implementations are permitted, but not required, to support Inf s and NaN s in their floating-point computations. Any representable floating-point value is legal as input to a GL command that requires floating-point data. The result of providing a value that is not a floating- point number to such a command is unspecified, but must not lead to GL interrup- tion or termination. In IEEE arithmetic, for example, providing a negative zero or a denormalized number to a GL command yields predictable results, while providing a NaN or an infinity yields unspecified results. 2.3.3.2 16-Bit Floating-Point Numbers A 16-bit floating-point number has a 1-bit sign (S), a 5-bit exponent (E), and a 10-bit mantissa (M). The value V of a 16-bit floating-point number is determined by the following: V =    (−1)S × 0.0, E = 0, M = 0 (−1)S × 2−14 × M 210 , E = 0, M = 0 (−1)S × 2E−15 × 1 + M 210 , 0 < E < 31 (−1)S × Inf , E = 31, M = 0 NaN , E = 31, M = 0 OpenGL 4.4 (Core Profile) - March 19, 2014
  41. 41. 2.3. COMMAND EXECUTION 20 If the floating-point number is interpreted as an unsigned 16-bit integer N, then S = N mod 65536 32768 E = N mod 32768 1024 M = N mod 1024. Any representable 16-bit floating-point value is legal as input to a GL command that accepts 16-bit floating-point data. The result of providing a value that is not a floating-point number (such as Inf or NaN ) to such a command is unspecified, but must not lead to GL interruption or termination. Providing a denormalized number or negative zero to GL must yield predictable results. 2.3.3.3 Unsigned 11-Bit Floating-Point Numbers An unsigned 11-bit floating-point number has no sign bit, a 5-bit exponent (E), and a 6-bit mantissa (M). The value V of an unsigned 11-bit floating-point number is determined by the following: V =    0.0, E = 0, M = 0 2−14 × M 64 , E = 0, M = 0 2E−15 × 1 + M 64 , 0 < E < 31 Inf , E = 31, M = 0 NaN , E = 31, M = 0 If the floating-point number is interpreted as an unsigned 11-bit integer N, then E = N 64 M = N mod 64. When a floating-point value is converted to an unsigned 11-bit floating-point representation, finite values are rounded to the closest representable finite value. While less accurate, implementations are allowed to always round in the direction of zero. This means negative values are converted to zero. Likewise, finite posi- tive values greater than 65024 (the maximum finite representable unsigned 11-bit floating-point value) are converted to 65024. Additionally: negative infinity is con- verted to zero; positive infinity is converted to positive infinity; and both positive and negative NaN are converted to positive NaN . OpenGL 4.4 (Core Profile) - March 19, 2014
  42. 42. 2.3. COMMAND EXECUTION 21 Any representable unsigned 11-bit floating-point value is legal as input to a GL command that accepts 11-bit floating-point data. The result of providing a value that is not a floating-point number (such as Inf or NaN ) to such a command is unspecified, but must not lead to GL interruption or termination. Providing a denormalized number to GL must yield predictable results. 2.3.3.4 Unsigned 10-Bit Floating-Point Numbers An unsigned 10-bit floating-point number has no sign bit, a 5-bit exponent (E), and a 5-bit mantissa (M). The value V of an unsigned 10-bit floating-point number is determined by the following: V =    0.0, E = 0, M = 0 2−14 × M 32 , E = 0, M = 0 2E−15 × 1 + M 32 , 0 < E < 31 Inf , E = 31, M = 0 NaN , E = 31, M = 0 If the floating-point number is interpreted as an unsigned 10-bit integer N, then E = N 32 M = N mod 32. When a floating-point value is converted to an unsigned 10-bit floating-point representation, finite values are rounded to the closest representable finite value. While less accurate, implementations are allowed to always round in the direction of zero. This means negative values are converted to zero. Likewise, finite posi- tive values greater than 64512 (the maximum finite representable unsigned 10-bit floating-point value) are converted to 64512. Additionally: negative infinity is con- verted to zero; positive infinity is converted to positive infinity; and both positive and negative NaN are converted to positive NaN . Any representable unsigned 10-bit floating-point value is legal as input to a GL command that accepts 10-bit floating-point data. The result of providing a value that is not a floating-point number (such as Inf or NaN ) to such a command is unspecified, but must not lead to GL interruption or termination. Providing a denormalized number to GL must yield predictable results. OpenGL 4.4 (Core Profile) - March 19, 2014
  43. 43. 2.3. COMMAND EXECUTION 22 2.3.3.5 Fixed-Point Computation Vertex attributes may be specified using a 32-bit two’s-complement signed repre- sentation with 16 bits to the right of the binary point (fraction bits). 2.3.3.6 General Requirements Some calculations require division. In such cases (including implied divisions re- quired by vector normalizations), a division by zero produces an unspecified result but must not lead to GL interruption or termination. 2.3.4 Fixed-Point Data Conversions When generic vertex attributes and pixel color or depth components are repre- sented as integers, they are often (but not always) considered to be normalized. Normalized integer values are treated specially when being converted to and from floating-point values, and are usually referred to as normalized fixed-point. Such values are always either signed or unsigned. In the remainder of this section, b denotes the bit width of the fixed-point inte- ger representation. When the integer is one of the types defined in table 2.2, b is the required bit width of that type. When the integer is a texture or renderbuffer color or depth component (see section 8.5), b is the number of bits allocated to that component in the internal format of the texture or renderbuffer. When the integer is a framebuffer color or depth component (see section 9), b is the number of bits allo- cated to that component in the framebuffer. For framebuffer and renderbuffer alpha components, b must be at least 2 if the buffer does not contain an alpha component, or if there is only one bit of alpha in the buffer. The signed and unsigned fixed-point representations are assumed to be b-bit binary twos-complement integers and binary unsigned integers, respectively. 2.3.4.1 Conversion from Normalized Fixed-Point to Floating-Point Unsigned normalized fixed-point integers represent numbers in the range [0, 1]. The conversion from an unsigned normalized fixed-point value c to the correspond- ing floating-point value f is defined as f = c 2b − 1 . (2.1) Signed normalized fixed-point integers represent numbers in the range [−1, 1]. The conversion from a signed normalized fixed-point value c to the corresponding OpenGL 4.4 (Core Profile) - March 19, 2014
  44. 44. 2.3. COMMAND EXECUTION 23 floating-point value f is performed using f = max c 2b−1 − 1 , −1.0 . (2.2) Only the range [−2b−1 + 1, 2b−1 − 1] is used to represent signed fixed-point values in the range [−1, 1]. For example, if b = 8, then the integer value −127 cor- responds to −1.0 and the value 127 corresponds to 1.0. Note that while zero can be exactly expressed in this representation, one value (−128 in the example) is outside the representable range, and must be clamped before use. This equation is used ev- erywhere that signed normalized fixed-point values are converted to floating-point, including for all signed normalized fixed-point parameters in GL commands, such as vertex attribute values3, as well as for specifying texture or framebuffer values using signed normalized fixed-point. 2.3.4.2 Conversion from Floating-Point to Normalized Fixed-Point The conversion from a floating-point value f to the corresponding unsigned nor- malized fixed-point value c is defined by first clamping f to the range [0, 1], then computing f = f × (2b − 1). (2.3) f is then cast to an unsigned binary integer value with exactly b bits. The conversion from a floating-point value f to the corresponding signed nor- malized fixed-point value c is performed by clamping f to the range [−1, 1], then computing f = f × (2b−1 − 1). (2.4) After conversion, f is then cast to a signed two’s-complement binary integer value with exactly b bits. This equation is used everywhere that floating-point values are converted to signed normalized fixed-point, including when querying floating-point state (see section 2.2.2) and returning integers4, as well as for specifying signed normalized texture or framebuffer values using floating-point. 3 This is a behavior change in OpenGL 4.2. In previous versions, a different conversion for signed normalized values was used in which −128 mapped to −1.0, 127 mapped to 1.0, and 0.0 was not exactly representable. 4 This is a behavior change in OpenGL 4.2. In previous versions, a different conversion for signed normalized values was used in which −1.0 mapped to −128, 1.0 mapped to 127, and 0.0 was not exactly representable. OpenGL 4.4 (Core Profile) - March 19, 2014
  45. 45. 2.4. RENDERING COMMANDS 24 2.4 Rendering Commands GL commands performing rendering into a framebuffer are sometimes treated spe- cially by other GL operations such as conditional rendering (see section 10.10). Such commands are called rendering commands, and include the drawing com- mands *Draw* (see section 10.5), as well as these additional commands: • BlitFramebuffer (see section 18.3.1) • Clear (see section 17.4.3) • ClearBuffer* (see section 17.4.3.1) • DispatchCompute* (see section 19) 2.5 Context State Context state is state that belongs to the GL context as a whole, rather than to instances of the different object types described in section 2.6. Context state con- trols fixed-function stages of the GPU, such as clipping, primitive rasterization, and framebuffer clears, and also specifies bindings of objects to the context specifying which objects are used during command execution. The Specification describes all visible context state variables and describes how each one can be changed. State variables are grouped somewhat arbitrarily by their function. Although we describe operations that the GL performs on the frame- buffer, the framebuffer is not a part of GL state. There are two types of context state. Server state resides in the GL server; the majority of GL state falls into this category. Client state resides in the GL client. Unless otherwise specified, all state is server state; client state is specifically identified. Each instance of a context includes a complete set of server state; each connection from a client to a server also includes a complete set of client state. While an implementation of OpenGL may be hardware dependent, the Specifi- cation is independent of any specific hardware on which it is implemented. We are concerned with the state of graphics hardware only when it corresponds precisely to GL state. 2.5.1 Generic Context State Queries Context state queries are described in detail in chapter 22. OpenGL 4.4 (Core Profile) - March 19, 2014

×