
- •Introduction
- •Formatting of Optional Features
- •What is the OpenGL Graphics System?
- •Our View
- •Companion Documents
- •OpenGL Operation
- •OpenGL Fundamentals
- •Floating-Point Computation
- •GL State
- •GL Command Syntax
- •Basic GL Operation
- •GL Errors
- •Begin/End Paradigm
- •Begin and End
- •Polygon Edges
- •GL Commands within Begin/End
- •Vertex Specification
- •Vertex Arrays
- •Buffer Objects
- •Vertex Arrays in Buffer Objects
- •Array Indices in Buffer Objects
- •Rectangles
- •Coordinate Transformations
- •Controlling the Viewport
- •Matrices
- •Normal Transformation
- •Generating Texture Coordinates
- •Clipping
- •Current Raster Position
- •Colors and Coloring
- •Lighting
- •ColorMaterial
- •Lighting State
- •Color Index Lighting
- •Clamping or Masking
- •Flatshading
- •Color and Associated Data Clipping
- •Final Color Processing
- •Vertex Shaders
- •Shader Objects
- •Program Objects
- •Shader Variables
- •Shader Execution
- •Required State
- •Rasterization
- •Invariance
- •Antialiasing
- •Multisampling
- •Points
- •Basic Point Rasterization
- •Point Rasterization State
- •Point Multisample Rasterization
- •Line Segments
- •Basic Line Segment Rasterization
- •Other Line Segment Features
- •Line Rasterization State
- •Line Multisample Rasterization
- •Polygons
- •Basic Polygon Rasterization
- •Stippling
- •Antialiasing
- •Options Controlling Polygon Rasterization
- •Depth Offset
- •Polygon Multisample Rasterization
- •Polygon Rasterization State
- •Pixel Rectangles
- •Pixel Storage Modes
- •The Imaging Subset
- •Pixel Transfer Modes
- •Rasterization of Pixel Rectangles
- •Pixel Transfer Operations
- •Pixel Rectangle Multisample Rasterization
- •Bitmaps
- •Texturing
- •Compressed Texture Images
- •Texture Parameters
- •Depth Component Textures
- •Cube Map Texture Selection
- •Texture Wrap Modes
- •Texture Completeness
- •Texture State and Proxy State
- •Texture Objects
- •Texture Environments and Texture Functions
- •Texture Comparison Modes
- •Texture Application
- •Color Sum
- •Fragment Shaders
- •Shader Variables
- •Shader Execution
- •Antialiasing Application
- •Multisample Point Fade
- •Per-Fragment Operations
- •Pixel Ownership Test
- •Scissor Test
- •Multisample Fragment Operations
- •Alpha Test
- •Stencil Test
- •Depth Buffer Test
- •Occlusion Queries
- •Blending
- •Dithering
- •Logical Operation
- •Additional Multisample Fragment Operations
- •Whole Framebuffer Operations
- •Selecting a Buffer for Writing
- •Fine Control of Buffer Updates
- •Clearing the Buffers
- •The Accumulation Buffer
- •Drawing, Reading, and Copying Pixels
- •Writing to the Stencil Buffer
- •Reading Pixels
- •Copying Pixels
- •Pixel Draw/Read State
- •Special Functions
- •Evaluators
- •Selection
- •Feedback
- •Display Lists
- •Flush and Finish
- •Hints
- •State and State Requests
- •Querying GL State
- •Simple Queries
- •Data Conversions
- •Enumerated Queries
- •Texture Queries
- •Stipple Query
- •Color Matrix Query
- •Color Table Query
- •Convolution Query
- •Histogram Query
- •Minmax Query
- •Pointer and String Queries
- •Occlusion Queries
- •Buffer Object Queries
- •Shader and Program Queries
- •Saving and Restoring State
- •State Tables
- •Invariance
- •Corollaries
- •Version 1.1
- •Version 1.2
- •Imaging Subset
- •Version 1.2.1
- •Version 1.3
- •Version 1.4
- •Fog Coordinate
- •Texture LOD Bias
- •Version 1.5
- •Version 2.0
- •ARB Extensions
- •Texture Mirrored Repeat
- •OpenGL Shading Language
The OpenGL R Graphics System:
A Specification
(Version 2.0 - October 22, 2004)
Mark Segal
Kurt Akeley
Editor (version 1.1): Chris Frazier
Editor (versions 1.2-1.5): Jon Leech Editors (version 2.0): Jon Leech and Pat Brown
Copyright c 1992-2004 Silicon Graphics, Inc.
This document contains unpublished information of
Silicon Graphics, Inc.
This document is protected by copyright, and contains information proprietary to Silicon Graphics, Inc. Any copying, adaptation, distribution, public performance, or public display of this document without the express written consent of Silicon Graphics, Inc. is strictly prohibited. The receipt or possession of this document 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.
U.S. Government Restricted Rights Legend
Use, duplication, or disclosure by the Government is subject to restrictions set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or in similar or successor clauses in the FAR or the DOD or NASA FAR Supplement. Unpublished rights reserved under the copyright laws of the United States. Contractor/manufacturer is Silicon Graphics, Inc., 1600 Amphitheatre Parkway, Mountain View, CA 94043.
OpenGL is a registered trademark of Silicon Graphics, Inc.
Unix is a registered trademark of The Open Group.
The ”X” device and X Windows System are trademarks of
The Open Group.
Contents
1 Introduction |
1 |
|
1.1 |
Formatting of Optional Features . . . . . . . . . . . . . . . . . . |
1 |
1.2 |
What is the OpenGL Graphics System? . . . . . . . . . . . . . . |
1 |
1.3 |
Programmer’s View of OpenGL . . . . . . . . . . . . . . . . . . |
2 |
1.4 |
Implementor’s View of OpenGL . . . . . . . . . . . . . . . . . . |
2 |
1.5 |
Our View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
3 |
1.6 |
Companion Documents . . . . . . . . . . . . . . . . . . . . . . . |
3 |
2 OpenGL Operation |
4 |
||
2.1 |
OpenGL Fundamentals . . . . . . . . . . . . . . . . . . . . . . . |
4 |
|
|
2.1.1 |
Floating-Point Computation . . . . . . . . . . . . . . . . |
6 |
2.2 |
GL State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
6 |
|
2.3 |
GL Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . |
7 |
|
2.4 |
Basic GL Operation . . . . . . . . . . . . . . . . . . . . . . . . . |
10 |
|
2.5 |
GL Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
11 |
|
2.6 |
Begin/End Paradigm . . . . . . . . . . . . . . . . . . . . . . . . |
12 |
|
|
2.6.1 |
Begin and End . . . . . . . . . . . . . . . . . . . . . . . |
15 |
|
2.6.2 |
Polygon Edges . . . . . . . . . . . . . . . . . . . . . . . |
19 |
2.6.3GL Commands within Begin/End . . . . . . . . . . . . . 19
2.7 |
Vertex Specification . . . . . . . . . . . . . . . . . . . . . . . . . |
20 |
|
2.8 |
Vertex Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
23 |
|
2.9 |
Buffer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
33 |
|
|
2.9.1 |
Vertex Arrays in Buffer Objects . . . . . . . . . . . . . . |
38 |
|
2.9.2 |
Array Indices in Buffer Objects . . . . . . . . . . . . . . |
39 |
2.10 |
Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
39 |
|
2.11 |
Coordinate Transformations . . . . . . . . . . . . . . . . . . . . |
40 |
|
|
2.11.1 |
Controlling the Viewport . . . . . . . . . . . . . . . . . . |
41 |
|
2.11.2 |
Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . |
42 |
|
2.11.3 |
Normal Transformation . . . . . . . . . . . . . . . . . . . |
48 |
i
CONTENTS |
|
ii |
|
|
2.11.4 |
Generating Texture Coordinates . . . . . . . . . . . . . . |
49 |
2.12 Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
52 |
||
2.13 |
Current Raster Position . . . . . . . . . . . . . . . . . . . . . . . |
54 |
|
2.14 Colors and Coloring . . . . . . . . . . . . . . . . . . . . . . . . . |
57 |
||
|
2.14.1 |
Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . |
59 |
|
2.14.2 |
Lighting Parameter Specification . . . . . . . . . . . . . . |
64 |
|
2.14.3 |
ColorMaterial . . . . . . . . . . . . . . . . . . . . . . . |
66 |
|
2.14.4 |
Lighting State . . . . . . . . . . . . . . . . . . . . . . . . |
68 |
|
2.14.5 |
Color Index Lighting . . . . . . . . . . . . . . . . . . . . |
68 |
|
2.14.6 |
Clamping or Masking . . . . . . . . . . . . . . . . . . . |
69 |
|
2.14.7 |
Flatshading . . . . . . . . . . . . . . . . . . . . . . . . . |
69 |
|
2.14.8 |
Color and Associated Data Clipping . . . . . . . . . . . . |
70 |
|
2.14.9 |
Final Color Processing . . . . . . . . . . . . . . . . . . . |
71 |
2.15 |
Vertex Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . . |
71 |
|
|
2.15.1 |
Shader Objects . . . . . . . . . . . . . . . . . . . . . . . |
72 |
|
2.15.2 |
Program Objects . . . . . . . . . . . . . . . . . . . . . . |
73 |
|
2.15.3 |
Shader Variables . . . . . . . . . . . . . . . . . . . . . . |
75 |
|
2.15.4 |
Shader Execution . . . . . . . . . . . . . . . . . . . . . . |
84 |
|
2.15.5 |
Required State . . . . . . . . . . . . . . . . . . . . . . . |
88 |
3 Rasterization |
90 |
3.1Invariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.2Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.2.1 |
Multisampling . . . . . . . . . . . . . . . . . . . . . . . |
93 |
3.3 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
95 |
|
3.3.1 |
Basic Point Rasterization . . . . . . . . . . . . . . . . . . |
97 |
3.3.2Point Rasterization State . . . . . . . . . . . . . . . . . . 101
3.3.3Point Multisample Rasterization . . . . . . . . . . . . . . 101
3.4 Line Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . |
101 |
3.4.1 Basic Line Segment Rasterization . . . . . . . . . . . . . |
102 |
3.4.2Other Line Segment Features . . . . . . . . . . . . . . . . 104
3.4.3 |
Line Rasterization State . . . . . . . . . . . . . . . . . . |
107 |
3.4.4 |
Line Multisample Rasterization . . . . . . . . . . . . . . |
107 |
3.5 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
108 |
|
3.5.1 |
Basic Polygon Rasterization . . . . . . . . . . . . . . . . |
108 |
3.5.2 |
Stippling . . . . . . . . . . . . . . . . . . . . . . . . . . |
110 |
3.5.3Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . 111
3.5.4 |
Options Controlling Polygon Rasterization . . . . . . . . |
111 |
3.5.5 |
Depth Offset . . . . . . . . . . . . . . . . . . . . . . . . |
111 |
3.5.6 |
Polygon Multisample Rasterization . . . . . . . . . . . . |
113 |
Version 2.0 - October 22, 2004
CONTENTS |
iii |
3.5.7 |
Polygon Rasterization State . . . . . . . . . . . . . . . . 113 |
3.6Pixel Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.6.1 |
Pixel Storage Modes . . . . . . . . . . . . . . . . . . . . |
114 |
3.6.2 |
The Imaging Subset . . . . . . . . . . . . . . . . . . . . |
114 |
3.6.3Pixel Transfer Modes . . . . . . . . . . . . . . . . . . . . 116
3.6.4 |
Rasterization of Pixel Rectangles . . . . . . . . . . . . . |
126 |
3.6.5 |
Pixel Transfer Operations . . . . . . . . . . . . . . . . . |
137 |
3.6.6 |
Pixel Rectangle Multisample Rasterization . . . . . . . . |
147 |
3.7Bitmaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
3.8 Texturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
149 |
|
3.8.1 |
Texture Image Specification . . . . . . . . . . . . . . . . |
150 |
3.8.2 |
Alternate Texture Image Specification Commands . . . . |
158 |
3.8.3Compressed Texture Images . . . . . . . . . . . . . . . . 163
3.8.4Texture Parameters . . . . . . . . . . . . . . . . . . . . . 166
3.8.5 Depth Component Textures . . . . . . . . . . . . . . . . 168
3.8.6Cube Map Texture Selection . . . . . . . . . . . . . . . . 168
3.8.7Texture Wrap Modes . . . . . . . . . . . . . . . . . . . . 169
3.8.8 |
Texture Minification . . . . . . . . . . . . . . . . . . . . |
170 |
3.8.9 |
Texture Magnification . . . . . . . . . . . . . . . . . . . |
176 |
3.8.10 |
Texture Completeness . . . . . . . . . . . . . . . . . . . |
177 |
3.8.11 |
Texture State and Proxy State . . . . . . . . . . . . . . . |
178 |
3.8.12 |
Texture Objects . . . . . . . . . . . . . . . . . . . . . . . |
180 |
3.8.13 |
Texture Environments and Texture Functions . . . . . . . |
182 |
3.8.14 |
Texture Comparison Modes . . . . . . . . . . . . . . . . |
185 |
3.8.15 Texture Application . . . . . . . . . . . . . . . . . . . . . 189
3.9Color Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
3.10 |
Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
191 |
|
3.11 |
Fragment Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . |
193 |
|
|
3.11.1 |
Shader Variables . . . . . . . . . . . . . . . . . . . . . . |
193 |
|
3.11.2 |
Shader Execution . . . . . . . . . . . . . . . . . . . . . . |
194 |
3.12 |
Antialiasing Application . . . . . . . . . . . . . . . . . . . . . . |
197 |
|
3.13 |
Multisample Point Fade . . . . . . . . . . . . . . . . . . . . . . . |
197 |
|
4 Per-Fragment Operations and the Framebuffer |
198 |
4.1Per-Fragment Operations . . . . . . . . . . . . . . . . . . . . . . 199
4.1.1Pixel Ownership Test . . . . . . . . . . . . . . . . . . . . 199
4.1.2Scissor Test . . . . . . . . . . . . . . . . . . . . . . . . . 200
4.1.3Multisample Fragment Operations . . . . . . . . . . . . . 200
4.1.4 Alpha Test . . . . . . . . . . . . . . . . . . . . . . . . . 201
4.1.5Stencil Test . . . . . . . . . . . . . . . . . . . . . . . . . 202
Version 2.0 - October 22, 2004
CONTENTS |
iv |
4.1.6Depth Buffer Test . . . . . . . . . . . . . . . . . . . . . . 203
4.1.7 |
Occlusion Queries . . . . . . . . . . . . . . . . . . . . . |
204 |
4.1.8 |
Blending . . . . . . . . . . . . . . . . . . . . . . . . . . |
206 |
4.1.9Dithering . . . . . . . . . . . . . . . . . . . . . . . . . . 210
4.1.10 Logical Operation . . . . . . . . . . . . . . . . . . . . . 210
4.1.11 Additional Multisample Fragment Operations . . . . . . . 211
4.2Whole Framebuffer Operations . . . . . . . . . . . . . . . . . . . 212
4.2.1 |
Selecting a Buffer for Writing . . . . . . . . . . . . . . . |
212 |
4.2.2 |
Fine Control of Buffer Updates . . . . . . . . . . . . . . |
215 |
4.2.3 |
Clearing the Buffers . . . . . . . . . . . . . . . . . . . . |
216 |
4.2.4 |
The Accumulation Buffer . . . . . . . . . . . . . . . . . |
217 |
4.3Drawing, Reading, and Copying Pixels . . . . . . . . . . . . . . . 219
4.3.1Writing to the Stencil Buffer . . . . . . . . . . . . . . . . 219
4.3.2 |
Reading Pixels . . . . . . . . . . . . . . . . . . . . . . . |
219 |
4.3.3 |
Copying Pixels . . . . . . . . . . . . . . . . . . . . . . . |
223 |
4.3.4 |
Pixel Draw/Read State . . . . . . . . . . . . . . . . . . . |
226 |
5 Special Functions |
227 |
5.1Evaluators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
5.2 |
Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
233 |
5.3 |
Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
235 |
5.4 |
Display Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
237 |
5.5Flush and Finish . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
5.6Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
6 State and State Requests |
244 |
6.1 Querying GL State . . . . . . . . . . . . . . . . . . . . . . . . . |
244 |
6.1.1Simple Queries . . . . . . . . . . . . . . . . . . . . . . . 244
6.1.2Data Conversions . . . . . . . . . . . . . . . . . . . . . . 245
6.1.3 Enumerated Queries . . . . . . . . . . . . . . . . . . . . 246
6.1.4Texture Queries . . . . . . . . . . . . . . . . . . . . . . . 248
6.1.5Stipple Query . . . . . . . . . . . . . . . . . . . . . . . . 250
6.1.6Color Matrix Query . . . . . . . . . . . . . . . . . . . . . 250
6.1.7 Color Table Query . . . . . . . . . . . . . . . . . . . . . 250
6.1.8Convolution Query . . . . . . . . . . . . . . . . . . . . . 251
6.1.9Histogram Query . . . . . . . . . . . . . . . . . . . . . . 252
6.1.10Minmax Query . . . . . . . . . . . . . . . . . . . . . . . 252
6.1.11Pointer and String Queries . . . . . . . . . . . . . . . . . 253
6.1.12 |
Occlusion Queries . . . . . . . . . . . . . . . . . . . . . |
254 |
6.1.13 |
Buffer Object Queries . . . . . . . . . . . . . . . . . . . |
255 |
Version 2.0 - October 22, 2004
CONTENTS |
v |
6.1.14Shader and Program Queries . . . . . . . . . . . . . . . . 256
6.1.15Saving and Restoring State . . . . . . . . . . . . . . . . . 260
|
6.2 |
State Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
264 |
|
A |
Invariance |
|
299 |
|
|
A.1 |
Repeatability . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
299 |
|
|
A.2 |
Multi-pass Algorithms . . . . . . . . . . . . . . . . . . . . . . . |
300 |
|
|
A.3 |
Invariance Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . |
300 |
|
|
A.4 |
What All This Means . . . . . . . . . . . . . . . . . . . . . . . . |
302 |
|
B |
Corollaries |
|
303 |
|
C |
Version 1.1 |
|
306 |
|
|
C.1 |
Vertex Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
306 |
|
|
C.2 |
Polygon Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . |
307 |
|
|
C.3 |
Logical Operation . . . . . . . . . . . . . . . . . . . . . . . . . . |
307 |
|
|
C.4 |
Texture Image Formats . . . . . . . . . . . . . . . . . . . . . . . |
307 |
|
|
C.5 |
Texture Replace Environment . . . . . . . . . . . . . . . . . . . . |
307 |
|
|
C.6 |
Texture Proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . |
308 |
|
|
C.7 |
Copy Texture and Subtexture . . . . . . . . . . . . . . . . . . . . |
308 |
|
|
C.8 |
Texture Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . |
308 |
|
|
C.9 |
Other Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . |
308 |
|
|
C.10 |
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . |
309 |
|
D |
Version 1.2 |
|
311 |
|
|
D.1 |
Three-Dimensional Texturing . . . . . . . . . . . . . . . . . . . . |
311 |
|
|
D.2 |
BGRA Pixel Formats . . . . . . . . . . . . . . . . . . . . . . . . |
311 |
|
|
D.3 |
Packed Pixel Formats . . . . . . . . . . . . . . . . . . . . . . . . |
312 |
|
|
D.4 |
Normal Rescaling . . . . . . . . . . . . . . . . . . . . . . . . . . |
312 |
|
|
D.5 |
Separate Specular Color . . . . . . . . . . . . . . . . . . . . . . |
312 |
|
|
D.6 |
Texture Coordinate Edge Clamping . . . . . . . . . . . . . . . . |
312 |
|
|
D.7 |
Texture Level of Detail Control . . . . . . . . . . . . . . . . . . . |
313 |
|
|
D.8 |
Vertex Array Draw Element Range . . . . . . . . . . . . . . . . . |
313 |
|
|
D.9 |
Imaging Subset . . . . . . . . . . . . . . . . . . . . . . . . . . . |
313 |
|
|
|
D.9.1 |
Color Tables . . . . . . . . . . . . . . . . . . . . . . . . |
313 |
|
|
D.9.2 Convolution . . . . . . . . . . . . . . . . . . . . . . . . . |
314 |
|
|
|
D.9.3 |
Color Matrix . . . . . . . . . . . . . . . . . . . . . . . . |
314 |
|
|
D.9.4 Pixel Pipeline Statistics . . . . . . . . . . . . . . . . . . . |
315 |
|
|
|
D.9.5 Constant Blend Color . . . . . . . . . . . . . . . . . . . . |
315 |
|
|
|
D.9.6 |
New Blending Equations . . . . . . . . . . . . . . . . . . |
315 |
Version 2.0 - October 22, 2004
CONTENTS |
vi |
||
|
D.10 |
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . |
315 |
E |
Version 1.2.1 |
319 |
|
F |
Version 1.3 |
320 |
|
|
F.1 |
Compressed Textures . . . . . . . . . . . . . . . . . . . . . . . . |
320 |
|
F.2 |
Cube Map Textures . . . . . . . . . . . . . . . . . . . . . . . . . |
320 |
|
F.3 |
Multisample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
321 |
|
F.4 |
Multitexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
321 |
|
F.5 |
Texture Add Environment Mode . . . . . . . . . . . . . . . . . . |
322 |
|
F.6 |
Texture Combine Environment Mode . . . . . . . . . . . . . . . |
322 |
|
F.7 |
Texture Dot3 Environment Mode . . . . . . . . . . . . . . . . . . |
322 |
|
F.8 |
Texture Border Clamp . . . . . . . . . . . . . . . . . . . . . . . |
322 |
|
F.9 |
Transpose Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . |
323 |
|
F.10 |
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . |
323 |
G |
Version 1.4 |
328 |
|
|
G.1 |
Automatic Mipmap Generation . . . . . . . . . . . . . . . . . . . |
328 |
|
G.2 |
Blend Squaring . . . . . . . . . . . . . . . . . . . . . . . . . . . |
328 |
|
G.3 |
Changes to the Imaging Subset . . . . . . . . . . . . . . . . . . . |
329 |
|
G.4 |
Depth Textures and Shadows . . . . . . . . . . . . . . . . . . . . |
329 |
|
G.5 |
Fog Coordinate . . . . . . . . . . . . . . . . . . . . . . . . . . . |
329 |
|
G.6 |
Multiple Draw Arrays . . . . . . . . . . . . . . . . . . . . . . . . |
329 |
|
G.7 |
Point Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . |
330 |
|
G.8 |
Secondary Color . . . . . . . . . . . . . . . . . . . . . . . . . . |
330 |
|
G.9 |
Separate Blend Functions . . . . . . . . . . . . . . . . . . . . . . |
330 |
|
G.10 |
Stencil Wrap . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
330 |
|
G.11 |
Texture Crossbar Environment Mode . . . . . . . . . . . . . . . . |
330 |
|
G.12 |
Texture LOD Bias . . . . . . . . . . . . . . . . . . . . . . . . . . |
331 |
|
G.13 |
Texture Mirrored Repeat . . . . . . . . . . . . . . . . . . . . . . |
331 |
|
G.14 |
Window Raster Position . . . . . . . . . . . . . . . . . . . . . . |
331 |
|
G.15 |
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . |
331 |
H |
Version 1.5 |
334 |
|
|
H.1 |
Buffer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
334 |
|
H.2 |
Occlusion Queries . . . . . . . . . . . . . . . . . . . . . . . . . . |
335 |
|
H.3 |
Shadow Functions . . . . . . . . . . . . . . . . . . . . . . . . . . |
335 |
|
H.4 |
Changed Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . |
335 |
|
H.5 |
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . |
335 |
Version 2.0 - October 22, 2004
CONTENTS |
|
vii |
||
I |
Version 2.0 |
|
340 |
|
|
I.1 |
Programmable Shading . . . . . . . . . . . . . . . . . . . . . . . |
340 |
|
|
|
I.1.1 |
Shader Objects . . . . . . . . . . . . . . . . . . . . . . . |
340 |
|
|
I.1.2 |
Shader Programs . . . . . . . . . . . . . . . . . . . . . . |
340 |
|
|
I.1.3 |
OpenGL Shading Language . . . . . . . . . . . . . . . . |
341 |
|
|
I.1.4 Changes To Shader APIs . . . . . . . . . . . . . . . . . . |
341 |
|
|
I.2 |
Multiple Render Targets . . . . . . . . . . . . . . . . . . . . . . |
341 |
|
|
I.3 |
Non-Power-Of-Two Textures . . . . . . . . . . . . . . . . . . . . |
341 |
|
|
I.4 |
Point Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
342 |
|
|
I.5 |
Separate Stencil . . . . . . . . . . . . . . . . . . . . . . . . . . . |
342 |
|
|
I.6 |
Other Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . |
342 |
|
|
I.7 |
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . |
343 |
|
J |
ARB Extensions |
345 |
||
|
J.1 |
Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . |
345 |
|
|
J.2 |
Promoting Extensions to Core Features . . . . . . . . . . . . . . |
346 |
|
|
J.3 |
Multitexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
346 |
|
|
J.4 |
Transpose Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . |
346 |
|
|
J.5 |
Multisample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
346 |
|
|
J.6 |
Texture Add Environment Mode . . . . . . . . . . . . . . . . . . |
346 |
|
|
J.7 |
Cube Map Textures . . . . . . . . . . . . . . . . . . . . . . . . . |
347 |
|
|
J.8 |
Compressed Textures . . . . . . . . . . . . . . . . . . . . . . . . |
347 |
|
|
J.9 |
Texture Border Clamp . . . . . . . . . . . . . . . . . . . . . . . |
347 |
|
|
J.10 |
Point Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . |
347 |
|
|
J.11 |
Vertex Blend . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
347 |
|
|
J.12 |
Matrix Palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
347 |
|
|
J.13 |
Texture Combine Environment Mode . . . . . . . . . . . . . . . |
348 |
|
|
J.14 |
Texture Crossbar Environment Mode . . . . . . . . . . . . . . . . |
348 |
|
|
J.15 |
Texture Dot3 Environment Mode . . . . . . . . . . . . . . . . . . |
348 |
|
|
J.16 |
Texture Mirrored Repeat . . . . . . . . . . . . . . . . . . . . . . |
348 |
|
|
J.17 |
Depth Texture . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
348 |
|
|
J.18 |
Shadow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
348 |
|
|
J.19 |
Shadow Ambient . . . . . . . . . . . . . . . . . . . . . . . . . . |
348 |
|
|
J.20 |
Window Raster Position . . . . . . . . . . . . . . . . . . . . . . |
349 |
|
|
J.21 |
Low-Level Vertex Programming . . . . . . . . . . . . . . . . . . |
349 |
|
|
J.22 |
Low-Level Fragment Programming . . . . . . . . . . . . . . . . |
349 |
|
|
J.23 |
Buffer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
349 |
|
|
J.24 |
Occlusion Queries . . . . . . . . . . . . . . . . . . . . . . . . . . |
349 |
|
|
J.25 |
Shader Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . |
349 |
|
|
J.26 |
High-Level Vertex Programming . . . . . . . . . . . . . . . . . . |
350 |
Version 2.0 - October 22, 2004
CONTENTS |
viii |
|
J.27 |
High-Level Fragment Programming . . . . . . . . . . . . . . . . |
350 |
J.28 |
OpenGL Shading Language . . . . . . . . . . . . . . . . . . . . |
350 |
J.29 |
Non-Power-Of-Two Textures . . . . . . . . . . . . . . . . . . . . |
350 |
J.30 |
Point Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
350 |
J.31 |
Fragment Program Shadow . . . . . . . . . . . . . . . . . . . . . |
350 |
J.32 |
Multiple Render Targets . . . . . . . . . . . . . . . . . . . . . . |
351 |
J.33 |
Rectangular Textures . . . . . . . . . . . . . . . . . . . . . . . . |
351 |
Version 2.0 - October 22, 2004
List of Figures
2.1 Block diagram of the GL. . . . . . . . . . . . . . . . . . . . . . . 10
2.2Creation of a processed vertex from a transformed vertex and cur-
|
rent values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
13 |
2.3 |
Primitive assembly and processing. . . . . . . . . . . . . . . . . . |
13 |
2.4 |
Triangle strips, fans, and independent triangles. . . . . . . . . . . |
16 |
2.5 |
Quadrilateral strips and independent quadrilaterals. . . . . . . . . |
18 |
2.6 |
Vertex transformation sequence. . . . . . . . . . . . . . . . . . . |
40 |
2.7 |
Current raster position. . . . . . . . . . . . . . . . . . . . . . . . |
55 |
2.8 |
Processing of RGBA colors. . . . . . . . . . . . . . . . . . . . . |
57 |
2.9 |
Processing of color indices. . . . . . . . . . . . . . . . . . . . . . |
57 |
2.10 |
ColorMaterial operation. . . . . . . . . . . . . . . . . . . . . . . |
66 |
3.1Rasterization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.2 |
Rasterization of non-antialiased wide points. . . . . . . . . . . . . |
97 |
3.3 |
Rasterization of antialiased wide points. . . . . . . . . . . . . . . |
97 |
3.4Visualization of Bresenham’s algorithm. . . . . . . . . . . . . . . 102
3.5Rasterization of non-antialiased wide lines. . . . . . . . . . . . . 105
3.6The region used in rasterizing an antialiased line segment. . . . . 106
3.7Operation of DrawPixels. . . . . . . . . . . . . . . . . . . . . . 126
3.8Selecting a subimage from an image . . . . . . . . . . . . . . . . 130
3.9A bitmap and its associated parameters. . . . . . . . . . . . . . . 148
3.10A texture image and the coordinates used to access it. . . . . . . . 158
3.11Multitexture pipeline. . . . . . . . . . . . . . . . . . . . . . . . . 190
4.1Per-fragment operations. . . . . . . . . . . . . . . . . . . . . . . 199
4.2Operation of ReadPixels. . . . . . . . . . . . . . . . . . . . . . . 219
4.3Operation of CopyPixels. . . . . . . . . . . . . . . . . . . . . . . 223
5.1Map Evaluation. . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
5.2Feedback syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . 238
ix

