Sunteți pe pagina 1din 8

OpenGL 3.

2 API Quick Reference Card


OpenGL® is the only cross-platform graphics API that enables developers Vertex Specification void MultiTexCoord{1234}{sifd}v(enum texture,
T coords)
of software for PC, workstation, and supercomputing hardware to create high- Begin and End [2.6.1, 2.6.3]
performance, visually-compelling graphics software applications, in markets texture: TEXTUREi (where i is [0, MAX_TEXTURE_COORDS - 1])
Enclose coordinate sets between Begin/End pairs to void Normal3{bsifd}(T coords);
such as CAD, content creation, energy, entertainment, game development, construct geometric objects.
manufacturing, medical, and virtual reality. void Normal3{bsifd}v(T coords);
void Begin(enum mode);
• see FunctionName refers to functions on this reference card. void End(void); void FogCoord{fd}(T coord);
• [n.n.n] and [Table n.n] refer to sections and tables in the OpenGL 3.2 core mode: POINTS, LINE_STRIP, LINE_LOOP, LINES, POLYGON, void FogCoord{fd}v(T coord);
specification. QUAD_STRIP, QUADS, TRIANGLE_STRIP, TRIANGLE_FAN, void Color{34}{bsifd ubusui}(T components);
• [n.n.n] refers to sections in the OpenGL Shading Language 1.50 specification. TRIANGLES, LINES_ADJACENCY, LINE_STRIP_ADJACENCY, void Color{34}{bsifd ubusui}v(T components);
• Content shown in blue is removed from the OpenGL 3.2 core profile and present TRIANGLES_ADJACENCY, TRIANGLE_STRIP_ADJACENCY
void SecondaryColor3{bsifd ubusui}(T components);
only in the OpenGL 3.2 compatibility profile. Profile selection is made at context Polygon Edges [2.6.2]
creation. void SecondaryColor3{bsifd ubusui}v(
Flag each edge of polygon primitives as either T components);
• [n.n.n] and [Table n.n] refer to sections and tables in the OpenGL 3.2 compatibility boundary or non-boundary.
profile specification, and are shown only when they differ from the core profile. void EdgeFlag(boolean flag); void Index{sifd ub}(T index);
Specifications are available at www.opengl.org/registry void EdgeFlagv(boolean *flag); void Index{sifd ub}v(T index);
void VertexAttrib{1234}{sfd}(uint index, T values);
Vertex Specification [2.7]
void VertexAttrib{123}{sfd}v(uint index, T values);
OpenGL Operation Command Letters [Table 2.1]
Letters are used in commands to denote
Vertices have two, three, or four coordinates, and
optionally a current normal, multiple current texture void VertexAttrib4{bsifd ub us ui}v(uint index,
Floating-Point Numbers [2.1.2] types as shown below. coordinate sets, multiple current generic vertex T values);
16-Bit 1-bit sign attributes, current color, current secondary color, and void VertexAttrib4Nub(uint index, T values);
5-bit exponent b - byte (8 bits) ub - ubyte (8 bits) current fog coordinates.
10-bit mantissa s - short (16 bits) us - ushort (16 bits) void VertexAttrib4N{bsi ub us ui}v(uint index,
void Vertex{234}{sifd}(T coords); T values);
Unsigned 11-Bit no sign bit i - int (32 bits) ui - uint (32 bits) void Vertex{234}{sifd}v(T coords);
5-bit exponent void VertexAttribI{1234}{i ui}(uint index, T values);
f - float (32 bits) d - double (64 bits) void TexCoord{1234}{sifd}(T coords);
6-bit mantissa void VertexAttribI{1234}{i ui}v(uint index,
Unsigned 10-Bit no sign bit void TexCoord{1234}{sifd}v(T coords); T values);
5-bit exponent void MultiTexCoord{1234}{sifd}(enum texture, void VertexAttribI4{bs ubus}v(uint index, T values);
5-bit mantissa T coords)

GL Command Syntax [2.3] The arguments enclosed in brackets ([args ,] and [, args]) may or may not be present.
The argument type T and the number N of arguments may be indicated by the command name
GL commands are formed from a return type, a name, and optionally up to 4 characters
(or character pairs) from the Command Letters table (above), as shown by the prototype below: suffixes. N is 1, 2, 3, or 4 if present, or else corresponds to the type letters from the Command Table
(above). If “v” is present, an array of N items are passed by a pointer.
return-type Name{1234}{b s i f d ub us ui}{v} ([args ,] T arg1 , . . . , T argN [, args]); For brevity, the OpenGL documentation and this reference may omit the standard prefixes.
The actual names are of the forms: glFunctionName(), GL_CONSTANT, GLtype

Vertex Arrays [2.8] void VertexAttribIPointer(uint index, int size, enum type,
sizei stride, const void *pointer);
void DrawRangeElements(enum mode, uint start,
uint end, sizei count, enum type, void *indices);
Vertex data may be placed into arrays that are stored in the type: BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT,
client address space or server address space. void DrawArraysInstanced(enum mode, int first,
UNSIGNED_INT sizei count, sizei primcount);
void VertexPointer(int size, enum type, sizei stride, index: [0, MAX_VERTEX_ATTRIBS - 1]
void *pointer); void EnableClientState(enum array); void DrawElementsInstanced(enum mode, sizei count,
type: SHORT, INT, FLOAT, HALF_FLOAT, DOUBLE enum type, const void *indices, sizei primcount);
void NormalPointer(enum type, sizei stride, void *pointer); void DisableClientState(enum array); void DrawElementsBaseVertex(enum mode, sizei count,
type: BYTE, SHORT, INT, FLOAT, HALF_FLOAT, DOUBLE array: VERTEX_ARRAY, NORMAL_ARRAY, COLOR_ARRAY,
SECONDARY_COLOR_ARRAY, INDEX_ARRAY, enum type, void *indices, int basevertex);
void ColorPointer(int size, enum type, sizei stride, EDGE_FLAG_ARRAY, FOG_COORD_ARRAY, TEXTURE_COORD_ARRAY void DrawRangeElementsBaseVertex(enum mode,
void *pointer); uint start, uint end, sizei count, enum type, void *indices,
type: BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT, void EnableVertexAttribArray(uint index);
int basevertex);
UNSIGNED_INT, FLOAT, HALF_FLOAT, DOUBLE void DisableVertexAttribArray(uint index);
index: TEXTUREi (where i is [0, MAX_VERTEX_ATTRIBS - 1]) void DrawElementsInstancedBaseVertex(enum mode,
void SecondaryColorPointer(int size, enum type, sizei stride, sizei count, enum type, const void *indices,
void *pointer); void ClientActiveTexture(enum texture); sizei primcount, int basevertex);
type: BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT, void ArrayElement(int i);
UNSIGNED_INT, FLOAT, HALF_FLOAT, DOUBLE void MultiDrawElementsBaseVertex(enum mode,
Enable/Disable(PRIMITIVE_RESTART) sizei *count, enum type, void **indices, sizei primcount,
void IndexPointer(enum type, sizei stride, void *pointer);
type: UNSIGNED_BYTE, SHORT, INT, FLOAT, DOUBLE void PrimitiveRestartIndex(uint index); int *basevertex);
mode: POINTS, LINE_STRIP, LINE_LOOP, LINES, POLYGON,
void EdgeFlagPointer(sizei stride, void *pointer); Drawing Commands [2.8.2] [2.8.1] TRIANGLE_STRIP, TRIANGLE_FAN, TRIANGLES, QUAD_STRIP,
void FogCoordPointer(enum type, sizei stride, void *pointer); void DrawArrays(enum mode, int first, sizei count); QUADS, LINES_ADJACENCY, LINE_STRIP_ADJACENCY,
type: FLOAT, HALF_FLOAT, DOUBLE TRIANGLES_ADJACENCY, TRIANGLE_STRIP_ADJACENCY
void MultiDrawArrays(enum mode, int *first, sizei *count,
void TexCoordPointer(int size, enum type, sizei stride, sizei primcount); type: UNSIGNED_BYTE, UNSIGNED_SHORT, UNSIGNED_INT
void *pointer); void InterleavedArrays(enum format, sizei stride,
type: SHORT, INT, FLOAT, HALF_FLOAT, DOUBLE void DrawElements(enum mode, sizei count, enum type,
void *indices); void *pointer);
void VertexAttribPointer(uint index, int size, enum type, format: V2F, V3F, C4UB_V2F, C4UB_V3F, C3F_V3F, N3F_V3F,
boolean normalized, sizei stride, const void *pointer); void MultiDrawElements(enum mode, sizei *count, C4F_N3F_V3F, T2F_V3F, T4F_V4F, T2F_C4UB_V3F, T2F_C3F_V3F,
type: BYTE, UNSIGNED_BYTE, SHORT, USHORT, INT, UINT, FLOAT, enum type, void **indices, sizei primcount); T2F_N3F_V3F, T2F_C4F_N3F_V3F, T4F_C4F_N3F_V4F
HALF_FLOAT, DOUBLE

Buffer Objects [2.9] Mapping and Unmapping Buffer Data [2.9.3]


void *MapBufferRange(enum target, intptr offset,
void DeleteVertexArrays(sizei n, const uint *arrays);
void GenBuffers(sizei n, uint *buffers); void BindVertexArray(uint array);
void DeleteBuffers(sizei n, const uint *buffers); sizeiptr length, bitfield access);
access: The logical OR of MAP_READ_BIT, MAP_WRITE_BIT, Buffer Object Queries [6.1.8] [6.1.14]
Creating and Binding Buffer Objects [2.9.1] MAP_INVALIDATE_RANGE_BIT, MAP_FLUSH_EXPLICIT_BIT, boolean IsBuffer(uint buffer);
void BindBuffer(enum target, uint buffer); MAP_INVALIDATE_BUFFER_BIT, MAP_UNSYNCHRONIZED_BIT void GetBufferParameteriv(enum target, enum pname,
target: ARRAY_BUFFER, COPY_READ_BUFFER, COPY_WRITE_BUFFER, void *MapBuffer(enum target, enum access); int *data);
ELEMENT_ARRAY_BUFFER, PIXEL_PACK_BUFFER, access: READ_ONLY, WRITE_ONLY, READ_WRITE pname: BUFFER_SIZE, BUFFER_USAGE, BUFFER_ACCESS,
PIXEL_UNPACK_BUFFER, TEXTURE_BUFFER, BUFFER_ACCESS_FLAGS, BUFFER_MAPPED,
TRANSFORM_FEEDBACK_BUFFER, UNIFORM_BUFFER
void FlushMappedBufferRange(enum target, intptr offset, BUFFER_MAP_POINTER, BUFFER_MAP_OFFSET,
sizeiptr length); BUFFER_MAP_LENGTH
void BindBufferRange(enum target, uint index, uint buffer, target: see BindBuffer
intptr offset, sizeiptr size); void GetBufferSubData(enum target, intptr offset,
target: TRANSFORM_FEEDBACK_BUFFER, UNIFORM_BUFFER boolean UnmapBuffer(enum target); sizeiptr size, void *data);
target: see BindBuffer target: see BindBuffer
void BindBufferBase(enum target, uint index, uint buffer);
target: see BindBufferRange Copying Between Buffers [2.9.5] void GetBufferPointerv(enum target, enum pname,
void *CopyBufferSubData(enum readtarget, void **params);
Creating Buffer Object Data Stores [2.9.2] enum writetarget, intptr readoffset, intptr writeoffset, target: see BindBuffer
void BufferData(enum target, sizeiptr size, const void *data, sizeiptr size); pname: BUFFER_MAP_POINTER
enum usage); readtarget and writetarget: see BindBuffer
usage: STREAM_DRAW, STREAM_READ, STREAM_COPY, Vertex Array Object Queries [6.1.9] [6.1.15]
STATIC_DRAW, STATIC_READ, STATIC_COPY, DYNAMIC_DRAW, Vertex Array Objects [2.10] boolean IsVertexArray(uint array);
DYNAMIC_READ, DYNAMIC_COPY All states related to the definition of data used by the vertex
void BufferSubData(enum target, intptr offset, sizeiptr size, processor is encapsulated in a vertex array object.
const void *data); void GenVertexArrays(sizei n, uint *arrays);
target: see BindBuffer

