The OpenGL
R
Graphics System:
A Specification
(Version 1.5)
Mark Segal
Kurt Akeley
Editor (version 1.1): Chris Frazier
Editor (versions 1.2, 1.2.1, 1.3, 1.4, 1.5): Jon Leech
Copyright
c
1992-2003 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 succes-
sor 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
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 Objects . . . . . . . . . . . . . . . . . . . 13
2.6.2 Polygon Edges . . . . . . . . . . . . . . . . . . . . . . . 18
2.6.3 GL Commands within Begin/End . . . . . . . . . . . . . 19
2.7 Vertex Specification . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.8 Vertex Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.9 Buffer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.9.1 Vertex Arrays in Buffer Objects . . . . . . . . . . . . . . 35
2.9.2 Array Indices in Buffer Objects . . . . . . . . . . . . . . 36
2.10 Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.11 Coordinate Transformations . . . . . . . . . . . . . . . . . . . . 37
2.11.1 Controlling the Viewport . . . . . . . . . . . . . . . . . . 39
2.11.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.11.3 Normal Transformation . . . . . . . . . . . . . . . . . . . 45
2.11.4 Generating Texture Coordinates . . . . . . . . . . . . . . 46
i
ii CONTENTS
2.12 Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.13 Current Raster Position . . . . . . . . . . . . . . . . . . . . . . . 51
2.14 Colors and Coloring . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.14.1 Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.14.2 Lighting Parameter Specification . . . . . . . . . . . . . . 60
2.14.3 ColorMaterial . . . . . . . . . . . . . . . . . . . . . . . 62
2.14.4 Lighting State . . . . . . . . . . . . . . . . . . . . . . . . 64
2.14.5 Color Index Lighting . . . . . . . . . . . . . . . . . . . . 64
2.14.6 Clamping or Masking . . . . . . . . . . . . . . . . . . . 65
2.14.7 Flatshading . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.14.8 Color and Texture Coordinate Clipping . . . . . . . . . . 65
2.14.9 Final Color Processing . . . . . . . . . . . . . . . . . . . 66
3 Rasterization 68
3.1 Invariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.2 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.2.1 Multisampling . . . . . . . . . . . . . . . . . . . . . . . 71
3.3 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3.3.1 Basic Point Rasterization . . . . . . . . . . . . . . . . . . 74
3.3.2 Point Rasterization State . . . . . . . . . . . . . . . . . . 77
3.3.3 Point Multisample Rasterization . . . . . . . . . . . . . . 77
3.4 Line Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.4.1 Basic Line Segment Rasterization . . . . . . . . . . . . . 78
3.4.2 Other Line Segment Features . . . . . . . . . . . . . . . . 80
3.4.3 Line Rasterization State . . . . . . . . . . . . . . . . . . 83
3.4.4 Line Multisample Rasterization . . . . . . . . . . . . . . 83
3.5 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.5.1 Basic Polygon Rasterization . . . . . . . . . . . . . . . . 84
3.5.2 Stippling . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.5.3 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.5.4 Options Controlling Polygon Rasterization . . . . . . . . 87
3.5.5 Depth Offset . . . . . . . . . . . . . . . . . . . . . . . . 88
3.5.6 Polygon Multisample Rasterization . . . . . . . . . . . . 89
3.5.7 Polygon Rasterization State . . . . . . . . . . . . . . . . 90
3.6 Pixel Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.6.1 Pixel Storage Modes . . . . . . . . . . . . . . . . . . . . 90
3.6.2 The Imaging Subset . . . . . . . . . . . . . . . . . . . . 91
3.6.3 Pixel Transfer Modes . . . . . . . . . . . . . . . . . . . . 92
3.6.4 Rasterization of Pixel Rectangles . . . . . . . . . . . . . 102
3.6.5 Pixel Transfer Operations . . . . . . . . . . . . . . . . . 113
Version 1.5 - October 30, 2003
CONTENTS iii
3.6.6 Pixel Rectangle Multisample Rasterization . . . . . . . . 123
3.7 Bitmaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.8 Texturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
3.8.1 Texture Image Specification . . . . . . . . . . . . . . . . 126
3.8.2 Alternate Texture Image Specification Commands . . . . 135
3.8.3 Compressed Texture Images . . . . . . . . . . . . . . . . 139
3.8.4 Texture Parameters . . . . . . . . . . . . . . . . . . . . . 142
3.8.5 Depth Component Textures . . . . . . . . . . . . . . . . 143
3.8.6 Cube Map Texture Selection . . . . . . . . . . . . . . . . 143
3.8.7 Texture Wrap Modes . . . . . . . . . . . . . . . . . . . . 145
3.8.8 Texture Minification . . . . . . . . . . . . . . . . . . . . 147
3.8.9 Texture Magnification . . . . . . . . . . . . . . . . . . . 153
3.8.10 Texture Completeness . . . . . . . . . . . . . . . . . . . 153
3.8.11 Texture State and Proxy State . . . . . . . . . . . . . . . 154
3.8.12 Texture Objects . . . . . . . . . . . . . . . . . . . . . . . 156
3.8.13 Texture Environments and Texture Functions . . . . . . . 158
3.8.14 Texture Comparison Modes . . . . . . . . . . . . . . . . 164
3.8.15 Texture Application . . . . . . . . . . . . . . . . . . . . . 164
3.9 Color Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
3.10 Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
3.11 Antialiasing Application . . . . . . . . . . . . . . . . . . . . . . 169
3.12 Multisample Point Fade . . . . . . . . . . . . . . . . . . . . . . . 169
4 Per-Fragment Operations and the Framebuffer 170
4.1 Per-Fragment Operations . . . . . . . . . . . . . . . . . . . . . . 171
4.1.1 Pixel Ownership Test . . . . . . . . . . . . . . . . . . . . 171
4.1.2 Scissor Test . . . . . . . . . . . . . . . . . . . . . . . . . 172
4.1.3 Multisample Fragment Operations . . . . . . . . . . . . . 172
4.1.4 Alpha Test . . . . . . . . . . . . . . . . . . . . . . . . . 173
4.1.5 Stencil Test . . . . . . . . . . . . . . . . . . . . . . . . . 174
4.1.6 Depth Buffer Test . . . . . . . . . . . . . . . . . . . . . . 175
4.1.7 Occlusion Queries . . . . . . . . . . . . . . . . . . . . . 176
4.1.8 Blending . . . . . . . . . . . . . . . . . . . . . . . . . . 177
4.1.9 Dithering . . . . . . . . . . . . . . . . . . . . . . . . . . 180
4.1.10 Logical Operation . . . . . . . . . . . . . . . . . . . . . 181
4.1.11 Additional Multisample Fragment Operations . . . . . . . 181
4.2 Whole Framebuffer Operations . . . . . . . . . . . . . . . . . . . 183
4.2.1 Selecting a Buffer for Writing . . . . . . . . . . . . . . . 183
4.2.2 Fine Control of Buffer Updates . . . . . . . . . . . . . . 184
4.2.3 Clearing the Buffers . . . . . . . . . . . . . . . . . . . . 185
Version 1.5 - October 30, 2003