List of Tables
2.1 |
GL command suffixes . . . . . . . . . . . . . . . . . . . . . . . . |
8 |
2.2 |
GL data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
9 |
2.3 |
Summary of GL errors . . . . . . . . . . . . . . . . . . . . . . . |
12 |
2.4 |
Vertex array sizes (values per vertex) and data types . . . . . . . . |
25 |
2.5 |
Variables that direct the execution of InterleavedArrays. . . . . . |
32 |
2.6 |
Buffer object parameters and their values. . . . . . . . . . . . . . |
34 |
2.7 |
Buffer object initial state. . . . . . . . . . . . . . . . . . . . . . . |
36 |
2.8 |
Buffer object state set by MapBuffer. . . . . . . . . . . . . . . . |
37 |
2.9 |
Component conversions . . . . . . . . . . . . . . . . . . . . . . . |
59 |
2.10 |
Summary of lighting parameters. . . . . . . . . . . . . . . . . . . |
61 |
2.11 |
Correspondence of lighting parameter symbols to names. . . . . . |
65 |
2.12 |
Polygon flatshading color selection. . . . . . . . . . . . . . . . . |
70 |
3.1PixelStore parameters. . . . . . . . . . . . . . . . . . . . . . . . 115
3.2PixelTransfer parameters. . . . . . . . . . . . . . . . . . . . . . 116
3.3PixelMap parameters. . . . . . . . . . . . . . . . . . . . . . . . 117
3.4Color table names. . . . . . . . . . . . . . . . . . . . . . . . . . 118
3.5DrawPixels and ReadPixels types. . . . . . . . . . . . . . . . . . 128
3.6DrawPixels and ReadPixels formats. . . . . . . . . . . . . . . . 129
3.7Swap Bytes bit ordering. . . . . . . . . . . . . . . . . . . . . . . 130
3.8Packed pixel formats. . . . . . . . . . . . . . . . . . . . . . . . . 131
3.9UNSIGNED BYTE formats. Bit numbers are indicated for each com-
ponent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
132 |
3.10 UNSIGNED SHORT formats . . . . . . . . . . . . . . . . . . . . . |
133 |
3.11UNSIGNED INT formats . . . . . . . . . . . . . . . . . . . . . . . 134
3.12Packed pixel field assignments. . . . . . . . . . . . . . . . . . . . 135
3.13Color table lookup. . . . . . . . . . . . . . . . . . . . . . . . . . 140
3.14Computation of filtered color components. . . . . . . . . . . . . . 141
x