©2009 Khronos Group - Rev. 0809 www.opengl.org/registry


OpenGL 3.2 API Quick Reference Card
Rectangles, Matrices, Texture Coordinates Lighting and Color Rendering Control and Queries
Rectangles [2.11] Lighting/ Lighting Parameter Specification [2.13.1] Conditional Rendering [2.18]
Specifiy rectangles as two corner vertices. Enable/Disable(LIGHTING) (affects all lights) void BeginConditionalRender(uint id, enum mode);
void Rect{sifd}(T x1, T y1, T x2, T y2); Enable/Disable(LIGHTi) (affects individual lights) void EndConditionalRender(void);
void Rect{sifd}v(T v1[2], T v2[2]); void Material{if}(enum face, enum pname, T param); mode: QUERY_WAIT, QUERY_NO_WAIT,
QUERY_BY_REGION_WAIT, QUERY_BY_REGION_NO_WAIT
Matrices [2.12.1] void Material{if}v(enum face, enum pname, T params);
face: FRONT, BACK, FRONT_AND_BACK Transform Feedback [2.19]
void MatrixMode(enum mode); pname: AMBIENT, DIFFUSE, AMBIENT_AND_DIFFUSE, SPECULAR,
mode: TEXTURE, MODELVIEW, COLOR, PROJECTION EMISSION, SHININESS, COLOR_INDEXES
void BeginTransformFeedback(enum primitiveMode);
void LoadMatrix{fd}(T m[16]); void EndTransformFeedback(void);
void Light{if}(enum light, enum pname, T param); primitiveMode: TRIANGLES, LINES, POINTS
void MultMatrix{fd}(T m[16]); void Light{if}v(enum light, enum pname, T params);
void LoadTransposeMatrix{fd}(T m[16]); light: LIGHTi (where i >= 0)
void BindBufferRange(enum target, uint index,
uint buffer, intptr offset, sizeiptr size);
void MultTransposeMatrix{fd}(T m[16]); pname: AMBIENT, DIFFUSE, SPECULAR, POSITION, SPOT_DIRECTION,
SPOT_EXPONENT, SPOT_CUTOFF, CONSTANT_ATTENTUATION, void BindBufferBase(enum target, uint index, uint buffer);
void LoadIdentity(void); target: TRANSFORM_FEEDBACK_BUFFER
LINEAR_ATTENUATION, QUADRATIC_ATTENUATION
void Rotate{fd}(Ty, T x, T y, T z);
void Translate{fd}(T x, T y, T z); void LightModel{if}(enum pname, T param); Current Raster Position [2.24]
void Scale{fd}(T x, T y, T z); void LightModel{if}v(enum pname, T params); void RasterPos{234}{sifd}(T coords);
pname: LIGHT_MODEL_AMBIENT, LIGHT_MODEL_LOCAL_VIEWER, void RasterPos{234}{sifd}v(T coords);
void Frustum(double l, double r, double b, double t, LIGHT_MODEL_TWO_SIDE, LIGHT_MODEL_COLOR_CONTROL
double n, double f); void WindowPos{23}{sifd}(T coords);
void Ortho(double l, double r, double b, double t, ColorMaterial [2.13.3, 2.13.6] void WindowPos{23}{sifd}v(const T coords);
double n, double f); Enable/Disable(COLOR_MATERIAL)
void PushMatrix(void); void ColorMaterial(enum face, enum mode);
Asynchronous Queries [2.17]
face: FRONT, BACK, FRONT_AND_BACK void BeginQuery(enum target, uint id);
void PopMatrix(void); target: PRIMITIVES_GENERATED, SAMPLES_PASSED,
mode: EMISSION, AMBIENT, DIFFUSE, SPECULAR, TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
Generating Texture Coordinates [2.12.3] AMBIENT_AND_DIFFUSE
void TexGen{ifd}(enum coord, enum pname, T param); void EndQuery(enum target);
void ClampColor(enum target, enum clamp); void GenQueries(sizei n, uint *ids);
void TexGen{ifd}v(enum coord, enum pname, T *params); target: CLAMP_VERTEX_COLOR
void DeleteQueries(sizei n, const uint *ids);
coord: S, T, R, Q clamp: TRUE, FALSE, FIXED_ONLY
pname: TEXTURE_GEN_MODE, OBJECT_PLANE, EYE_PLANE
Flatshading [2.18] [2.21] Asynchronous State Queries [6.1.6] [6.1.12]
void ProvokingVertex(enum provokeMode); boolean IsQuery(uint id);
Viewport and Clipping provokeMode: FIRST_VERTEX_CONVENTION, void GetQueryiv(enum target, enum pname,
int *params);
LAST_VERTEX_CONVENTION
Controlling the Viewport [2.16.1] target: SAMPLES_PASSED, PRIMITIVES_GENERATED,
void DepthRange(clampd n, clampd f); void ShadeModel(enum mode); TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
mode: SMOOTH, FLAT
void Viewport(int x, int y, sizei w, sizei h); pname: CURRENT_QUERY, QUERY_COUNTER_BITS
Queries [6.13] void GetQueryObjectiv(uint id, enum pname,
Clipping [2.23] void GetLight{if}v(enum light, enum value, T data); int *params);
Enable/Disable(CLIP_DISTANCEi) void GetQueryObjectuiv(uint id, enum pname,
i: [0, MAX_CLIP_DISTANCES - 1] void GetMaterial{if}v(enum face, enum value, T data);
face: FRONT, BACK uint *params);
void ClipPlane(enum p, double eqn[4]); pname: QUERY_RESULT, QUERY_RESULT_AVAILABLE
p: CLIP_PLANEi (where i is [0, MAX_CLIP_PLANES - 1])

Shaders and Programs void GetUniformIndices(uint program, sizei uniformCount,


const char **uniformNames, uint *uniformIndices);
GetProgramiv(uint program, GEOMETRY_OUTPUT_TYPE,
int *params)
Shader Objects [2.11.1] [2.14.1] *params returns: POINTS, LINE_STRIP, TRIANGLE_STRIP
uint CreateShader(uint type); void GetActiveUniformName(uint program,
type: VERTEX_SHADER, FRAGMENT_SHADER, GEOMETRY_SHADER uint uniformIndex, sizei bufSize, sizei *length, Fragment Shaders [3.9.2] [3.12.2]
char *uniformName); void BindFragDataLocation(uint program, uint colorNumber,
void ShaderSource(uint shader, sizei count,
const char **string, const int *length); void GetActiveUniform(uint program, uint index, const char *name);
sizei bufSize, sizei *length, int *size, enum *type, int GetFragDataLocation(uint program, const char *name);
void CompileShader(uint shader); char *name); name: null-terminated string
void DeleteShader(uint shader); void GetActiveUniformsiv(uint program, sizei uniformCount,
Program Objects [2.11.2] [2.14.2]
const uint *uniformIndices, enum pname, int *params);
pname: UNIFORM_TYPE, UNIFORM_SIZE, UNIFORM_NAME_LENGTH,
Shader Queries
uint CreateProgram(void); UNIFORM_BLOCK_INDEX, UNIFORM_OFFSET, Shader Queries [6.1.10] [6.1.16]
void AttachShader(uint program, uint shader); UNIFORM_ARRAY_STRIDE, UNIFORM_MATRIX_STRIDE, boolean IsShader(uint shader);
UNIFORM_IS_ROW_MAJOR
void DetachShader(uint program, uint shader); type: FLOAT, FLOAT_VECn, INT, INT_VECn, UNSIGNED_INT, void GetShaderiv(uint shader, enum pname, int *params);
UNSIGNED_INT_VECn, BOOL, BOOL_VECn, FLOAT_MAT*, pname: SHADER_TYPE, DELETE_STATUS, COMPILE_STATUS,
void LinkProgram(uint program); INFO_LOG_LENGTH, SHADER_SOURCE_LENGTH
SAMPLER_*, INT_SAMPLER_*, UNSIGNED_INT_SAMPLER_*
void UseProgram(uint program); void GetAttachedShaders(uint program, sizei maxCount,
void DeleteProgram(uint program); Loading Uniform Variables In Default Uniform Block sizei *count, uint *shaders);
void Uniform{1234}{if}(int location, T value);
void GetShaderInfoLog(uint shader, sizei bufSize,
Vertex Attributes [2.11.3] [2.14.3] void Uniform{1234}{if}v(int location, sizei count, T value); sizei *length, char *infoLog);
Vertex shaders operate on an array of 4-component items void Uniform{1234}ui(int location, T value);
numbered from slot 0 to MAX_VERTEX_ATTRIBS - 1. void GetShaderSource(uint shader, sizei bufSize,
void Uniform{1234}uiv(int location, sizei count, T value); sizei *length, char *source);
void GetActiveAttrib(uint program, uint index, void UniformMatrix{234}fv(int location, sizei count,
sizei bufSize, sizei *length, int *size, enum *type, void GetVertexAttrib{dfi li lui}v(uint index, enum pname,
boolean transpose, const float *value); double *params);
char *name);
*type returns: FLOAT, FLOAT_VECn, FLOAT_MAT*, INT, INT_VECn, void UniformMatrix{2x3,3x2,2x4,4x2,3x4,4x3}fv( pname: CURRENT_VERTEX_ATTRIB , VERTEX_ATTRIB_ARRAY_x
UNSIGNED_INT, UNSIGNED_INT_VECn int location, sizei count, boolean transpose, (where x may be BUFFER_BINDING, ENABLED, SIZE, STRIDE, TYPE,
const float *value); NORMALIZED, INTEGER)
int GetAttribLocation(uint program, const char *name);
void GetVertexAttribPointerv(uint index, enum pname,
void BindAttribLocation(uint program, uint index, Uniform Buffer Object Bindings void **pointer);
const char *name); void UniformBlockBinding(uint program, pname: VERTEX_ATTRIB_ARRAY_POINTER
uint uniformBlockIndex, uint uniformBlockBinding);
Uniform Variables [2.11.4] [2.14.4] void GetUniform{if ui}v(uint program, int location,
int GetUniformLocation(uint program, const char *name); Varying Variables [2.11.6] [2.14.6] T *params)
void TransformFeedbackVaryings(uint program,
uint GetUniformBlockIndex(uint program, sizei count, const char **varyings, enum bufferMode); Program Queries [6.1.10] [6.1.16]
const char *uniformBlockName); bufferMode: INTERLEAVED_ATTRIBS, SEPARATE_ATTRIBS boolean IsProgram(uint program);
void GetActiveUniformBlockName(uint program, void GetTransformFeedbackVarying(uint program, void GetProgramiv(uint program, enum pname, int *params);
uint uniformBlockIndex, sizei bufSize, sizei *length, uint index, sizei bufSize, sizei *length, sizei *size, pname: DELETE_STATUS, LINK_STATUS, VALIDATE_STATUS,
char *uniformBlockName); enum *type, char *name); INFO_LOG_LENGTH, ATTACHED_SHADERS,
*type returns any of the scalar, vector, or matrix attribute types GEOMETRY_INPUT_TYPE, GEOMETRY_VERTICES_OUT,
void GetActiveUniformBlockiv(uint program, returned by GetActiveAttrib. GEOMETRY_OUTPUT_TYPE, ACTIVE_ATTRIBUTES,
uint uniformBlockIndex, enum pname, int *params); ACTIVE_ATTRIBUTE_MAX_LENGTH, ACTIVE_UNIFORMS,
pname: UNIFORM_BLOCK_BINDING, UNIFORM_BLOCK_DATA_SIZE, Shader Execution (Validation) [2.11.7] [2.14.7] TRANSFORM_FEEDBACK_*, ACTIVE_UNIFORM_*
UNIFORM_BLOCK_NAME_LENGTH, void ValidateProgram(uint program);
UNIFORM_BLOCK_ACTIVE_UNIFORMS, void GetProgramInfoLog(uint program, sizei bufSize,
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, Geometry Shaders [2.12] [2.15] sizei *length, char *infoLog);
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, GetProgramiv(uint program, GEOMETRY_INPUT_TYPE,
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, int *params)
UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER *params returns: POINTS, LINES, LINES_ADJACENCY, TRIANGLES,
TRIANGLES_ADJACENCY

