The OpenGL Graphics System. A Specification (Version 4.2 (Core Profile) - April 27, 2012).pdf

(3653 KB) Pobierz
The OpenGL Graphics System:
A Specification
(Version 4.2 (Core Profile) - April 27, 2012)
Mark Segal
Kurt Akeley
Editor (version 1.1): Chris Frazier
Editor (versions 1.2-4.2): Jon Leech
Editor (version 2.0): Pat Brown
R
Copyright c 2006-2012 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.
Contents
1
Introduction
1.1 Formatting of the OpenGL Specification
1.1.1 Formatting of Changes . . . . .
1.2 What is the OpenGL Graphics System?
1.3 Programmer’s View of OpenGL . . . .
1.4 Implementor’s View of OpenGL . . . .
1.5 Our View . . . . . . . . . . . . . . . .
1.6 The Deprecation Model . . . . . . . . .
1.7 Companion Documents . . . . . . . . .
1.7.1 OpenGL Shading Language . .
1.7.2 Window System Bindings . . .
1
1
1
1
2
2
2
3
3
3
3
5
5
7
11
12
13
13
15
17
19
20
22
28
30
34
34
35
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2 OpenGL Operation
2.1 OpenGL Fundamentals . . . . . . . . . . . . . . . . .
2.1.1 Numeric Computation . . . . . . . . . . . . .
2.1.2 Fixed-Point Data Conversions . . . . . . . . .
2.2 GL State . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.1 Shared Object State . . . . . . . . . . . . . . .
2.3 GL Command Syntax . . . . . . . . . . . . . . . . . .
2.3.1 Data Conversion For State-Setting Commands
2.4 Basic GL Operation . . . . . . . . . . . . . . . . . . .
2.5 GL Errors . . . . . . . . . . . . . . . . . . . . . . . .
2.6 Primitives and Vertices . . . . . . . . . . . . . . . . .
2.6.1 Primitive Types . . . . . . . . . . . . . . . . .
2.7 Vertex Specification . . . . . . . . . . . . . . . . . . .
2.8 Vertex Arrays . . . . . . . . . . . . . . . . . . . . . .
2.8.1 Transferring Array Elements . . . . . . . . . .
2.8.2 Packed Vertex Data Formats . . . . . . . . . .
2.8.3 Drawing Commands . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
i
CONTENTS
2.9
Buffer Objects . . . . . . . . . . . . . . . . . . . . .
2.9.1 Creating and Binding Buffer Objects . . . .
2.9.2 Creating Buffer Object Data Stores . . . . .
2.9.3 Mapping and Unmapping Buffer Data . . . .
2.9.4 Effects of Accessing Outside Buffer Bounds
2.9.5 Copying Between Buffers . . . . . . . . . .
2.9.6 Vertex Arrays in Buffer Objects . . . . . . .
2.9.7 Array Indices in Buffer Objects . . . . . . .
2.9.8 Indirect Commands in Buffer Objects . . . .
2.9.9 Buffer Object State . . . . . . . . . . . . . .
Vertex Array Objects . . . . . . . . . . . . . . . . .
Vertex Shaders . . . . . . . . . . . . . . . . . . . .
2.11.1 Shader Objects . . . . . . . . . . . . . . . .
2.11.2 Loading Shader Binaries . . . . . . . . . . .
2.11.3 Program Objects . . . . . . . . . . . . . . .
2.11.4 Program Pipeline Objects . . . . . . . . . .
2.11.5 Program Binaries . . . . . . . . . . . . . . .
2.11.6 Vertex Attributes . . . . . . . . . . . . . . .
2.11.7 Uniform Variables . . . . . . . . . . . . . .
2.11.8 Subroutine Uniform Variables . . . . . . . .
2.11.9 Samplers . . . . . . . . . . . . . . . . . . .
2.11.10 Images . . . . . . . . . . . . . . . . . . . .
2.11.11 Output Variables . . . . . . . . . . . . . . .
2.11.12 Shader Execution . . . . . . . . . . . . . . .
2.11.13 Shader Memory Access . . . . . . . . . . .
2.11.14 Required State . . . . . . . . . . . . . . . .
Tessellation . . . . . . . . . . . . . . . . . . . . . .
2.12.1 Tessellation Control Shaders . . . . . . . . .
2.12.2 Tessellation Primitive Generation . . . . . .
2.12.3 Tessellation Evaluation Shaders . . . . . . .
Geometry Shaders . . . . . . . . . . . . . . . . . . .
2.13.1 Geometry Shader Input Primitives . . . . . .
2.13.2 Geometry Shader Output Primitives . . . . .
2.13.3 Geometry Shader Variables . . . . . . . . . .
2.13.4 Geometry Shader Execution Environment . .
Coordinate Transformations . . . . . . . . . . . . .
2.14.1 Controlling the Viewport . . . . . . . . . . .
Asynchronous Queries . . . . . . . . . . . . . . . .
Conditional Rendering . . . . . . . . . . . . . . . .
Transform Feedback . . . . . . . . . . . . . . . . .
OpenGL 4.2 (Core Profile) - April 27, 2012
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
ii
43
44
46
48
53
53
53
54
55
55
55
56
58
60
60
65
71
73
77
100
103
104
104
109
117
122
124
125
131
139
144
145
147
147
148
154
154
157
160
161
2.10
2.11
2.12
2.13
2.14
2.15
2.16
2.17
CONTENTS
2.17.1 Transform Feedback Objects . . . . . .
2.17.2 Transform Feedback Primitive Capture
2.17.3 Transform Feedback Draw Operations .
2.18 Primitive Queries . . . . . . . . . . . . . . . .
2.19 Flatshading . . . . . . . . . . . . . . . . . . .
2.20 Primitive Clipping . . . . . . . . . . . . . . . .
2.20.1 Clipping Shader Outputs . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
iii
161
163
167
168
169
170
172
174
175
176
176
177
179
181
182
182
182
182
185
187
187
188
188
190
190
191
192
193
193
194
195
207
208
209
211
213
227
232
239
3 Rasterization
3.1 Discarding Primitives Before Rasterization . . . . . . . .
3.2 Invariance . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.1 Multisampling . . . . . . . . . . . . . . . . . . .
3.4 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4.1 Basic Point Rasterization . . . . . . . . . . . . . .
3.4.2 Point Rasterization State . . . . . . . . . . . . . .
3.4.3 Point Multisample Rasterization . . . . . . . . . .
3.5 Line Segments . . . . . . . . . . . . . . . . . . . . . . .
3.5.1 Basic Line Segment Rasterization . . . . . . . . .
3.5.2 Other Line Segment Features . . . . . . . . . . . .
3.5.3 Line Rasterization State . . . . . . . . . . . . . .
3.5.4 Line Multisample Rasterization . . . . . . . . . .
3.6 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.1 Basic Polygon Rasterization . . . . . . . . . . . .
3.6.2 Antialiasing . . . . . . . . . . . . . . . . . . . . .
3.6.3 Options Controlling Polygon Rasterization . . . .
3.6.4 Depth Offset . . . . . . . . . . . . . . . . . . . .
3.6.5 Polygon Multisample Rasterization . . . . . . . .
3.6.6 Polygon Rasterization State . . . . . . . . . . . .
3.7 Pixel Rectangles . . . . . . . . . . . . . . . . . . . . . . .
3.7.1 Pixel Storage Modes and Pixel Buffer Objects . . .
3.7.2 Transfer of Pixel Rectangles . . . . . . . . . . . .
3.8 Early Per-Fragment Tests . . . . . . . . . . . . . . . . . .
3.9 Texturing . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.1 Texture Objects . . . . . . . . . . . . . . . . . . .
3.9.2 Sampler Objects . . . . . . . . . . . . . . . . . .
3.9.3 Texture Image Specification . . . . . . . . . . . .
3.9.4 Alternate Texture Image Specification Commands
3.9.5 Compressed Texture Images . . . . . . . . . . . .
3.9.6 Multisample Textures . . . . . . . . . . . . . . . .
OpenGL 4.2 (Core Profile) - April 27, 2012
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Zgłoś jeśli naruszono regulamin