LIST OF TABLES |
xi |
3.15Conversion from RGBA and depth pixel components to internal texture, table, or filter components. . . . . . . . . . . . . . . . . . 153
3.16Correspondence of sized internal formats to base internal formats. 154
3.17Specific compressed internal formats. . . . . . . . . . . . . . . . 155
3.18Generic compressed internal formats. . . . . . . . . . . . . . . . 155
3.19Texture parameters and their values. . . . . . . . . . . . . . . . . 167
3.20Selection of cube map images. . . . . . . . . . . . . . . . . . . . 168
3.21Correspondence of filtered texture components. . . . . . . . . . . 184
3.22Texture functions REPLACE, MODULATE, and DECAL . . . . . . . . 184
3.23Texture functions BLEND and ADD. . . . . . . . . . . . . . . . . . 185
3.24COMBINE texture functions. . . . . . . . . . . . . . . . . . . . . . 186
3.25Arguments for COMBINE RGB functions. . . . . . . . . . . . . . . 187
3.26Arguments for COMBINE ALPHA functions. . . . . . . . . . . . . 187
3.27Depth texture comparison functions. . . . . . . . . . . . . . . . . 188
4.1RGB and Alpha blend equations. . . . . . . . . . . . . . . . . . . 207
4.2Blending functions. . . . . . . . . . . . . . . . . . . . . . . . . . 209
4.3Arguments to LogicOp and their corresponding operations. . . . . 211
4.4Arguments to DrawBuffer and the buffers that they indicate. . . . 213
4.5PixelStore parameters. . . . . . . . . . . . . . . . . . . . . . . . 221
4.6ReadPixels index masks. . . . . . . . . . . . . . . . . . . . . . . 223
4.7ReadPixels GL data types and reversed component conversion formulas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
5.1Values specified by the target to Map1. . . . . . . . . . . . . . . 228
5.2Correspondence of feedback type to number of values per vertex. . 237
5.3 Hint targets and descriptions . . . . . . . . . . . . . . . . . . . . 243
6.1Texture, table, and filter return values. . . . . . . . . . . . . . . . 249
6.2Attribute groups . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
6.3State Variable Types . . . . . . . . . . . . . . . . . . . . . . . . . 263
6.4GL Internal begin-end state variables (inaccessible) . . . . . . . . 265
6.5 Current Values and Associated Data . . . . . . . . . . . . . . . . 266
6.6Vertex Array Data . . . . . . . . . . . . . . . . . . . . . . . . . . 267
6.7Vertex Array Data (cont.) . . . . . . . . . . . . . . . . . . . . . . 268
6.8 |
Buffer Object State . . . . . . . . . . . . . . . . . . . . . . . . . |
269 |
6.9 |
Transformation state . . . . . . . . . . . . . . . . . . . . . . . . |
270 |
6.10 |
Coloring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
271 |
6.11 |
Lighting (see also table 2.10 for defaults) . . . . . . . . . . . . . |
272 |
6.12 |
Lighting (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . |
273 |
Version 2.0 - October 22, 2004
LIST OF TABLES |
xii |
6.13 Rasterization |
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 |
6.14Multisampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
6.15Textures (state per texture unit and binding point) . . . . . . . . . 276
6.16Textures (state per texture object) . . . . . . . . . . . . . . . . . . 277
6.17Textures (state per texture image) . . . . . . . . . . . . . . . . . . 278
6.18Texture Environment and Generation . . . . . . . . . . . . . . . . 279
6.19Pixel Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
6.20Pixel Operations (cont.) . . . . . . . . . . . . . . . . . . . . . . . 281
6.21 |
Framebuffer Control . . . . . . . . . . . . . . . . . . . . . . . . |
282 |
6.22 |
Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
283 |
6.23 |
Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
284 |
6.24 |
Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
285 |
6.25 |
Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
286 |
6.26 |
Pixels (cont.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
287 |
6.27Evaluators (GetMap takes a map name) . . . . . . . . . . . . . . 288
6.28Shader Object State . . . . . . . . . . . . . . . . . . . . . . . . . 289
6.29Program Object State . . . . . . . . . . . . . . . . . . . . . . . . 290
6.30Vertex Shader State . . . . . . . . . . . . . . . . . . . . . . . . . 291
6.31Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
6.32Implementation Dependent Values . . . . . . . . . . . . . . . . . 293
6.33 |
Implementation Dependent Values (cont.) . . . . . . . . . . . . . |
294 |
6.34 |
Implementation Dependent Values (cont.) . . . . . . . . . . . . . |
295 |
6.35 |
Implementation Dependent Values (cont.) . . . . . . . . . . . . . |
296 |
6.36Implementation Dependent Pixel Depths . . . . . . . . . . . . . . 297
6.37Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
H.1 New token names . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Version 2.0 - October 22, 2004

Chapter 1
Introduction
This document 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 as well as familiarity with basic graphics hardware and associated terms.
1.1Formatting of Optional Features
Starting with version 1.2 of OpenGL, some features in the specification are considered optional; an OpenGL implementation may or may not choose to provide them (see section 3.6.2).
Portions of the specification which are optional are so described where the optional features are first defined (see section 3.6.2). State table entries which are optional are typeset against a gray background .
1.2What is the OpenGL Graphics System?
OpenGL (for “Open Graphics Library”) is a software interface to graphics hardware. The interface consists of a set of several hundred procedures and functions that allow a programmer to specify the 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 pertain to drawing objects such as points, lines, polygons, and bitmaps, but the way that some of this drawing occurs (such as when antialiasing
1
1.3. PROGRAMMER’S VIEW OF OPENGL |
2 |
or texturing is enabled) relies on the existence of a framebuffer. Further, some of OpenGL is specifically concerned with framebuffer manipulation.
1.3Programmer’s View of OpenGL
To the programmer, OpenGL is a set of commands that allow the specification of geometric objects in two or three dimensions, together with commands that control how these objects are rendered into the framebuffer. For the most part, OpenGL provides an immediate-mode interface, meaning that specifying an object causes it to be drawn.
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 a GL context and associate it with the window. Once a GL context is allocated, the programmer is free to issue OpenGL commands. Some calls are used to draw simple geometric objects (i.e. points, line segments, and polygons), while others affect the rendering of these primitives including how they are lit or colored and how they are mapped from the user’s twoor three-dimensional model space to the two-dimensional screen. There are also calls to effect direct control of the framebuffer, such as reading and writing pixels.
1.4Implementor’s View of OpenGL
To the implementor, OpenGL is a set of commands that affect the operation of graphics hardware. If the hardware consists only of an addressable framebuffer, then OpenGL must be implemented almost entirely on the host CPU. More typically, the graphics hardware may comprise varying degrees of graphics acceleration, from a raster subsystem capable of rendering two-dimensional lines and polygons to sophisticated floating-point processors capable of transforming and computing on geometric data. The OpenGL implementor’s task is to provide the CPU software interface while dividing the work for each OpenGL command between the CPU and the graphics hardware. This division must be tailored to the available graphics hardware to obtain optimum performance in carrying out OpenGL calls.
OpenGL maintains a considerable amount of state information. This state controls how objects are drawn into the framebuffer. Some of this state is directly available to the user: he or she can make calls to obtain its value. Some of it, however, is visible only by the effect it has on what is drawn. One of the main goals of this specification is to make OpenGL state information explicit, to elucidate how it changes, and to indicate what its effects are.
Version 2.0 - October 22, 2004
1.5. OUR VIEW |
3 |
1.5Our View
We view OpenGL as a state machine that controls a set of specific drawing operations. 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.6Companion Documents
This 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 semantics of the programming language used to write vertex and fragment shaders (see sections 2.15 and 3.11). These sections may include references to concepts and terms (such as shading language variable types) defined in the companion document.
OpenGL 2.0 implementations are guaranteed to support at least version 1.10 of the shading language; the actual version supported may be queried as described in section 6.1.11.
Version 2.0 - October 22, 2004