©2009 Khronos Group - Rev. 0809 www.opengl.org/registry


www.opengl.org/registry
OpenGL 3.2 API Quick Reference Card
Rasterization [3] internalformat: One of the formats in [Table 3.16] or
[Tables 3.17-3.19] except the RED, RG, DEPTH_COMPONENT,
format and type: See GetTexImage, except format cannot
be DEPTH_COMPONENT
Enable/Disable(target) and DEPTH_STENCIL base and sized internal formats in those
target: RASTERIZER_DISCARD, MULTISAMPLE tables, all sized internal formats with non-fixed internal data void GetSeparableFilter(enum target, enum format,
types as discussed in [3.9], and sized internal format RGB9_E5. enum type, void *row, void *column, void *span);
Multisampling [3.3.1] format: RED, GREEN, BLUE, ALPHA, RG, RGB, RGBA, BGRA, target: SEPARABLE_2D
Use to antialias points, lines, polygons, bitmaps, and images. LUMINANCE, LUMINANCE_ALPHA format and type: See GetTexImage
Enable/Disable(MULTISAMPLE) type: {UNSIGNED_}BYTE/SHORT/INT*, {HALF_}FLOAT [Table 3.5] void GetConvolutionParameter{if}v(enum target,
void GetMultisamplefv(enum pname, uint index, Enable/Disable(POST_COLOR_MATRIX_COLOR_TABLE) enum pname, T params);
float *val); target: CONVOLUTION_1D, CONVOLUTION_2D, SEPARABLE_2D
void ColorTableParameter{if}v(enum target, enum pname, pname: {MAX_}CONVOLUTION_WIDTH,
pname: SAMPLE_POSITION T params); {MAX_}CONVOLUTION_HEIGHT, CONVOLUTION_x (where x
target: COLOR_TABLE, POST_CONVOLUTION_COLOR_TABLE,
Points [3.4] POST_COLOR_MATRIX_COLOR_TABLE
may be BORDER_COLOR, BORDER_MODE, FILTER_SCALE,
void PointSize(float size); FILTER_BIAS, FORMAT)
pname: COLOR_TABLE_SCALE, COLOR_TABLE_BIAS
void PointParameter{if}(enum pname, T param); Histogram Table Specification [3.7.3]
void PointParameter{if}v(enum pname, const T params); Alternate Color Table Specification Commands
void CopyColorTable(enum target, enum internalformat, Enable/Disable(HISTOGRAM)
pname: POINT_SIZE_MIN, POINT_SIZE_MAX,
POINT_DISTANCE_ATTENUATION POINT_FADE THRESHOLD_SIZE, int x, int y, sizei width); void Histogram(enum target, sizei width,
POINT_SPRITE_COORD_ORIGIN enum internalformat, boolean sink);
void ColorSubTable(enum target, sizei start, sizei count, target: HISTOGRAM, PROXY_HISTOGRAM
param, params: LOWER_LEFT, UPPER_LEFT, pointer to point fade enum format, enum type, void *data);
threshold internalformat: see ColorTable
void CopyColorSubTable(enum target, sizei start, int x,
Enable/Disable(VERTEX_PROGRAM_POINT_SIZE) int y, sizei count); Histogram Query [6.1.9]
Enable/Disable(POINT_SMOOTH) (Point antialias) target and pname: see ColorTableParameter{if}v void GetHistogram(enum target, boolean reset,
Enable/Disable(POINT_SPRITE) enum format, enum type, void *values);
Color Table Query [6.1.7] target: HISTOGRAM
Line Segments [3.5] void GetColorTable(enum target, enum format, enum type, format and type: See GetTexImage, except format cannot
void LineWidth(float width); void *table); be DEPTH_COMPONENT
Enable/Disable(LINE_SMOOTH) (Line antialias) target: COLOR_TABLE, POST_CONVOLUTION_COLOR_TABLE, void ResetHistogram(enum target);
POST_COLOR_MATRIX_COLOR_TABLE target: HISTOGRAM
Other Line Segments Features [3.5.2] format and type: See GetTexImage, except format cannot
void GetHistogramParameter{if}v(enum target,
void LineStipple(int factor, ushort pattern); be DEPTH_COMPONENT
enum pname, T params);
Enable/Disable(LINE_STIPPLE) void GetColorTableParameter{if}v(enum target, target: HISTOGRAM, PROXY_HISTOGRAM
enum pname, T params); pname: HISTOGRAM_x (where x may be FORMAT, WIDTH, RED_SIZE,
Stipple Query [6.1.5] target: {PROXY_}COLOR_TABLE, GREEN_SIZE, BLUE_SIZE, ALPHA_SIZE, LUMINANCE_SIZE, SINK)
void GetPolygonStipple(void *pattern); {PROXY_}POST_CONVOLUTION_COLOR_TABLE,
{PROXY_}POST_COLOR_MATRIX_COLOR_TABLE Minmax Table Specification [3.7.3]
Polygons [3.6] pname: COLOR_TABLE_x (where x may be SCALE, BIAS, Enable/Disable(MINMAX)
Enable/Disable(POLYGON_STIPPLE) FORMAT, COLOR_TABLE_WIDTH, RED_SIZE, GREEN_SIZE, void Minmax(enum target, enum internalformat,
Enable/Disable(POLYGON_SMOOTH) (Polygon antialias) BLUE_SIZE, ALPHA_SIZE, LUMINANCE_SIZE, INTENSITY_SIZE) boolean sink);
void FrontFace(enum dir); target: MINMAX
Convolution Filter Specification [3.7.3] internalformat: see ColorTable, except INTENSITY base and
dir: CCW, CW Enable/Disable(POST_CONVOLUTION_COLOR_TABLE) sized internal formats
void CullFace(enum mode); void ConvolutionFilter2D(enum target, enum
mode: FRONT, BACK, FRONT_AND_BACK internalformat, sizei width, sizei height, enum format, Minmax Query [6.1.10]
Enable/Disable(CULL_FACE) enum type, void GetMinmax(enum target, boolean reset,
void *data); enum format, enum type, void *values);
Stippling [3.6.2] target: CONVOLUTION_2D target: MINMAX
void PolygonStipple(ubyte *pattern); internalformat: see ColorTable format and type: See GetTexImage, except format cannot
format: RED, GREEN, BLUE, ALPHA, RG, RGB, RGBA, BGRA, be DEPTH_COMPONENT
Polygon Rasterization & Depth Offset [3.6.3] [3.6.4] LUMINANCE, LUMINANCE_ALPHA, RED_INTEGER, GREEN_INTEGER, void ResetMinmax(enum target);
void PolygonMode(enum face, enum mode); BLUE_INTEGER, ALPHA_INTEGER, RG_INTEGER, RGB_INTEGER, target: MINMAX
face: FRONT, BACK, FRONT_AND_BACK RBGA_INTEGER, BGR_INTEGER, BGRA_INTEGER
mode: POINT, LINE, FILL type: {UNSIGNED_}BYTE/SHORT/INT*, {HALF_}FLOAT void GetMinmaxParameter{if}v(enum target,
void PolygonOffset(float factor, float units); enum pname, T params);
void ConvolutionParameter{if}v(enum target, enum pname, target: MINMAX
Enable/Disable(target) T params); pname: MINMAX_FORMAT, MINMAX_SINK
target: POLYGON_OFFSET_POINT, POLYGON_OFFSET_LINE, target: CONVOLUTION_2D
POLYGON_OFFSET_FILL pname: CONVOLUTION_FILTER_SCALE, CONVOLUTION_FILTER_BIAS Rasterization of Pixel Rectangles [3.7.5]
void ConvolutionFilter1D(enum target, enum void DrawPixels(sizei width, sizei height, enum format,
Pixel Rectangles [3.7] internalformat, sizei width, enum format, enum type, enum type, void *data);
void PixelStore{if}(enum pname, T param); void *data); format: {COLOR|STENCIL}_INDEX, DEPTH_COMPONENT,
pname: UNPACK_x (where x may be SWAP_BYTES, LSB_FIRST, DEPTH_STENCIL, RED, GREEN, BLUE, ALPHA, RG, RGB, RGBA,
ROW_LENGTH, SKIP_ROWS, SKIP_PIXELS, ALIGNMENT, target: CONVOLUTION_1D
internalformat, format, and type: see ConvolutionFilter2D BGR, BGRA, LUMINANCE{_ALPHA} [Table 3.6]
IMAGE_HEIGHT, SKIP_IMAGES) (*_INTEGER formats are not supported)
void SeparableFilter2D(enum target, enum internalformat, type: UNSIGNED_BYTE, BITMAP, BYTE, UNSIGNED_SHORT, SHORT,
Pixel Transfer Modes [3.7.3] sizei width, sizei height, enum format, enum type, UNSIGNED_INT, INT, HALF_FLOAT, FLOAT, or another value from
void PixelTransfer{if}(enum param, T value); void *row, void *column); [Table 3.5]
param: MAP_COLOR, MAP_STENCIL, INDEX_SHIFT, target: SEPARABLE_2D
INDEX_OFFSET, x_SCALE, DEPTH_SCALE, x_BIAS, internalformat, format, and type: see ConvolutionFilter2D void ClampColor(enum target, enum clamp);
DEPTH_BIAS, or another value from [Table 3.2] target: CLAMP_READ_COLOR, CLAMP_FRAGMENT_COLOR
Alternate Convolution Filter Specification Commands clamp: TRUE, FALSE, FIXED_ONLY
void PixelMap{ui us f}v(enum map, sizei size, T values); void CopyConvolutionFilter2D(enum target,
map: PIXEL_MAP_{I, S, R, G, B, A}_TO_{I, S, R, G, B, A} [Table 3.3] enum internalformat, int x, int y, sizei width, sizei height); void PixelZoom(float zx, float zy);
Enumerated Queries [6.1.3] target: CONVOLUTION_2D
internalformat: see ConvolutionFilter2D Pixel Transfer Operations [3.7.6]
void GetPixelMap{ui us f}v(enum map, T data); void CopyConvolutionFilter1D(enum target, enum void ConvolutionParameter{if}(enum target,
map: PIXEL_MAP_{I, S, R, G, B, A}_TO_{I, S, R, G, B, A} [Table 3.3] internalformat, int x, int y, sizei width); enum pname, T param);
target: CONVOLUTION_1D target: CONVOLUTION_1D, CONVOLUTION_2D, SEPARABLE_2D
Color Table Specification [3.7.3] pname: CONVOLUTION_BORDER_MODE
void ColorTable(enum target, enum internalformat, internalformat: see ConvolutionFilter2D
param: REDUCE, CONSTANT_BORDER, REPLICATE_BORDER
sizei width, enum format, enum type, void *data); Convolution Query [6.1.8]
target: {PROXY_}COLOR_TABLE, void GetConvolutionFilter(enum target, enum format, Bitmaps [3.8]
POST_CONVOLUTION_COLOR_TABLE, enum type, void *image); void Bitmap(sizei w, sizei h, float xb0, float yb0, float xbi,
POST_COLOR_MATRIX_COLOR_TABLE [Table 3.4] float ybi, ubyte *data);
target: CONVOLUTION_1D, CONVOLUTION_2D

Texturing [3.8] [3.9] format: COLOR_INDEX, DEPTH_COMPONENT, DEPTH_STENCIL, RED,


GREEN, BLUE, ALPHA, RG, RGB, RGBA, BGR, BGRA, LUMINANCE,
target: TEXTURE_1D, PROXY_TEXTURE_1D
type: UNSIGNED_BYTE, BITMAP, BYTE, UNSIGNED_SHORT, SHORT,
void ActiveTexture(enum texture); LUMINANCE_ALPHA, RED_INTEGER, GREEN_INTEGER, UNSIGNED_INT, INT, HALF_FLOAT, FLOAT, or another value from
texture: TEXTUREi (where i is BLUE_INTEGER, ALPHA_INTEGER, RG_INTEGER, RGB_INTEGER, [Table 3.2] [Table 3.5]
[0, MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1]) RGBA_INTEGER, BGR_INTEGER, BGRA_INTEGER, or one of the internalformat and format: See TexImage3D
values from [Table 3.5] [Table 3.8]
Texture Image Specification [3.8.1] [3.9.1] type: UNSIGNED_BYTE, BITMAP, BYTE, UNSIGNED_SHORT, SHORT, Alt. Texture Image Specification Commands [3.8.2] [3.9.2]
void TexImage3D(enum target, int level, int internalformat, UNSIGNED_INT, INT, HALF_FLOAT, FLOAT, or a value from [Table 3.5] void CopyTexImage2D(enum target, int level,
sizei width, sizei height, sizei depth, int border, enum internalformat, int x, int y, sizei width, sizei height,
enum format, enum type, void *data); void TexImage2D(enum target, int level, int internalformat, int border);
target: {PROXY_}TEXTURE_3D, {PROXY_}TEXTURE_2D_ARRAY sizei width, sizei height, int border, enum format, target: TEXTURE_2D, TEXTURE_1D_ARRAY, TEXTURE_RECTANGLE,
internalformat: ALPHA, DEPTH_COMPONENT, DEPTH_STENCIL, enum type, void *data); TEXTURE_CUBE_MAP*
LUMINANCE, LUMINANCE_ALPHA, INTENSITY, RED, RG, RGB, target: {PROXY_}TEXTURE_2D, {PROXY_}TEXTURE_1D_ARRAY, internalformat: See TexImage2D
RGBA; a sized internal format from [Tables 3.12-3.13] {PROXY_}TEXTURE_RECTANGLE, TEXTURE_CUBE_MAP_*,
[Tables 3.17-3.19]; COMPRESSED_RED_RGTC1, PROXY_TEXTURE_CUBE_MAP void CopyTexImage1D(enum target, int level,
COMPRESSED_SIGNED_RED_RGTC1, COMPRESSED_RG_RGTC2, internalformat, format, and type: See TexImage3D enum internalformat, int x, int y, sizei width, int border);
COMPRESSED_SIGNED_RG_RGTC2, or a generic compressed target: TEXTURE_1D
format from [Table 3.14] [Table 3.20] void TexImage1D(enum target, int level, int internalformat, internalformat: See TexImage1D
sizei width, int border, enum format, enum type,
void *data); (Continued >)

©2009 Khronos Group - Rev. 0809 www.opengl.org/registry


OpenGL 3.2 API Quick Reference Card
Texturing (continued) void CompressedTexSubImage1D(enum target, int level,
int xoffset, sizei width, enum format, sizei imageSize,
void PrioritizeTextures(sizei n, uint *textures,
clampf *priorities);
void TexSubImage3D(enum target, int level, int xoffset, void *data);
int yoffset, int zoffset, sizei width, sizei height, sizei depth, target: TEXTURE_1D Texture Environments & Texture Functions [3.9.15]
enum format, enum type, void *data); format: See TexImage1D void TexEnv{if}(enum target, enum pname, T param);
target: TEXTURE_3D, TEXTURE_2D_ARRAY void TexEnv{if}v(enum target, enum pname, T params);
format and type: See TexImage3D Multisample Textures [3.8.4] [3.9.4] target: TEXTURE_FILTER_CONTROL, POINT_SPRITE, TEXTURE_ENV
void TexSubImage2D(enum target, int level, int xoffset, void TexImage3DMultisample(enum target, sizei samples, pname: TEXTURE_LOD_BIAS, TEXTURE_ENV_MODE,
int yoffset, sizei width, sizei height, enum format, int internalformat, sizei width, sizei height, sizei depth, TEXTURE_ENV_COLOR, COMBINE_RGB, COMBINE_ALPHA,
enum type, void *data); boolean fixedsamplelocations); RGB_SCALE, ALPHA_SCALE, COORD_REPLACE, SRCn_RGB,
target: TEXTURE_2D, TEXTURE_1D_ARRAY, TEXTURE_RECTANGLE, target: TEXTURE_2D_MULTISAMPLE_ARRAY, SRCn_ALPHA, OPERANDn_RGB, OPERANDn_ALPHA
TEXTURE_CUBE_MAP_* PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY (where n is [0, 1, 2])
format and type: See TexImage2D internalformat: ALPHA, RED, RG, RGB, RGBA, DEPTH_COMPONENT,
DEPTH_STENCIL, STENCIL_INDEX, or the sized internal formats Texture Application [3.9.19]
void TexSubImage1D(enum target, int level, int xoffset, corresponding to these base formats Enable/Disable(param)
sizei width, enum format, enum type, void *data); void TexImage2DMultisample(enum target, sizei samples, param: TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP
target: TEXTURE_1D int internalformat, sizei width, sizei height,
format: See TexImage1D Enumerated Queries [6.1.3]
type: BYTE, UNSIGNED_BYTE*, SHORT, UNSIGNED_SHORT*, INT,
boolean fixedsamplelocations); void GetTexEnv{if}v(enum env, enum value, T data);
target: TEXTURE_2D_MULTISAMPLE, PROXY_TEXTURE_2D_MULTISAMPLE env: POINT_SPRITE, TEXTURE_ENV, TEXTURE_FILTER_CONTROL
UNSIGNED_INT*, HALF_FLOAT, FLOAT* internalformat: See TexImage3DMultisample
void CopyTexSubImage3D(enum target, int level, int xoffset, void GetTexGen{ifd}v(enum coord, enum value, T data);
int yoffset, int zoffset, int x, int y, sizei width, sizei height); Buffer Textures [3.8.5] [3.9.5] coord: S, T, R, Q
target: TEXTURE_3D, TEXTURE_2D ARRAY void TexBuffer(enum target, enum internalformat, void GetTexParameter{if}v(enum target, enum value,
void CopyTexSubImage2D(enum target, int level, int xoffset, uint buffer); T data);
int yoffset, int x, int y, sizei width, sizei height); target: TEXTURE_BUFFER void GetTexParameterI{i ui}v(enum target, enum value,
target: TEXTURE_2D, TEXTURE_1D_ARRAY, TEXTURE_RECTANGLE, internalformat: R8, R16, R16F, R32F, R8I, R16I, R32I, R8U1, R16UI, T data);
TEXTURE_CUBE_MAP* R32UI, RG8, RG26, RG16F, RG32F, RG8I, RG16I, RG32I, RG8UI, target: TEXTURE_1D*, TEXTURE_2D*, TEXTURE_3D,
RG16UI, RG32UI, RGBA8, RGBA16, RGBA16F, RGBA32F, RGBA8I, TEXTURE_RECTANGLE, TEXTURE_CUBE_MAP
void CopyTexSubImage1D(enum target, int level, int xoffset, RGBA16I, RGBA32I, RGBA8UI, RGBA16UI, RGBA32UI value: TEXTURE_RESIDENT, TEXTURE_WRAP_{S, T, R},
int x, int y, sizei width); TEXTURE_{MIN, MAG}_FILTER, TEXTURE_BORDER_COLOR,
target: TEXTURE_1D Texture Parameters [3.8.6] [3.9.6]
void TexParameter{if}(enum target, enum pname, T param); TEXTURE_PRIORITY, TEXTURE_{MIN, MAX}_LOD,
Compressed Texture Images [3.8.3] [3.9.3] TEXTURE_{BASE, MAX}_LEVEL, TEXTURE_LOD_BIAS,
void TexParameter{if}v(enum target, enum pname, DEPTH_TEXTURE_MODE, TEXTURE_COMPARE_{MODE, FUNC},
void CompressedTexImage3D(enum target, int level, T *params);
enum internalformat, sizei width, sizei height, sizei depth, GENERATE_MIPMAP
int border, sizei imageSize, void *data); void TexParameterI{i ui}v(enum target, enum pname, void GetTexLevelParameter{if}v(enum target, int lod,
target: See TexImage3D T *params); enum value, T data);
internalformat: COMPRESSED_RED_RGTC1_RED, target: TEXTURE_1D*, TEXTURE_2D*, TEXTURE_3D, target: TEXTURE_1D*, TEXTURE_2D*, {PROXY_}TEXTURE_3D,
COMPRESSED_SIGNED_RED_RGTC1_RED, TEXTURE_RECTANGLE, TEXTURE_CUBE_MAP {PROXY_}TEXTURE_RECTANGLE, TEXTURE_CUBE_MAP_*,
COMPRESSED_RG_RGTC2_RG, COMPRESSED_SIGNED_RG_RGTC2 pname: TEXTURE_WRAP_{S, T, R}, TEXTURE_{MIN, MAG}_FILTER, PROXY_TEXTURE_1D{_ARRAY}, PROXY_TEXTURE_2D{_ARRAY},
TEXTURE_BORDER_COLOR, TEXTURE_PRIORITY, TEXTURE_{MIN, {PROXY_}TEXTURE_2D_MULTISAMPLE*,
void CompressedTexImage2D(enum target, int level, MAX}_LOD, TEXTURE_{BASE, MAX}_LEVELS, TEXTURE_LOD_BIAS,
enum internalformat, sizei width, sizei height, int border, PROXY_TEXTURE_CUBE_MAP , TEXTURE_BUFFER
DEPTH_TEXTURE_MODE, TEXTURE_COMPARE_{MODE, FUNC}, value: {PROXY_}TEXTURE_{1, 2}D{_ARRAY}, {PROXY_}TEXTURE_3D,
sizei imageSize, void *data); GENERATE_MIPMAP [Table 3.16] [Table 3.22]
target: See TexImage2D (Compressed rectangular {PROXY_}TEXTURE_RECTANGLE,
texture formats not supported.) Seamless Cube Map Filtering [3.8.8] [3.9.8] {PROXY_}TEXTURE_2D_MULTISAMPLE{_ARRAY}, TEXTURE_BUFFER,
TEXTURE_CUBE_MAP_{POSITIVE|NEGATIVE}_{X, Y, Z},
internalformat: See CompressedTexImage3D Enable/Disable(TEXTURE_CUBE_MAP_SEAMLESS) PROXY_TEXTURE_CUBE_MAP
void CompressedTexImage1D(enum target, int level, Manual Mipmap Generation [3.8.9] [3.9.9]
enum internalformat, sizei width, int border, void GenerateMipmap(enum target); Texture Queries [6.1.4]
sizei imageSize, void *data); target: TEXTURE_1D*, TEXTURE_2D*, TEXTURE_3D, void GetTexImage(enum target, int lod, enum format,
target: TEXTURE_1D, PROXY_TEXTURE_1D TEXTURE_CUBE_MAP enum type, void *img);
internalformat: See CompressedTexImage3D target: TEXTURE_{1, 2}D{_ARRAY}, TEXTURE_3D, TEXTURE_
void CompressedTexSubImage3D(enum target, int level, Texture Objects [3.8.14] [3.9.14] RECTANGLE, TEXTURE_CUBE_MAP_{POSITIVE|NEGATIVE}_{X, Y, Z}
int xoffset, int yoffset, int zoffset, sizei width, sizei height, void BindTexture(enum target, uint texture); format: See TexImage3D
target: TEXTURE_{1, 2}D{_ARRAY}, TEXTURE_3D, type: BITMAP, {UNSIGNED_}BYTE/SHORT/INT*, {HALF_}FLOAT,
sizei depth, enum format, sizei imageSize, void *data); TEXTURE_RECTANGLE, TEXTURE_BUFFER, TEXTURE_CUBE_MAP, FLOAT_32_UNSIGNED_INT_24_8_REV [Table 3.2] [Table 3.5]
target: TEXTURE_3D, TEXTURE_2D ARRAY
format: See TexImage3D TEXTURE_2D_MULTISAMPLE{_ARRAY} void GetCompressedTexImage(enum target, int lod,
void CompressedTexSubImage2D(enum target, int level, void DeleteTextures(sizei n, uint *textures); void *img);
int xoffset, int yoffset, sizei width, sizei height, void GenTextures(sizei n, uint *textures); target: See GetTexImage
enum format, sizei imageSize, void *data); boolean AreTexturesResident(sizei n, uint *textures, boolean IsTexture(uint texture);
target: TEXTURE_2D, TEXTURE_1D_ARRAY, TEXTURE_RECTANGLE, boolean *residences);
TEXTURE_CUBE_MAP_*
format: See TexImage2D

Color Sum, Fog, and Hints Drawing, Reading, and Copying Pixels Copying Pixels [4.3.2] [4.3.3]
void CopyPixels(int x, int y, sizei width, sizei height,
Color Sum [3.10] Reading Pixels [4.3.1] [4.3.2] enum type);
Enable/Disable(COLOR_SUM) void ReadPixels(int x, int y, sizei width, sizei height, type: COLOR, STENCIL, DEPTH, DEPTH_STENCIL
Fog [3.11] enum format, enum type, void *data);
format: {COLOR, STENCIL}_INDEX, DEPTH_COMPONENT, Blitting Pixel Rectangles [4.3.2] [4.3.3]
Enable/Disable(FOG) DEPTH_STENCIL, RED, GREEN, BLUE, ALPHA, RG, RGB, RGBA, void BlitFramebuffer(int srcX0, int srcY0, int srcX1,
void Fog{if}(enum pname, T param); BGR, BGRA, LUMINANCE{_ALPHA}, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1,
void Fog{if}v(enum pname, T params); {RED, GREEN, BLUE, ALPHA, RG, RGB, RGBA, BGR, BGRA}_INTEGER bitfield mask, enum filter);
pname: FOG_MODE, FOG_COORD_SRC, FOG_DENSITY, FOG_START, [Table 3.6] mask: Bitwise OR of COLOR_BUFFER_BIT, DEPTH_BUFFER_BIT,
FOG_END, FOG_COLOR, FOG_INDEX type: BITMAP, {UNSIGNED_}BYTE/SHORT/INT*, {HALF_}FLOAT, STENCIL_BUFFER_BIT
Hints [5.3] [5.7] FLOAT_32_UNSIGNED_INT_24_8_REV [Table 3.2] [Table 3.5] filter: LINEAR, NEAREST
void Hint(enum target, enum hint); void ReadBuffer(enum src);
target: LINE_SMOOTH_HINT, FRAGMENT_SHADER_DERIVATIVE_HINT, src: NONE, FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT,
TEXTURE_COMPRESSION_HINT, POLYGON_SMOOTH_HINT,
FRONT, BACK, LEFT, RIGHT, FRONT_AND_BACK,
PERSPECTIVE_CORRECTION_HINT, POINT_SMOOTH_HINT, Also see DrawPixels, ClampColor, and PixelZoom in the
AUXi (where i is [0, AUX_BUFFERS - 1 ]), COLOR_ATTACHMENTi
FOG_HINT, GENERATE_MIPMAP_HINT
hint: FASTEST, NICEST, DONT_CARE (where i is [0, MAX_COLOR_ATTACHMENTS - 1]) Rasterization section of this reference card.

Per-Fragment Operations Stencil Test [4.1.4] [4.1.5]


Enable/Disable(STENCIL_TEST)
Occlusion Queries [4.1.6] [4.1.7]
BeginQuery(SAMPLES_PASSED, uint id);
Scissor Test [4.1.2] void StencilFunc(enum func, int ref, uint mask);
Enable/Disable(SCISSOR_TEST) EndQuery(SAMPLES_PASSED);
void StencilFuncSeparate(enum face, enum func, int ref,
void Scissor(int left, int bottom, sizei width, sizei height ); uint mask); Blending [4.1.7] [4.1.8]
void StencilOp(enum sfail, enum dpfail, enum dppass); Enablei/Disablei(BLEND, uint index) (individual buffers)
Multisample Fragment Operations [4.1.3]
Enable/Disable(cap) void StencilOpSeparate(enum face, enum sfail, enum dpfail, Enable/Disable(BLEND) (all draw buffers)
cap: SAMPLE_ALPHA_TO_COVERAGE, SAMPLE_ALPHA_TO_ONE, enum dppass); void BlendEquation(enum mode);
SAMPLE_COVERAGE face: FRONT, BACK, FRONT_AND_BACK void BlendEquationSeparate(enum modeRGB,
void SampleCoverage(clampf value, boolean invert); sfail, dpfail, and dppass: KEEP, ZERO, REPLACE, INCR, DECR, INVERT, enum modeAlpha);
INCR_WRAP, DECR_WRAP mode, modeRGB, and modeAlpha: FUNC_ADD,
void SampleMaski(uint maskNumber, bitfield mask); func: NEVER, ALWAYS, LESS, LEQUAL, EQUAL, GREATER, GEQUAL, FUNC_SUBTRACT, FUNC_REVERSE_SUBTRACT, MIN, MAX
Alpha Test [4.1.4] NOTEQUAL
Enable/Disable(ALPHA_TEST) Depth Buffer Test [4.1.5] [4.1.6]
void AlphaFunc(enum func, clampf ref); Enable/Disable(DEPTH_TEST)
func: NEVER, ALWAYS, LESS,LEQUAL, EQUAL, GEQUAL, GREATER, void DepthFunc(enum func);
NOTEQUAL func: See StencilOpSeparate (Continued >)
©2009 Khronos Group - Rev. 0809 www.opengl.org/registry
OpenGL 3.2 API Quick Reference Card
Per-Fragment Operations (cont.) Whole Framebuffer Operations Clearing the Buffers [4.2.3]
void Clear(bitfield buf);
void BlendFuncSeparate(enum srcRGB, enum dstRGB, Selecting a Buffer for Writing [4.2.1] buf: Bitwise OR of COLOR_BUFFER_BIT, DEPTH_BUFFER_BIT,
enum srcAlpha, enum dstAlpha); void DrawBuffer(enum buf); STENCIL_BUFFER_BIT, ACCUM_BUFFER_BIT
buf: NONE, FRONT_LEFT, FRONT_RIGHT, BACK_LEFT,
void BlendFunc(enum src, enum dst); BACK_RIGHT, FRONT, BACK, LEFT, RIGHT, void ClearColor(clampf r, clampf g, clampf b, clampf a);
dst, dstRGB, and dstAlpha: ZERO, ONE, {ONE_MINUS_}SRC_COLOR, FRONT_AND_BACK, COLOR_ATTACHMENTi (where i is void ClearIndex(float index);
{ONE_MINUS_}DST_COLOR, {ONE_MINUS_}SRC_ALPHA, [0, MAX_COLOR_ATTACHMENTS - 1 ]), AUXi (where i is
{ONE_MINUS_}DST_ALPHA, {ONE_MINUS_}CONSTANT_COLOR, void ClearDepth(clampd d);
[0, AUX_BUFFERS - 1 ])
{ONE_MINUS_}CONSTANT_ALPHA void ClearStencil(int s);
src, srcRGB, srcAlpha: same for dst, plus SRC_ALPHA_SATURATE void DrawBuffers(sizei n, const enum *bufs);
bufs: NONE, FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, void ClearAccum(float r, float g, float b, float a);
void BlendColor(clampf red, clampf green, clampf blue, COLOR_ATTACHMENTi (where i is [0, MAX_COLOR_ATTACHMENTS - 1 ]), void ClearBuffer{if ui}v(enum buffer, int drawbuffer,
clampf alpha); AUXi (where i is [0, AUX_BUFFERS - 1 ]) const T *value)
Dithering [4.1.9] [4.1.10] buffer: COLOR, DEPTH, STENCIL
Fine Control of Buffer Updates [4.2.2]
Enable/Disable(DITHER) void IndexMask(uint mask); void ClearBufferfi(enum buffer, int drawbuffer, float depth,
int stencil);
Logical Operation [4.1.10] [4.1.11] void ColorMask(boolean r, boolean g, boolean b, boolean a); buffer: DEPTH_STENCIL
Enable/Disable(COLOR_LOGIC_OP) void ColorMaski(uint buf, boolean r, boolean g, boolean b, drawbuffer: 0
void LogicOp(enum op); boolean a);
op: CLEAR, AND, AND_REVERSE, COPY, AND_INVERTED, NOOP, void DepthMask(boolean mask); Accumulation Buffer [4.2.4]
OR, OR, NOR, EQUIV, INVERT, OR_REVERSE, COPY_INVERTED, void Accum(enum op, float value);
OR_INVERTED, NAND, SET void StencilMask(uint mask); op: ACCUM, LOAD, RETURN, MULT, ADD.
void StencilMaskSeparate(enum face, uint mask);
face: FRONT, BACK, FRONT_AND_BACK

Framebuffer Objects target: DRAW_FRAMEBUFFER, READ_FRAMEBUFFER, FRAMEBUFFER


attachment: DEPTH_ATTACHMENT, STENCIL_ATTACHMENT,
Framebuffer Completeness [4.4.4]
enum CheckFramebufferStatus(enum target);
Binding & Managing Framebuffer Objects [4.4.1] DEPTH_STENCIL_ATTACHMENT, COLOR_ATTACHMENTi (where i is target: DRAW_FRAMEBUFFER, READ_FRAMEBUFFER, FRAMEBUFFER
void BindFramebuffer(enum target, uint framebuffer); [0, MAX_COLOR_ATTACHMENTS - 1]) returns: FRAMEBUFFER_COMPLETE or a constant indicating which
target: DRAW_FRAMEBUFFER, READ_FRAMEBUFFER, FRAMEBUFFER renderbuffertarget: RENDERBUFFER value violates framebuffer completeness
void DeleteFramebuffers(sizei n, uint *framebuffers); Attaching Texture Images to a Framebuffer
void GenFramebuffers(sizei n, uint *ids); Framebuffer Object Queries [6.1.11] [6.1.17]
void FramebufferTexture(enum target, enum attachment, boolean IsFramebuffer(uint framebuffer);
uint texture, int level);
Attaching Images to Framebuffer Objects [4.4.2] target: DRAW_FRAMEBUFFER, READ_FRAMEBUFFER, FRAMEBUFFER void GetFramebufferAttachmentParameteriv(enum target,
Renderbuffer Objects attachment: See FramebufferRenderbuffer enum attachment, enum pname, int *params);
void BindRenderbuffer(enum target, uint renderbuffer); target: DRAW_FRAMEBUFFER, READ_FRAMEBUFFER, FRAMEBUFFER
void FramebufferTexture3D(enum target, enum attachment, attachment: FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT,
target: RENDERBUFFER enum textarget, uint texture, int level, int layer); COLOR_ATTACHMENTi, AUXi, DEPTH, STENCIL, DEPTH_ATTACHMENT,
void DeleteRenderbuffers(sizei n, const uint *renderbuffers); textarget: TEXTURE_3D STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT
void GenRenderbuffers(sizei n, uint *renderbuffers); target and attachment: See FramebufferRenderbuffer pname: FRAMEBUFFER_ATTACHMENT_x (where x may be
void RenderbufferStorageMultisample(enum target, void FramebufferTexture2D(enum target, enum attachment, OBJECT_TYPE, OBJECT_NAME, RED_SIZE, GREEN_SIZE, BLUE_SIZE,
sizei samples, enum internalformat, sizei width, enum textarget, uint texture, int level); ALPHA_SIZE, DEPTH_SIZE, STENCIL_SIZE, COMPONENT_TYPE,
textarget: TEXTURE_2D{_MULTISAMPLE}, TEXTURE_RECTANGLE, COLOR_ENCODING, TEXTURE_LEVEL, LAYERED,
sizei height); TEXTURE_CUBE_MAP_* TEXTURE_CUBE_MAP_FACE, TEXTURE_LAYER)
target: RENDERBUFFER target and attachment: See FramebufferRenderbuffer
internalformat: See TexImage2DMultisample Renderbuffer Object Queries [6.1.12] [6.1.18]
void FramebufferTexture1D(enum target, enum attachment, boolean IsRenderbuffer(uint renderbuffer);
void RenderbufferStorage(enum target, enum textarget, uint texture, int level);
enum internalformat, sizei width, sizei height); textarget: TEXTURE_1D void GetRenderbufferParameteriv(enum target,
target and internalformat: See RenderbufferStorageMultisample target and attachment: See FramebufferRenderbuffer enum pname, int *params);
target: RENDERBUFFER
Attaching Renderbuffer Images to Framebuffer void FramebufferTextureLayer(enum target, pname: RENDERBUFFER_x (where x may be WIDTH, HEIGHT,
void FramebufferRenderbuffer(enum target, enum attachment, uint texture, int level, int layer); RED_SIZE, GREEN_SIZE, BLUE_SIZE, ALPHA_SIZE, DEPTH_SIZE,
enum attachment, enum renderbuffertarget, target and attachment: See FramebufferTexture3D STENCIL_SIZE, INTERNAL_FORMAT, SAMPLES)
uint renderbuffer);

Special Functions Selection [5.2]


void InitNames(void);
Synchronization
Evaluators [5.1] void PopName(void); Flush and Finish [5.1] [5.5]
void Map1{fd}(enum target, T u1, T u2, int stride, int order, void Flush(void);
T points); void PushName(uint name);
target: MAP1_VERTEX_3, MAP1_VERTEX_4, MAP1_INDEX 1, void LoadName(uint name); void Finish(void);
MAP1_COLOR_4, MAP1_NORMA, MAP1_TEXTURE_COORD_1, int RenderMode(enum mode);
MAP1_TEXTURE_COORD_2, MAP1_TEXTURE_COORD_3,
Sync Objects and Fences [5.2] [5.6]
mode: RENDER, SELECT, FEEDBACK sync FenceSync(enum condition, bitfield flags)
MAP1_TEXTURE_COORD_4
void SelectBuffer(sizei n, uint *buffer); condition: SYNC_GPU_COMMANDS_COMPLETE
void Map2{fd}(enum target, T u1, T u2, int ustride, flags: must be 0
int uorder, T v1, T v2, int vstride, int vorder, T points); Feedback [5.3]
target: See Map1, except replace MAP1 with MAP2 void FeedbackBuffer(sizei n, enum type, float *buffer); void DeleteSync(sync sync);
type: 2D, 3D, 3D_COLOR, 3D_COLOR_TEXTURE, 4D_COLOR_TEXTURE
void EvalCoord{12}{fd}(T arg); Waiting for Sync Objects [5.2.1] [5.6.1]
void PassThrough(float token); enum ClientWaitSync(sync sync, bitfield flags,
void EvalCoord{12}{fdg}(T arg);
void MapGrid1{fd}(int n, T u1, T u2); Display Lists [5.4] uint64 timeout_ns);
void NewList(uint n, enum mode); flags: SYNC_FLUSH_COMMANDS_BIT, or zero
void MapGrid2{fd}(int nu, T u1, T u2, int nv, T v1, T v2);
void EvalMesh1(enum mode, int p1, int p2); mode: COMPILE, COMPILE_AND_EXECUTE void WaitSync(sync sync, bitfield flags,
mode: POINT, LINE void EndList(void); uint64 timeout_ns);
void CallList(uint n); timeout_ns: TIMEOUT_IGNORED
void EvalMesh2(enum mode, int p1, int p2, int q1, int q2);
mode: FILL, POINT, LINE void CallLists(sizei n, enum type, void *lists); Sync Object Queries [6.1.7] [6.1.13]
void EvalPoint1(int p); type: BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT, void GetSynciv(sync sync, enum pname, sizei bufSize,
UNSIGNED_INT, FLOAT sizei *length, int *values);
void EvalPoint2(int p, int q);
void ListBase(uint base); pname: OBJECT_TYPE, SYNC_STATUS, SYNC_CONDITION,
Enumerated Query [6.1.3] uint GenLists(sizei s); SYNC_FLAGS
void GetMap{ifd}v(enum map, enum value, T data); boolean IsSync(sync sync);
map: a map type described in section [5.1] boolean IsList(uint list);
value: ORDER, COEFF, DOMAIN void DeleteLists(uint list, sizei range);

State and State Requests boolean IsEnabled(enum value); ubyte *GetStringi(enum name, uint index);
name: EXTENSIONS
A complete list of symbolic constants for states is shown boolean IsEnabledi(enum target, uint index);
index: range is [0, NUM_EXTENSIONS - 1]
in the tables in [6.2]. Pointer and String Queries [6.1.5] [6.1.11]
Simple Queries [6.1.1] void GetPointerv(enum pname, void **params); Saving and Restoring State [6.1.19]
void GetBooleanv(enum value, boolean *data); pname: SELECTION_BUFFER_POINTER, FEEDBACK_BUFFER_POINTER, void PushAttrib(bitfield mask);
void GetIntegerv(enum value, int *data); VERTEX_ARRAY_POINTER, NORMAL_ARRAY_POINTER, mask: ALL_ATTRIB_BITS, or the bitwise OR of the attribute groups in
COLOR_ARRAY_POINTER, SECONDARY_COLOR_ARRAY_POINTER, [Table 6.2]
void GetInteger64v(enum value, int64 *data); INDEX_ARRAY_POINTER, TEXTURE_COORD_ARRAY_POINTER, void PushClientAttrib(bitfield mask);
void GetFloatv(enum value, float *data); FOG_COORD_ARRAY_POINTER, EDGE_FLAG_ARRAY_POINTER mask: CLIENT_ALL_ATTRIB_BITS, or the bitwise OR of the
void GetDoublev(enum value, double *data); attribute groups in [Table 6.2]
ubyte *GetString(enum name);
void GetBooleani_v(enum target, uint index, boolean *data); name: RENDERER, VENDOR, VERSION, void PopAttrib(void);
void GetIntegeri_v(enum target, uint index, int *data); SHADING_LANGUAGE_VERSION, EXTENSIONS void PopClientAttrib(void);

©2009 Khronos Group - Rev. 0809 www.opengl.org/registry


The OpenGL Shading Language 1.50 Quick Reference Card
The OpenGL® Shading Language is several closely-
related languages which are used to create shaders for
Preprocessor [3.3] Preprocessor Directives
Each number sign (#) can be preceded in its line only by spaces
each of the programmable processors contained in the Preprocessor Operators or horizontal tabs.
OpenGL processing pipeline. Preprocessor operators follow C++ standards. Preprocessor
expressions are evaluated according to the behavior of the host # #define #undef #if #ifdef
[n.n.n] and [Table n.n] refer to sections and tables in the processor, not the processor targeted by the shader. #ifndef #else #elif #endif #error
specification at www.opengl.org/registry #pragma #extension #version #line
Content shown in blue is removed from the OpenGL 3.2 #version 150 “#version 150” is required in shaders using version 1.50 of the language. #version
core profile and present only in the OpenGL 3.2 compatibility #version 150 compatibility must occur in a shader before anything else other than white space or comments. Use
profile. “compatibility” to access features in the compatibility profile.
#extension extension_name : behavior • behavior: require, enable, warn, disable
#extension all : behavior • extension_name: the extension supported by the compiler, or “all”
Types [4.1.1-4.1.10]
Transparent Types Predefined Macros
void no function return value
bool Boolean __LINE__ __FILE__ Decimal integer constants __VERSION__ Decimal integer, e.g.: 150
int, uint signed and unsigned integers
float floating scalar
vec2, vec3, vec4 floating point vector
bvec2, bvec3, bvec4 Boolean vector
Qualifiers Interpolation Qualifier [4.3.9]
Qualify outputs from vertex shader and inputs to fragment shader.
ivec2, ivec2, ivec3 signed and unsigned integer vector Storage Qualifiers [4.3] smooth perspective correct interpolation
uvec2, uvec2, uvec3 Variable declarations may have one storage qualifier. flat no interpolation
mat2, mat3, mat4 2x2, 3x3, 4x4 float matrix none (default) local read/write memory, or input parameter noperspective linear interpolation
mat2x2, mat2x3, mat2x4 2-column float matrix with 2, 3, or 4 rows const compile-time constant, or read-only function parameter The following predeclared variables can be redeclared with an
mat3x2, mat3x3, mat3x4 3-column float matrix with 2, 3, or 4 rows interpolation qualifier:
in linkage into a shader from previous stage (copied in) Vertex language: gl_FrontColor
mat4x2, mat4x3, mat4x4 4-column float matrix with 2, 3, or 4 rows centroid in linkage with centroid based interpolation gl_BackColor
Floating-Point Sampler Types (Opaque) out linkage out of a shader to subsequent stage (copied out) gl_FrontSecondaryColor
sampler[1,2,3]D access a 1D, 2D, or 3D texture centroid out linkage with centroid based interpolation gl_BackSecondaryColor
Fragment language: gl_Color
samplerCube access cube mapped texture uniform linkage between a shader, OpenGL, and the application gl_SecondaryColor
sampler2DRect access rectangular texture
Uniform [4.3.5] Parameter Qualifiers [4.4]
sampler[1,2]DShadow access 1D or 2D depth texture/comparison Input values are copied in at function call time, output values
Use to declare global variables with the same values across
sampler2DRectShadow access rectangular texture/comparison the entire primitive being processed. Uniform variables are are copied out at function return time.
sampler[1,2]DArray access 1D or 2D array texture read-only. Use uniform qualifiers with any basic data types or none (default) same as in
array of these, or when declaring a variable whose type is a in for function parameters passed into a function
sampler[1,2]DArrayShadow access 1D or 2D array depth texture/ structure, e.g.:
comparison out for function parameters passed back out of a function, but
uniform vec4 lightPosition; not initialized for use when passed in
samplerBuffer access buffer texture inout for function parameters passed both into and out of a function
sampler2DMS access 2D multi-sample texture Layout Qualifiers [4.3.8]
sampler2DMSArray access 2D multi-sample array texture
layout(layout-qualifiers) block-declaration Precision and Precision Qualifiers [4.5]
layout(layout-qualifiers) in/out/uniform Precision qualifiers have no affect on precision; they aid code
layout(layout-qualifiers) in/out/uniform declaration portability with OpenGL ES. They are:
Integer Sampler Types (Opaque)
highp, mediump, lowp
isampler[1,2,3]D access integer 1D, 2D, or 3D texture Input Layout Qualifiers
Layout qualifier identifiers for geometry shader inputs: Precision qualifiers precede a floating point or integer declaration:
isamplerCube access integer cube mapped texture lowp float color;
isampler2DRect access integer 2D rectangular texture points, lines, lines_adjacency, triangles, triangles_adjacency
A precision statement sets a default for subsequent declarations:
isampler[1,2]DArray access integer 1D or 2D array texture Fragment shaders can have an input layout only for redeclaring highp int;
the built-in variable gl_FragCoord with the layout qualifier
isamplerBuffer access integer buffer texture identifiers: Invariant Qualifiers Examples [4.6]
isampler2DMS access integer 2D multi-sample texture origin_upper_left, pixel_center_integer #pragma STDGL invariant(all) force all output variables to be
isampler2DMSArray access int. 2D multi-sample array texture invariant
Output Layout Qualifiers invariant gl_Position; qualify a previously declared
Unsigned Integer Sampler Types (Opaque) Layout qualifier identifiers for geometry shader outputs: variable
usampler[1,2,3]D access unsigned int 1D, 2D, or 3D texture points, line_strip, triangle_strip, invariant centroid out vec3 Color; qualify as part of a variable
max_vertices = integer-constant declaration
usamplerCube access unsigned int cube mapped texture
usampler2DRect access unsigned int rectangular texture Uniform-Block Layout Qualifiers Order of Qualification [4.7]
usampler[1,2]DArray access 1D or 2D array texture Layout qualifier identifiers for uniform blocks: When multiple qualifications are present, they must follow a
strict order. This order is as follows.
usamplerBuffer access unsigned integer buffer texture shared, packed, std140, row_major, column_major
invariant, interpolation, storage, precision
usampler2DMS access uint 2D multi-sample texture storage, parameter, precision
usampler2DMSArray access uint 2D multi-sample array texture
Implicit Conversions (All others must use constructors) Operators and Expressions 14. || logical inclusive or
Expression type Implicitly converted to type Operators [5.1] Numbered in order of precedence. The selection (Selects one entire operand. Use mix()
int, uint float 15. ?:
to select individual components of vectors.)
relational and equality operators > < <= >= == != evaluate to a
Boolean. To compare vectors component-wise, use functions =+
ivec2, uvec2 vec2 = -=
such as lessThan(), equal(), etc. assignment
ivec3, uvec3 vec3 16. *= /=
1. () parenthetical grouping %= <<= >>=
arithmetic assignments
ivec4, uvec4 vec4
[] array subscript &= ^= |=
Aggregation of Basic Types () function call & constructor structure
2. 17. , sequence
Arrays float[3] foo; . field or method selector, swizzler
float foo[3]; ++ -- postfix increment and decrement
++ -- prefix increment and decrement Vector Components [5.5]
* structures and blocks can be arrays 3. In addition to array numeric subscript syntax (e,g,: v[0], v[i])),
+-~! unary
* only 1-dimensional arrays supported names of vector components are denoted by a single letter.
4. */% multiplicative
* structure members can be arrays Components can be swizzled and replicated, e.g.: pos.xx, pos.zy
5. +- additive
Structures struct type-name { 6. << >> bit-wise shift {x, y, z, w} Use when accessing vectors that represent points or
members 7. < > <= >= relational normals
} struct-name[]; // optional variable declaration, 8. == != equality
// optionally an array 9. & bit-wise and {r, g, b, a} Use when accessing vectors that represent colors
Blocks in/out/uniform block-name { // interface matching by 10. ^ bit-wise exclusive or {s, t, p, q} Use when accessing vectors that represent texture
// block name coordinates
11. | bit-wise inclusive or
optionally-qualified members
} instance-name[]; // optional instance name, 12. && logical and
// optionally an array 13. ^^ logical exclusive or

©2009 Khronos Group - Rev. 0809 www.opengl.org/registry


OpenGL Shading Language 1.50 Quick Reference Card
Built-In Inputs, Outputs, and Constants [7] Aggregate Operations and Constructors Examples of operations on matrices and vectors:
m = f * m; // scalar * matrix component-wise
Vertex Language Matrix Constructor Examples [5.4] v = f * v; // scalar * vector component-wise
mat2(vec2, vec2); // one column per argument v = v * v; // vector * vector component-wise
in int gl_VertexID; out gl_PerVertex { m = m op m; // matrix op matrix component-wise
in int gl_InstanceID; vec4 gl_Position; mat3x2(vec2, vec2, vec2); // column 1
mat2(float, float, float, float); // column 2 m = m * m; // linear algebraic multiply
float gl_PointSize; m = v * m; // row vector * matrix linear algebraic multiply
in vec4 gl_Color; mat2x3(vec2, float, vec2, float); // column 2 m = m * v; // matrix * column vector linear algebraic multiply
float gl_ClipDistance[];
in vec4 gl_SecondaryColor; mat4x4(mat3x3); // mat3x3 to upper left, set lower f = dot(v, v); // vector dot product
vec4 gl_ClipVertex; // right to 1, fill rest with zero
in vec3 gl_Normal; }; v = cross(v, v); // vector cross product
in vec4 gl_Vertex; Array Constructor Example [5.4] m = matrixCompMult(m, m); // component-wise multiply
in vec4 gl_MultiTexCoord{0-7}; out vec4 gl_FrontColor; float c[3] = float[3](5.0, b + 1.0, 1.1); m = outerProduct(v, v); // matrix product of column * row vector
in float gl_FogCoord; out vec4 gl_BackColor;
Structure Constructor Example [5.4] Structure and Array Operations [5.7]
out vec4 gl_FrontSecondaryColor; Select structure fields and the length() method of an array
struct light {members; };
out vec4 gl_BackSecondaryColor; light lightVar = light(3.0, vec3(1.0, 2.0, 3.0)); using the period (.) operator. Other operators include:
out vec4 gl_TexCoord[]; . field or method selector
out float gl_FogFragCoord; Matrix Components [5.6]
Access components of a matrix with array subscripting syntax. == != equality
Geometry Language For example: = assignment
mat4 m; // m represents a matrix
in gl_PerVertex { out gl_PerVertex { [] indexing (arrays only)
vec4 gl_Position; m[1] = vec4(2.0); // sets second column to all 2.0
vec4 gl_Position; Array elements are accessed using the array subscript
float gl_PointSize; m[0][0] = 1.0; // sets upper left element to 1.0
float gl_PointSize; operator ( [ ] ). For example:
float gl_ClipDistance[]; m[2][3] = 2.0; // sets 4th element of 3rd column to 2.0
float gl_ClipDistance[]; diffuseColor += lightIntensity[3] * NdotL;
} gl_in[]; };
in int gl_PrimitiveIDIn; out int gl_PrimitiveID;
out int gl_Layer;
Built-In Constants With Minimum Values (cont’d) Statements and Structure
const int gl_MaxTextureUnits = 2; Iteration and Jumps [6]
Compatibility profile outputs from the Vertex Language are also const int gl_MaxTextureCoords = 8; Function Call call by value, return
available as deprecated inputs and outputs in the Geometry Language. const int gl_MaxGeometryTextureImageUnits = 16;
const int gl_MaxTextureImageUnits = 16; Iteration for (;;) { break, continue }
Fragment Language const int gl_MaxVertexAttribs = 16; while ( ) { break, continue }
const int gl_MaxVertexTextureImageUnits = 16; do { break, continue } while ( );
in vec4 gl_FragCoord; out float gl_FragDepth;
in bool gl_FrontFacing; const int gl_MaxCombinedTextureImageUnits = 48; Selection if ( ) { }
in float gl_ClipDistance[]; const int gl_MaxGeometryVaryingComponents = 64; if ( ) { } else { }
in vec2 gl_PointCoord; const int gl_MaxVaryingComponents = 64; switch ( ) { case integer: … break; … default: … }
in int gl_PrimitiveID; const int gl_MaxVaryingFloats = 64; Jump break, continue, return
const int gl_MaxGeometryOutputVertices = 256; (There is no ‘goto’)
Built-In Constants With Minimum Values [7.4] const int gl_MaxFragmentUniformComponents = 1024; Entry void main()
const int gl_MaxClipDistances = 8; const int gl_MaxGeometryTotalOutputComponents = 1024; Exit return in main()
const int gl_MaxClipPlanes = 8; const int gl_MaxGeometryUniformComponents = 1024; discard // Fragment shader only
const int gl_MaxDrawBuffers = 8; const int gl_MaxVertexUniformComponents = 1024;

Built-In Functions Common Functions (Continued) Geometric Functions [8.4]


These functions operate on vectors as vectors, not
Angle & Trigonometry Functions [8.1] T round(T x) nearest integer, implementation-
component-wise. T is float, vec2, vec3, vec4.
Component-wise operation. Parameters specified as angle are dependent rounding mode
assumed to be in units of radians. T is float, vec2, vec3, vec4. T roundEven(T x) nearest integer, 0.5 rounds to nearest float length(T x) length of vector
T radians(T degrees) degrees to radians even integer float distance(T p0, T p1) distance between points
T degrees(T radians) radians to degrees T ceil(T x) nearest integer >= x float dot(T x, T y) dot product
T sin(T angle) sine T fract(T x) x - floor(x) vec3 cross(vec3 x, vec3 y) cross product
T cos(T angle) cosine T mod(T x, float y) T normalize(T x) normalize vector to length 1
modulus
T tan(T angle) tangent T mod(T x, T y) vec4 ftransform( ) invariant vertex transformation
T modf(T x, out T i) separate integer and fractional parts T faceforward(T N, T I, T Nref) returns N if dot(Nref, I) < 0, else -N
T asin(T x) arc sine
T min(T x, T y) T reflect(T I, T N) reflection direction I - 2 * dot(N,I) * N
T acos(T x) arc cosine
T min(T x, float y) T refract(T I, T N, float eta) refraction vector
T atan(T y, T x) arc tangent Ti min(Ti x, Ti y)
T atan(T y_over_x) minimum value
Ti min(Ti x, int y) Matrix Functions [8.5]
T sinh(T x) hyperbolic sine Tu min(Tu x, Tu y) Type mat is any matrix type.
T cosh(T x) hyperbolic cosine Tu min(Tu x, uint y) mat matrixCompMult(mat x, mat y) multiply x by y component-wise
T tanh(T x) hyperbolic tangent T max(T x, T y) matN outerProduct(vecN c, vecN r) where N is 2, 3, 4 : c * r outer product
T max(T x, float y)
T asinh(T x) hyperbolic sine Ti max(Ti x, Ti y) matNxM outerProduct(vecM c, where N != M and N,
T acosh(T x) hyperbolic cosine maximum value vecN r) M = 2, 3, 4 : c * r outer product
Ti max(Ti x, int y)
T atanh(T x) hyperbolic tangent Tu max(Tu x, Tu y) matN transpose(matN m) where N is 2, 3, 4 : transpose of m
Tu max(Tu x, uint y) matNxM transpose(matMxN m) where N != M and N,M = 2, 3, 4 :
Exponential Functions [8.2] T clamp(T x, T minVal, T maxVal) transpose of m
Component-wise operation. T is float, vec2, vec3, vec4. T clamp(T x, float minVal, float determinant(matN m) determinant of m
T pow(T x, T y) xy float maxVal)
Ti clamp(Ti x, Ti minVal, Ti maxVal) matN inverse(matN m) where N is 2, 3, 4 : inverse of m
T exp(T x) ex
Ti clamp(Ti x, int minVal,
T log(T x) ln min(max(x, minVal), maxVal) Vector Relational Functions [8.6]
int maxVal)
T exp2(T x) 2x Tu clamp(Tu x, Tu minVal, Tu Compare x and y component-wise. Sizes of the input and return
vectors for any particular call must match. Type bvec is bvecn;
T log2(T x) log2 maxVal) vec is vecn; {ui}vec is {ui}vecn (where n is 2, 3, or 4). T is the
T sqrt(T x) square root Tu clamp(Tu x, uint minVal, union of vec and {ui}vec.
uint maxVal) bvec lessThan(T x, T y) <
T inversesqrt(T x) inverse square root
T mix(T x, T y, T a)
linear blend of x and y bvec lessThanEqual(T x, T y) <=
Common Functions [8.3] T mix(T x, T y, float a)
T mix(T x, T y, bvec a) true components in a select bvec greaterThan(T x, T y) >
Component-wise operation. T is float, vec2, vec3, vec4. Ti is int,
ivec2, ivec3, ivec4. Tu is uint, uvec2, uvec3, uvec4. bvec is bvec2, components from y, else from x bvec greaterThanEqual(T x, T y) >=
bvec3, bvec4, bool. T step(T edge, T x) bvec equal(T x, T y) ==
0.0 if x < edge, else 1.0
T abs(T x) T step(float edge, T x) bvec equal(bvec x, bvec y)
Ti abs(Ti x) absolute value
T smoothstep(T edge0, T edge1, T x) bvec notEqual(T x, T y) !=
T sign(T x) returns -1.0, 0.0, or 1.0 T smoothstep(float edge0, clip and smooth bvec notEqual(bvec x, bvec y)
Ti sign(Ti x) float edge1, T x) bool any(bvec x) true if any component of x is true
T floor(T x) nearest integer <= x bvec isnan(T x) true if x is NaN bool all(bvec x) true if all components of x are true
T trunc(T x) nearest integer with absolute value <= bvec isinf(T x) true if x is positive or negative infinity bvec not(bvec x) logical complement of x
absolute value of x
(continued >)

©2009 Khronos Group - Rev. 0809 www.opengl.org/registry


The OpenGL Shading Language 1.50 Quick Reference Card
Derivative Functions [8.8] Noise Functions [8.9] Geometry Shader Functions [8.10]
Available only in fragment shaders. T is float, vec2, vec3, vec4. Returns noise value. Available to fragment, geometry, and vertex Only available in geometry shaders.
T dFdx(T p) derivative in x shaders. T is float, vec2, vec3, vec4. void EmitVertex() emits current values of output variables
T dFdy(T p) derivative in y float noise1(T x) to the current output primitive
T fwidth(T p) sum of absolute derivative in x and y vec2 noisen(T x) where n is 2, 3, or 4 void EndPrimitive() completes current output primitive and
starts a new one

Texture Lookup Functions [8.7] float textureOffset(sampler1DShadow sampler, vec3 P, int offset [, float bias])
Texture lookup with explicit gradient:
Available to vertex, geometry, and fragment shaders. gvec4 gvec4 textureGrad(gsampler1D sampler, float P, float dPdx, float dPdy)
means vec4, ivec4, or uvec4. gsampler* means sampler*, float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset [, float bias])
isampler*, or usampler*. gvec4 textureGrad(gsampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy)
gvec4 textureOffset(gsampler1DArray sampler, vec2 P, int offset [, float bias])
gvec4 textureGrad(gsampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy)
Texture lookup, returning LOD if present: gvec4 textureOffset(gsampler2DArray sampler, vec3 P, ivec2 offset [, float bias])
gvec4 textureGrad(gsamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy)
int textureSize(gsampler1D sampler, int lod) float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset
[, float bias]) gvec4 textureGrad(gsampler2DRect sampler, vec2 P, vec2 dPdx, vec2 dPdy)
ivec2 textureSize(gsampler2D sampler, int lod)
float textureGrad(sampler2DRectShadow sampler, vec3 P, vec2 dPdx,
ivec3 textureSize(gsampler3D sampler, int lod) Fetch a single texel: vec2 dPdy)
ivec2 textureSize(gsamplerCube sampler, int lod) gvec4 texelFetch(gsampler1D sampler, int P, int lod) float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy)
int textureSize(sampler1DShadow sampler, int lod) gvec4 texelFetch(gsampler2D sampler, ivec2 P, int lod) float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy)
ivec2 textureSize(sampler2DShadow sampler, int lod) gvec4 texelFetch(gsampler3D sampler, ivec3 P, int lod) float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx,
ivec2 textureSize(samplerCubeShadow sampler, int lod) gvec4 texelFetch(gsampler2DRect sampler, ivec2 P) vec3 dPdy)
gvec4 texelFetch(gsampler1DArray sampler, ivec2 P, int lod) gvec4 textureGrad(gsampler1DArray sampler, vec2 P, float dPdx, float dPdy)
ivec2 textureSize(gsampler2DRect sampler)
gvec4 texelFetch(gsampler2DArray sampler, ivec3 P, int lod) gvec4 textureGrad(gsampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy)
ivec2 textureSize(sampler2DRectShadow sampler)
gvec4 texelFetch(gsamplerBuffer sampler, int P) float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx,
ivec2 textureSize(gsampler1DArray sampler, int lod) float dPdy)
gvec4 texelFetch(gsampler2DMS sampler, ivec2 P, int sample) float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx,
ivec3 textureSize(gsampler2DArray sampler, int lod)
gvec4 texelFetch(gsampler2DMSArray sampler, ivec3 P, int sample) vec2 dPdy)
ivec2 textureSize(sampler1DArrayShadow sampler, int lod)
ivec3 textureSize(sampler2DArrayShadow sampler, int lod) Fetch a single texel, with offset: Texture lookup with explicit gradient and offset:
int textureSize(gsamplerBuffer sampler) gvec4 texelFetchOffset(gsampler1D sampler, int P, int lod, int offset) gvec4 textureGradOffset(gsampler1D sampler, float P, float dPdx, float dPdy,
int offset)
ivec2 textureSize(gsampler2DMS sampler) gvec4 texelFetchOffset(gsampler2D sampler, ivec2 P, int lod, ivec2 offset) gvec4 textureGradOffset(gsampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy,
ivec2 textureSize(gsampler2DMSArray sampler) gvec4 texelFetchOffset(gsampler3D sampler, ivec3 P, int lod, ivec3 offset) ivec2 offset)
gvec4 texelFetchOffset(gsampler2DRect sampler, ivec2 P, ivec2 offset) gvec4 textureGradOffset(gsampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy,
Texture lookup: ivec3 offset)
gvec4 texelFetchOffset(gsampler1DArray sampler, ivec2 P, int lod, int offset) gvec4 textureGradOffset(gsampler2DRect sampler, vec2 P, vec2 dPdx,
gvec4 texture(gsampler1D sampler, float P [, float bias]) vec2 dPdy, ivec2 offset)
gvec4 texelFetchOffset(gsampler2DArray sampler, ivec3 P, int lod, ivec2 offset)
gvec4 texture(gsampler2D sampler, vec2 P [, float bias]) float textureGradOffset(sampler2DRectShadow sampler, vec3 P, vec2 dPdx,
gvec4 texture(gsampler3D sampler, vec3 P [, float bias]) Projective texture lookup with offset: vec2 dPdy, ivec2 offset)
gvec4 textureProjOffset(gsampler1D sampler, vec{2,4} P, int offset [, float bias]) float textureGradOffset(sampler1DShadow sampler, vec3 P, float dPdx,
gvec4 texture(gsamplerCube sampler, vec3 P [, float bias]) float dPdy, int offset)
float texture(sampler{1,2}DShadow sampler, vec3 P [, float bias]) gvec4 textureProjOffset(gsampler2D sampler, vec{3,4} P, ivec2 offset float textureGradOffset(sampler2DShadow sampler, vec3 P, vec2 dPdx,
[, float bias]) vec2 dPdy, ivec2 offset)
float texture(samplerCubeShadow sampler, vec4 P [, float bias]) gvec4 textureProjOffset(gsampler3D sampler, vec4 P, ivec3 offset [, float bias]) float textureGradOffset(samplerCubeShadow sampler, vec4 P, vec3 dPdx,
gvec4 texture(gsampler1DArray sampler, vec2 P [, float bias]) gvec4 textureProjOffset(gsampler2DRect sampler, vec{3,4} P, ivec2 offset) vec3 dPdy, ivec2 offset)
gvec4 texture(gsampler2DArray sampler, vec3 P [, float bias]) gvec4 textureGradOffset(gsampler1DArray sampler, vec2 P, float dPdx, float
float textureProjOffset(sampler2DRectShadow sampler, vec4 P, ivec2 offset) dPdy, int offset)
float texture(sampler1DArrayShadow sampler, vec3 P [, float bias]) float textureProjOffset(sampler1DShadow sampler, vec4 P, int offset gvec4 textureGradOffset(gsampler2DArray sampler, vec3 P, vec2 dPdx, vec2
float texture(sampler2DArrayShadow sampler, vec4 P) [, float bias]) dPdy, ivec2 offset)
float textureProjOffset(sampler2DShadow sampler, vec4 P, ivec2 offset float textureGradOffset(sampler1DArrayShadow sampler, vec3 P, float dPdx,
gvec4 texture(gsampler2DRect sampler, vec2 P) float dPdy, int offset)
[, float bias])
float texture(sampler2DRectShadow sampler, vec3 P) float textureGradOffset(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx,
Offset texture lookup with explicit LOD: vec2 dPdy, ivec2 offset)
Texture lookup with projection: gvec4 textureLodOffset(gsampler1D sampler, float P, float lod, int offset)
gvec4 textureProj(gsampler1D sampler, vec{2,4} P [, float bias]) Projective texture lookup with explicit gradient:
gvec4 textureLodOffset(gsampler2D sampler, vec2 P, float lod, ivec2 offset) gvec4 textureProjGrad(gsampler1D sampler, vec{2,4} P, float dPdx, float dPdy)
gvec4 textureProj(gsampler2D sampler, vec{3,4} P [, float bias]) gvec4 textureLodOffset(gsampler3D sampler, vec3 P, float lod, ivec3 offset) gvec4 textureProjGrad(gsampler2D sampler, vec{3,4} P, vec2 dPdx, vec2 dPdy)
gvec4 textureProj(gsampler3D sampler, vec4 P [, float bias]) float textureLodOffset(sampler1DShadow sampler, vec3 P, float lod, int offset) gvec4 textureProjGrad(gsampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy)
float textureProj(sampler{1,2}DShadow sampler, vec4 P [, float bias]) float textureLodOffset(sampler2DShadow sampler, vec3 P, float lod, gvec4 textureProjGrad(gsampler2DRect sampler, vec{3,4} P, vec2 dPdx,
gvec4 textureProj(gsampler2DRect sampler, vec{3,4} P) ivec2 offset) vec2 dPdy)
float textureProj(sampler2DRectShadow sampler, vec4 P) gvec4 textureLodOffset(gsampler1DArray sampler, vec2 P, float lod, int offset) float textureProjGrad(sampler2DRectShadow sampler, vec4 P, vec2 dPdx,
gvec4 textureLodOffset(gsampler2DArray sampler, vec3 P, float lod, vec2 dPdy)
Texture lookup with explicit LOD: ivec2 offset) float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx,
gvec4 textureLod(gsampler1D sampler, float P, float lod) float textureLodOffset(sampler1DArrayShadow sampler, vec3 P, float lod, float dPdy)
int offset) float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx,
gvec4 textureLod(gsampler2D sampler, vec2 P, float lod) vec2 dPdy)
gvec4 textureLod(gsampler3D sampler, vec3 P, float lod) Projective texture lookup with explicit LOD:
gvec4 textureProjLod(gsampler1D sampler, vec{2,4} P, float lod) Projective texture lookup with explicit gradient and offset:
gvec4 textureLod(gsamplerCube sampler, vec3 P, float lod) gvec4 textureProjGradOffset(gsampler1D sampler, vec{2,4} P, float dPdx,
gvec4 textureProjLod(gsampler2D sampler, vec{3,4} P, float lod)
float textureLod(sampler{1,2}DShadow sampler, vec3 P, float lod) float dPdy, int offset)
gvec4 textureProjLod(gsampler3D sampler, vec4 P, float lod) gvec4 textureProjGradOffset(gsampler2D sampler, vec{3,4} P, vec2 dPdx,
gvec4 textureLod(gsampler1DArray sampler, vec2 P, float lod)
float textureProjLod(sampler{1,2}DShadow sampler, vec4 P, float lod) vec2 dPdy, vec2 offset)
gvec4 textureLod(gsampler2DArray sampler, vec3 P, float lod) gvec4 textureProjGradOffset(gsampler2DRect sampler, vec{3,4} P, vec2 dPdx,
float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod) Offset projective texture lookup with explicit LOD: vec2 dPdy, ivec2 offset)
gvec4 textureProjLodOffset(gsampler1D sampler, vec{2,4} P, float lod, int offset) float textureProjGradOffset(sampler2DRectShadow sampler, vec4 P,
Texture lookup with offset: vec2 dPdx, vec2 dPdy, ivec2 offset)
gvec4 textureProjLodOffset(gsampler2D sampler, vec{3,4} P, float lod, gvec4 textureProjGradOffset(gsampler3D sampler, vec4 P, vec3 dPdx,
gvec4 textureOffset(gsampler1D sampler, float P, int offset [, float bias]) ivec2 offset) vec3 dPdy, vec3 offset)
gvec4 textureOffset(gsampler2D sampler, vec2 P, ivec2 offset [, float bias]) gvec4 textureProjLodOffset(gsampler3D sampler, vec4 P, float lod, ivec3 offset) float textureProjGradOffset(sampler1DShadow sampler, vec4 P, float dPdx,
gvec4 textureOffset(gsampler3D sampler, vec3 P, ivec3 offset [, float bias]) float textureProjLodOffset(sampler1DShadow sampler, vec4 P, float lod, float dPdy, int offset)
int offset) float textureProjGradOffset(sampler2DShadow sampler, vec4 P, vec2 dPdx,
gvec4 textureOffset(gsampler2DRect sampler, vec2 P, ivec2 offset) float textureProjLodOffset(sampler2DShadow sampler, vec4 P, float lod, vec2 dPdy, vec2 offset)
float textureOffset(sampler2DRectShadow sampler, vec3 P, ivec2 offset) ivec2 offset)

OpenGL is a registered trademark of Silicon Graphics International, used under license by Khronos Group.
The Khronos Group is an industry consortium creating open standards for the authoring and acceleration
of parallel computing, graphics and dynamic media on a wide variety of platforms and devices.
See www.khronos.org to learn more about the Khronos Group.
See www.opengl.org to learn more about OpenGL.

©2009 Khronos Group - Rev. 0809 Reference card production by Miller & Mattson www.millermattson.com www.opengl.org/registry

S-ar putea să vă placă și