Professional Documents
Culture Documents
Opengl41 Quick Reference Card PDF
Opengl41 Quick Reference Card PDF
OpenGL Operation Command Letters [Table 2.1] Vertex Specification void FogCoord{fd}(T coord);
Letters are used in commands to denote types. void FogCoord{fd}v(const T coord);
Floating-Point Numbers [2.1.1 - 2.1.2] Begin and End [2.6]
16-Bit 1-bit sign, 5-bit exponent, b - byte (8 bits) ub - ubyte (8 bits) Enclose coordinate sets between Begin/End void Color{34}{bsifd ubusui}(T components);
10-bit mantissa s - short (16 bits) us - ushort (16 bits) pairs to construct geometric objects. void Color{34}{bsifd ubusui}v(
Unsigned 11-Bit no sign bit, 5-bit exponent, i - int (32 bits) ui - uint (32 bits) void Begin(enum mode); const T components);
6-bit mantissa void End(void); void ColorP{34}ui(enum type, uint coords);
Unsigned 10-Bit no sign bit, 5-bit exponent, i64 - int64 (64 bits) ui64 - uint64 (64 bits) mode: see MultiDrawElementsBaseVertex
Separate Patches void ColorP{34}uiv(enum type,
5-bit mantissa f - float (32 bits) d - double (64 bits) const uint *coords);
void PatchParameteri(enum pname, int value);
pname: PATCH_VERTICES void SecondaryColor3{bsifd ubusui}(
T components);
OpenGL Errors [2.5] enum GetError(void); Returns the numeric error code. Polygon Edges [2.6.2]
Flag each edge of polygon primitives as either void SecondaryColor3{bsifd ubusui}v(
boundary or non-boundary. const T components);
void EdgeFlag(boolean flag);
Vertex Arrays [2.8] void ArrayElement(int i);
void EdgeFlagv(const boolean *flag);
void SecondaryColorP3ui(enum type,
uint coords);
void VertexPointer(int size, enum type, Enable/Disable(PRIMITIVE_RESTART)
sizei stride, const void *pointer); void PrimitiveRestartIndex(uint index); Vertex Specification [2.7] void SecondaryColorP3uiv(enum type,
type: SHORT, INT, FLOAT, HALF_FLOAT, DOUBLE, Vertices have 2, 3, or 4 coordinates, and const uint *coords);
{UNSIGNED_}INT_2_10_10_10_REV Drawing Commands [2.8.3] [2.8.2] optionally a current normal, multiple current
void Index{sifd ub}(T index);
void DrawArrays(enum mode, int first, texture coordinate sets, multiple current
void NormalPointer(enum type, sizei stride, sizei count); generic vertex attributes, current color, current void Index{sifd ub}v(const T index);
const void *pointer); secondary color, and current fog coordinates.
type: see VertexPointer, plus BYTE void DrawArraysInstanced(enum mode, The VertexAttrib* commands specify generic
int first, sizei count, sizei primcount}; void Vertex{234}{sifd}(T coords); attributes with components of type float
void ColorPointer(int size, enum type,
sizei stride, const void *pointer); void DrawArraysIndirect(enum mode, void Vertex{234}{sifd}v(const T coords); (VertexAttrib*), int or uint (VertexAttribI*), or
type: see VertexPointer, plus BYTE, UINT, const void *indirect); double (VertexAttribL*d*).
void MultiDrawArrays(enum mode, void VertexP{234}ui(enum type, uint coords); void VertexAttrib{1234}{sfd}(uint index,
UNSIGNED_{BYTE, SHORT}
void SecondaryColorPointer(int size, const int *first, sizei *count, void VertexP{234}uiv(enum type, T values);
enum type, sizei stride, const void *pointer); const sizei primcount); const uint *coords); void VertexAttrib{123}{sfd}v(uint index,
type: see ColorPointer void DrawElements(enum mode, type: INT_2_10_10_10_REV, const T values);
sizei count, enum type, const void *indices); UNSIGNED_INT_2_10_10_10_REV
void IndexPointer(enum type, sizei stride, void VertexAttrib4{bsifd ub us ui}v(
const void *pointer); void DrawElementsInstanced(enum mode, void TexCoord{1234}{sifd}(T coords); uint index, const T values);
type: UNSIGNED_BYTE, SHORT, INT, FLOAT, DOUBLE sizei count, enum type, const void *indices, void TexCoord{1234}{sifd}v(const T coords); void VertexAttrib4Nub(uint index, T values);
void EdgeFlagPointer(sizei stride, sizei primcount); void TexCoordP{1234}ui(enum type,
const void *pointer); void MultiDrawElements(enum mode, void VertexAttrib4N{bsi ub us ui}v(
uint coords); uint index, const T values);
void FogCoordPointer(enum type, sizei *count, enum type,
sizei stride, const void *pointer); const void **indices, sizei primcount); void TexCoordP{1234}uiv(enum type, void VertexAttribI{1234}{i ui}(uint index,
const uint *coords); T values);
type: FLOAT, HALF_FLOAT, DOUBLE void DrawRangeElements(enum mode, type: see VertexP{234}uiv
void TexCoordPointer(int size, enum type, uint start, uint end, sizei count, void VertexAttribI{1234}{i ui}v(uint index,
sizei stride, const void *pointer); enum type, const void *indices); void MultiTexCoord{1234}{sifd}( const T values);
type: see VertexPointer void DrawElementsBaseVertex(enum mode, enum texture, T coords); void VertexAttribI4{bs ub us}v(uint index,
void VertexAttribPointer(uint index, int size, sizei count, enum type, const void *indices, void MultiTexCoord{1234}{sifd}v( const T values);
enum type, boolean normalized, int basevertex); enum texture, const T coords); void VertexAttribP{1234}ui(
sizei stride, const void *pointer); void DrawRangeElementsBaseVertex( texture: TEXTUREi (where i is uint index, enum type, boolean normalized,
type: see ColorPointer, plus FIXED enum mode, uint start, uint end, [0, MAX_TEXTURE_COORDS - 1]) uint value)
void VertexAttribIPointer(uint index, sizei count, enum type, const void *indices, void MultiTexCoordP{1234}ui(enum texture, void VertexAttribL{1234}d(uint index,
int size, enum type, sizei stride, int basevertex); enum type, uint coords); T values);
const void *pointer); void DrawElementsInstancedBaseVertex( void MultiTexCoordP{1234}uiv(
type: BYTE, SHORT, UNSIGNED_{BYTE, SHORT}, INT, UINT enum mode, sizei count, enum type, void VertexAttribL{1234}dv(uint index,
enum texture, enum type, const uint *coords); T values);
index: [0, MAX_VERTEX_ATTRIBS - 1] const void *indices, sizei primcount,
void VertexAttribLPointer(uint index, int size, int basevertex); void Normal3{bsifd}(const T coords); void VertexAttribP{1234}uiv(uint index,
enum type, sizei stride, const void *pointer); void DrawElementsIndirect(enum mode, void Normal3{bsifd}v(T coords); enum type, boolean normalized,
type: DOUBLE enum type, const void *indirect); const uint *value);
void NormalP3ui(enum type, uint normal); type: see VertexP{234}uiv
index: see VertexAttribIPointer void MultiDrawElementsBaseVertex(
void EnableClientState(enum array); void NormalP3uiv(enum type, uint *normal);
enum mode, sizei *count, enum type,
void DisableClientState(enum array); const void **indices, sizei primcount,
array: {VERTEX, NORMAL, COLOR, INDEX}_ARRAY, int *basevertex);
mode: POINTS, LINE_STRIP, LINE_LOOP, LINES, Mapping/Unmapping Buffer Data [2.9.3] void BindVertexArray(uint array);
{SECONDARY_COLOR, EDGE_FLAG}_ARRAY, void *MapBufferRange(enum target,
FOG_COORD_ARRAY, TEXTURE_COORD_ARRAY POLYGON, TRIANGLE_{STRIP, FAN}, TRIANGLES, Buffer Object Queries [6.1.9] [6.1.15]
QUAD_STRIP, QUADS, LINES_ADJACENCY, intptr offset, sizeiptr length, bitfield access); boolean IsBuffer(uint buffer);
void EnableVertexAttribArray(uint index); {LINE, TRIANGLE}_STRIP_ADJACENCY, access: The logical OR of MAP_{READ, WRITE}_BIT,
void DisableVertexAttribArray(uint index); PATCHES, TRIANGLES_ADJACENCY, MAP_INVALIDATE_{BUFFER, RANGE}_BIT, void GetBufferParameteriv(enum target,
index: [0, MAX_VERTEX_ATTRIBS - 1] type: UNSIGNED_{BYTE, SHORT, INT} MAP_{FLUSH_EXPLICIT, UNSYNCHRONIZED}_BIT, enum pname, int *data);
target: see BindBuffer target: see BindBuffer
void VertexAttribDivisor(uint index, void InterleavedArrays(enum format, pname: BUFFER_SIZE, BUFFER_USAGE,
uint divisor); sizei stride, const void *pointer); void *MapBuffer(enum target, enum access); BUFFER_ACCESS{_FLAGS}, BUFFER_MAPPED,
void ClientActiveTexture(enum texture); format: V2F, V3F, C4UB_{V2F, V3F}, {C3F, N3F}_V3F, access: READ_ONLY, WRITE_ONLY, READ_WRITE BUFFER_MAP_{OFFSET, LENGTH}
index: TEXTUREi (where i is [0, MAX_TEXTURE_COORDS - 1]) C4F_N3F_V3F, T2F_{C4UB, C3F, N3F}_V3F, void FlushMappedBufferRange(
T2F_V3F, T4F_V4F, T2F_C4F_N3F_{V3F, V4F} void GetBufferParameteri64v(enum target,
enum target, intptr offset, sizeiptr length); enum pname, int64 *data);
target: see BindBuffer target: see BindBuffer
pname: see GetBufferParameteriv,
Buffer Objects [2.9] void BindBufferBase(enum target,
uint index, uint buffer);
boolean UnmapBuffer(enum target);
target: see BindBuffer
void GenBuffers(sizei n, uint *buffers); void GetBufferSubData(enum target,
target: see BindBufferRange Copying Between Buffers [2.9.5] intptr offset, sizeiptr size, void *data);
void DeleteBuffers(sizei n, const uint *buffers);
Creating Buffer Object Data Stores [2.9.2] void *CopyBufferSubData(enum readtarget, target: see BindBuffer
Creating and Binding Buffer Objects [2.9.1] void BufferData(enum target, sizeiptr size, enum writetarget, intptr readoffset,
void BindBuffer(enum target, uint buffer); void GetBufferPointerv(enum target,
const void *data, enum usage); intptr writeoffset, sizeiptr size); enum pname, void **params);
target: PIXEL_{PACK, UNPACK}_BUFFER, UNIFORM_BUFFER usage: STREAM_{DRAW, READ, COPY}, readtarget and writetarget: see BindBuffer
ARRAY_BUFFER, COPY_{READ, WRITE}_BUFFER, target: see BindBuffer
{DYNAMIC, STATIC}_{DRAW, READ, COPY} Vertex Array Objects [2.10] pname: BUFFER_MAP_POINTER
DRAW_INDIRECT_BUFFER, ELEMENT_ARRAY_BUFFER, target: see BindBuffer
TEXTURE_BUFFER, TRANSFORM_FEEDBACK_BUFFER, All states related to definition of data used by
void BufferSubData(enum target, vertex processor is in a vertex array object. Vertex Array Object Queries
void BindBufferRange(enum target, uint index, intptr offset, sizeiptr size, [6.1.10] [6.1.16]
uint buffer, intptr offset, sizeiptr size); void GenVertexArrays(sizei n, uint *arrays);
target: {TRANSFORM_FEEDBACK, UNIFORM}_BUFFER
const void *data); void DeleteVertexArrays(sizei n, boolean IsVertexArray(uint array);
target: see BindBuffer const uint *arrays);
©2010 Khronos Group - Rev. 0610 www.opengl.org/registry
OpenGL 4.1 API Quick Reference Card - Page 2
Rectangles, Matrices, Texture void Rotate{fd}(Ty, T x, T y, T z); Rendering Control & Queries void DrawTransformFeedback(
enum mode, uint id);
Coordinates void Translate{fd}(T x, T y, T z); Asynchronous Queries [2.15] [2.18]
void DrawTransformFeedbackStream(
void Scale{fd}(T x, T y, T z); void BeginQuery(enum target, uint id);
Rectangles [2.11] target: PRIMITIVES_GENERATED{n}, enum mode, uint id, uint stream);
Specifiy rectangles as two corner vertices. void Frustum(double l, double r, double b, {ANY_}SAMPLES_PASSED, TIME_ELAPSED,
void Rect{sifd}(T x1, T y1, T x2, T y2); double t, double n, double f); TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN{n} Transform Feedback Query
void EndQuery(enum target); [6.1.11] [6.1.17]
void Rect{sifd}v(const T v1[2], const T v2[2]); void Ortho(double l, double r, double b,
double t, double n, double f); boolean IsTransformFeedback(uint id);
void BeginQueryIndexed(enum target, uint
Matrices [2.12.1] void PushMatrix(void); index, uint id); Current Raster Position [2.25]
void MatrixMode(enum mode); void EndQueryIndexed(enum target, void RasterPos{234}{sifd}(T coords);
mode: TEXTURE, MODELVIEW, COLOR, PROJECTION void PopMatrix(void);
uint index); void RasterPos{234}{sifd}v(const T coords);
void LoadMatrix{fd}(const T m[16]); Texture Coordinates [2.12.3] void GenQueries(sizei n, uint *ids);
void TexGen{ifd}(enum coord, enum pname, void WindowPos{23}{sifd}(T coords);
void MultMatrix{fd}(const T m[16]); void DeleteQueries(sizei n, const uint *ids);
T param); void WindowPos{23}{sifd}v(const T coords);
void LoadTransposeMatrix{fd}(const T m[16]); Conditional Rendering [2.16] [2.19]
void TexGen{ifd}v(enum coord,
void MultTransposeMatrix{fd}(const T m[16]); enum pname, const T params); void BeginConditionalRender(uint id, Asynchronous Queries [6.1.7] [6.1.13]
coord: S, T, R, Q enum mode); boolean IsQuery(uint id);
void LoadIdentity(void); mode: QUERY_WAIT, QUERY_NO_WAIT,
pname: TEXTURE_GEN_MODE, {OBJECT, EYE}_PLANE QUERY_BY_REGION_{WAIT, NO_WAIT} void GetQueryiv(enum target,
enum pname, int *params);
void EndConditionalRender(void); target: see BeginQuery, plus TIMESTAMP
Lighting and Color const T params);
pname: LIGHT_MODEL_{AMBIENT, LOCAL_VIEWER}, Transform Feedback [2.17] [2.20]
pname: CURRENT_QUERY, QUERY_COUNTER_BITS
Enable/Disable(LIGHTING) // generic enable LIGHT_MODEL_{TWO_SIDE, COLOR_CONTROL} void GenTransformFeedbacks(sizei n, uint *ids); void GetQueryIndexediv(enum target,
uint index, enum pname, int *params);
Enable/Disable(LIGHTi) // indiv. lights ColorMaterial [4.3.1] [2.13.3, 3.7.5] void DeleteTransformFeedbacks(sizei n, target: see BeginQuery
Enable/Disable(COLOR_MATERIAL) const uint *ids); pname: CURRENT_QUERY, QUERY_COUNTER_BITS
Lighting Parameter Spec. [2.13.2] void BindTransformFeedback(
void Material{if}(enum face, void ColorMaterial(enum face, enum mode); void GetQueryObjectiv(uint id,
face: FRONT, BACK, FRONT_AND_BACK
enum target, uint id); enum pname, int *params);
enum pname, T param); target: TRANSFORM_FEEDBACK
mode: EMISSION, AMBIENT, DIFFUSE, SPECULAR, void GetQueryObjectuiv(uint id,
void Material{if}v(enum face, AMBIENT_AND_DIFFUSE void BeginTransformFeedback( enum pname, uint *params);
enum pname, const T params); enum primitiveMode);
void ClampColor(enum target, enum clamp); primitiveMode: TRIANGLES, LINES, POINTS void GetQueryObjecti64v(uint id,
face: FRONT, BACK, FRONT_AND_BACK target: CLAMP_VERTEX_COLOR
pname: AMBIENT, DIFFUSE, AMBIENT_AND_DIFFUSE, void EndTransformFeedback(void); enum pname, int64 *params);
clamp: TRUE, FALSE, FIXED_ONLY
EMISSION, SHININESS, COLOR_INDEXES, SPECULAR void GetQueryObjectui64v(uint id,
void PauseTransformFeedback(void);
void Light{if}(enum light, enum pname, Flatshading [2.19] [2.22] enum pname, uint64 *params);
void ProvokingVertex(enum provokeMode); void ResumeTransformFeedback(void); pname: QUERY_RESULT{_AVAILABLE}
T param);
provokeMode: {FIRST, LAST}_VERTEX_CONVENTION
void Light{if}v(enum light, enum pname, void ShadeModel(enum mode);
const T params);
light: LIGHTi (where i >= 0)
mode: SMOOTH, FLAT Viewport and Clipping void ViewportIndexedfv(uint index,
const float *v);
pname: AMBIENT, DIFFUSE, SPECULAR,POSITION, Queries [6.1.3] Controlling Viewport [2.14.1] [2.17.1] void Viewport(int x, int y, sizei w, sizei h);
SPOT_{DIRECTION, EXPONENT, CUTOFF}, void GetLight{if}v(enum light, enum value, void DepthRangeArrayv(uint first,
{CONSTANT, LINEAR,QUADRATIC}_ATTENUATION T data); sizei count, const clampd *v); Clipping [2.20] [2.23, 6.1.3]
void GetMaterial{if}v(enum face, void DepthRangeIndexed(uint index, Enable/Disable(CLIP_DISTANCEi)
void LightModel{if}(enum pname, T param); enum value, T data); clampd n, clampd f); i: [0, MAX_CLIP_DISTANCES - 1]
void LightModel{if}v(enum pname, face: FRONT, BACK void DepthRange(clampd n, clampd f); void ClipPlane(enum p, const double eqn[4]);
void DepthRangef(clampf n, clampd f); p: CLIP_PLANEi (where i is [0, MAX_CLIP_PLANES - 1])
void ViewportArrayv(uint first, sizei count, void GetClipPlane(enum plane,
Shaders and Programs void ActiveShaderProgram(uint pipeline,
uint program);
const float *v);
void ViewportIndexedf(uint index, float x, double eqn[4]);
Shader Objects [2.11.1-2] [2.14.1-2] float y, float w, float h);
uint CreateShader(enum type); Program Binaries [2.11.5] [2.14.5]
type: {VERTEX, FRAGMENT, GEOMETRY}_SHADER, void GetProgramBinary(uint program,
TESS_{EVALUATION, CONTROL}_SHADER
sizei bufSize, sizei *length, void GetUniformIndices(uint program, void ProgramUniform{1234}{ifd}(
void ShaderSource(uint shader, sizei count, enum *binaryFormat, void *binary); sizei uniformCount, uint program, int location, T value);
const char **string, const int *length); const char **uniformNames, void ProgramUniform{1234}{ifd}v(
void ProgramBinary(uint program, uint *uniformIndices);
void CompileShader(uint shader); enum binaryFormat, const void *binary, uint program, int location, sizei count,
sizei length); void GetActiveUniformName( const T value);
void ReleaseShaderCompiler(void);
uint program, uint uniformIndex, void ProgramUniform{1234}ui(
void DeleteShader(uint shader); Vertex Attributes [2.11.6] [2.14.6] sizei bufSize, sizei *length, uint program, int location, T value);
void ShaderBinary(sizei count, Vertex shaders operate on array of 4-component char *uniformName); void ProgramUniform{1234}uiv(
const uint *shaders, enum binaryformat, items numbered from slot 0 to void GetActiveUniform(uint program, uint program, int location, sizei count,
const void *binary, sizei length); MAX_VERTEX_ATTRIBS - 1. uint index, sizei bufSize, sizei *length, const T value);
void GetActiveAttrib(uint program, int *size, enum *type, char *name); void ProgramUniformMatrix{234}{fd}v(
Program Objects [2.11.3] [2.14.3] uint index, sizei bufSize, sizei *length, *type returns: DOUBLE, DOUBLE_{VECn, MATn, uint program, int location, sizei count,
uint CreateProgram(void); int *size, enum *type, char *name); MATnxn}, FLOAT, FLOAT_{VECn, MATn, MATnxn}, boolean transpose, const float *value);
void AttachShader(uint program, *type returns: FLOAT, FLOAT_{VECn, MATn, MATnxm}, INT, INT_VECn, UNSIGNED_INT{_VECn}, BOOL, void ProgramUniformMatrixf{2x3,3x2,2x4,
uint shader); INT, INT_VECn, UNSIGNED_{INT, INT_VECn} BOOL_VECn, and the SAMPLER_* and 4x2,3x4,4x3}{fd}v(
{UNSIGNED_}INT_SAMPLER_* values in uint program, int location, sizei count,
void DetachShader(uint program, int GetAttribLocation(uint program, [Table 2.13] [Table 2.16]
uint shader); boolean transpose, const float *value);
const char *name); void GetActiveUniformsiv(uint program,
void LinkProgram(uint program); Uniform Buffer Object Bindings
void BindAttribLocation(uint program, sizei uniformCount, const uint void UniformBlockBinding(uint program,
void UseProgram(uint program); uint index, const char *name); *uniformIndices, enum pname, uint uniformBlockIndex,
uint CreateShaderProgramv(enum type, int *params); uint uniformBlockBinding);
sizei count, const char **strings); Uniform Variables [2.11.7] [2.14.7] pname: UNIFORM_{TYPE, SIZE, NAME_LENGTH},
UNIFORM_BLOCK_INDEX, UNIFORM_OFFSET, Subroutine Uniform Variables
void ProgramParameteri(uint program, int GetUniformLocation(uint program, [2.11.8] [2.14.8]
const char *name); UNIFORM_{ARRAY, MATRIX}_STRIDE,
enum pname, int value); UNIFORM_IS_ROW_MAJOR int GetSubroutineUniformLocation(
pname: PROGRAM_SEPARABLE, uint GetUniformBlockIndex(uint program, uint program, enum shadertype,
PROGRAM_BINARY_{RETRIEVABLE_HINT}, const char *uniformBlockName); Load Uniform Vars. In Default Uniform Block const char *name);
value: TRUE, FALSE void Uniform{1234}{ifd}(int location, uint GetSubroutineIndex(uint program,
void DeleteProgram(uint program); void GetActiveUniformBlockName( T value); enum shadertype, const char *name);
uint program, uint uniformBlockIndex, void GetActiveSubroutineUniformiv(
sizei bufSize, sizei *length, void Uniform{1234}{ifd}v(int location, uint program, enum shadertype,
Program Pipeline Objects [2.11.4] [2.14.4] char *uniformBlockName); sizei count, const T value);
void GenProgramPipelines(sizei n, uint index, enum pname, int *values);
uint *pipelines); void GetActiveUniformBlockiv(uint void Uniform{1234}ui(int location, T value); pname: {NUM_}COMPATIBLE_SUBROUTINES,
program, UNIFORM_SIZE, UNIFORM_NAME_LENGTH
void DeleteProgramPipelines(sizei n, uint uniformBlockIndex, enum pname, void Uniform{1234}uiv(int location,
sizei count, const T value); void GetActiveSubroutineUniformName(
const uint *pipelines); int *params); uint program, enum shadertype,
void BindProgramPipeline(uint pipeline); pname: UNIFORM_BLOCK_{BINDING, DATA_SIZE}, void UniformMatrix{234}{fd}v( uint index, sizei bufsize, sizei *length,
UNIFORM_BLOCK_NAME_{LENGTH, UNIFORM}, int location, sizei count, char *name);
void UseProgramStages(uint pipeline, UNIFORM_BLOCK_ACTIVE_UNIFORMS_INDICES, boolean transpose, const T *value);
bitfield stages, uint program); void GetActiveSubroutineName(
stages: ALL_SHADER_BITS or the Bitwise OR of
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
void UniformMatrix{2x3,3x2,2x4,4x2, uint program, enum shadertype,
TESS_{CONTROL, EVALUATION}_SHADER_BIT,
UNIFORM_BLOCK_REFERENCED_BY_{
3x4,4x3}{fd}v(int location, sizei count, uint index, sizei bufsize, sizei *length,
{VERTEX, GEOMETRY, FRAGMENT}_SHADER_BIT
FRAGMENT_SHADER, GEOMETRY_SHADER,
boolean transpose, const T *value); char *name);
TESS_CONTROL_SHADER, TESS_EVALUATION_SHADER}
(Shaders and Programs Continue >)
Reading, and Copying Pixels type: {HALF_}FLOAT, {UNSIGNED_}BYTE, {UNSIGNED_}SHORT, BITMAP, Copying Pixels [4.3.2] [4.3.3]
{UNSIGNED_}INT, FLOAT_32_UNSIGNED_INT_24_8_REV, and
Reading Pixels [4.3.1] [4.3.2] void CopyPixels(int x, int y, sizei width, sizei height, enum type);
UNSIGNED_{BYTE, SHORT, INT}_* values from [Table 3.2] [Table 3.5] type: COLOR, STENCIL, DEPTH, DEPTH_STENCIL
void ReadPixels(int x, int y, sizei width, sizei height,
enum format, enum type, void *data); void ReadBuffer(enum src); void BlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
format: {COLOR, STENCIL}_INDEX, DEPTH_{COMPONENT, STENCIL}, src: NONE, FRONT{_LEFT, RIGHT}, LEFT, RIGHT, BACK{_LEFT, RIGHT}, int dstX0, int dstY0, int dstX1, int dstY1, bitfield mask,
RED, GREEN, BLUE, RG, RGB, RGBA, LUMINANCE{_ALPHA}, BGR, FRONT_AND_BACK, AUXi (i = [0, AUX_BUFFERS - 1 ]), enum filter);
{RED, GREEN, BLUE, ALPHA, RG, RGB, RGBA, BGR, BGRA}_INTEGER, COLOR_ATTACHMENTi (i = [0, MAX_COLOR_ATTACHMENTS - 1]) mask: Bitwise OR of {COLOR, DEPTH, STENCIL}_BUFFER_BIT
BGRA, ALPHA [Table 3.3] [Table 3.6] filter: LINEAR, NEAREST
(more parameters ) Also see DrawPixels, ClampColor, and PixelZoom in the Rasterization section of this reference card.
The OpenGL® Shading Language is used to create shaders for each of the Preprocessor [3.3]
programmable processors contained in the OpenGL processing pipeline. Preprocessor Operators
[n.n.n] and [Table n.n] refer to sections and tables in the OpenGL Shading Preprocessor operators follow C++ standards. Expressions are evaluated according to the behavior
Language 4.10 specification at www.opengl.org/registry of the host processor, not the processor targeted by the shader.
Content shown in blue is removed from the OpenGL 4.1 core profile and #version 410 “#version 410” is required in shaders using version 4.10 of the language.
present only in the OpenGL 4.1 compatibility profile. Use profile to indicate core or compatibilty. If no profile specified, the
#version 410 profile default is core.
#extension
Types [4.1] Integer Sampler Types (Opaque) extension_name : behavior • behavior: require, enable, warn, disable
• extension_name: the extension supported by the compiler, or “all”
Transparent Types isampler[1,2,3]D integer 1D, 2D, or 3D texture #extension all : behavior
void no function return value isamplerCube integer cube mapped texture
bool Boolean isampler2DRect int. 2D rectangular texture Preprocessor Directives
int, uint signed/unsigned integers isampler[1,2]DArray integer 1D, 2D array texture Each number sign (#) can be preceded in its line only by spaces or horizontal tabs.
float single-precision floating- isamplerBuffer integer buffer texture # #define #elif #else #endif #error
point scalar #extension #if #ifdef #ifndef #include #line
isampler2DMS int. 2D multi-sample texture #pragma #undef #version
double double-precision floating isampler2DMSArray int. 2D multi-sample array tex.
scalar
isamplerCubeArray int. cube map array texture Predefined Macros
vec2, vec3, vec4 floating point vector
dvec2, dvec3, dvec4 double precision floating- Unsigned Integer Sampler Types (Opaque) __LINE__ __FILE__ Decimal integer constants. FILE says which source string number is being
point vectors processed, or the path of the string if the string was an included string
usampler[1,2,3]D uint 1D, 2D, or 3D texture
bvec2, bvec3, bvec4 Boolean vectors usamplerCube uint cube mapped texture GL_compatibility_profile Integer 1 if the implementation supports the compatibility profile
ivec2, ivec3, ivec4 signed and unsigned integer usampler2DRect uint rectangular texture
uvec2, uvec3, uvec4 vectors __VERSION__ Decimal integer, e.g.: 410
mat2, mat3, mat4 2x2, 3x3, 4x4 float matrix usampler[1,2]DArray 1D or 2D array texture
mat2x2, mat2x3, 2-column float matrix of usamplerBuffer uint buffer texture
mat2x4 2, 3, or 4 rows usampler2DMS uint 2D multi-sample texture Qualifiers Uniform Qualifiers [4.3.5]
Declare global variables with same values
mat3x2, mat3x3, 3-column float matrix of usampler2DMSArray uint 2D multi-sample array tex. Storage Qualifiers [4.3] across entire primitive processed. Examples:
mat3x4 2, 3, or 4 rows Declarations may have one storage qualifier.
usamplerCubeArray uint cube map array texture uniform vec4 lightPosition;
mat4x2, mat4x3, 4-column float matrix of
mat4x4 2, 3, or 4 rows Implicit Conversions (All others must use constructors) (default) local read/write memory, uniform vec3 color = vec3(0.7, 0.7, 0.2);
none
or input parameter
dmat2, dmat3, dmat4 2x2, 3x3, 4x4 double- int -> uint Layout Qualifiers [4.3.8]
precision float matrix int, uint -> float compile-time constant, or read-only layout(layout-qualifiers) block-declaration
const
dmat2x2, dmat2x3, 2-col. double-precision float int, uint, float -> double function parameter layout(layout-qualifiers) in/out/uniform
dmat2x4 matrix of 2, 3, 4 rows
ivec2|3|4 -> uvec2|3|4 linkage into shader from previous layout(layout-qualifiers) in/out/uniform
dmat3x2, dmat3x3, 3-col. double-precision float in
ivec2|3|4 -> vec2|3|4 stage declaration
dmat3x4 matrix of 2, 3, 4 rows
uvec2|3|4 -> vec2|3|4 linkage w/centroid based Input Layout Qualifiers
dmat4x2, dmat4x3, 4-column double-precision centroid in
dmat4x4 float matrix of 2, 3, 4 rows vec2|3|4 -> dvec2|3|4 interpolation For all shader stages:
ivec2|3|4 -> dvec2|3|4 location = integer-constant
Floating-Point Sampler Types (Opaque) input linkage w/per-sample
uvec2|3|4 -> dvec2|3|4 sample in For tessellation evaluation shaders:
interpolation
sampler[1,2,3]D 1D, 2D, or 3D texture mat2|3|4 -> dmat2|3|4 triangles, quads, equal_spacing, isolines,
mat2x3|2x4 -> dmat2x3|2x4 out linkage out of a shader to next stage fractional_{even,odd}_spacing, cw, ccw,
samplerCube cube mapped texture point_mode
sampler2DRect rectangular texture mat3x2|3x4 -> dmat3x2|3x4 linkage w/centroid based
centroid out For geometry shader inputs:
mat4x2|4x3 -> dmat4x2|4x3 interpolation
sampler[1,2]DShadow 1D,2D depth texture/ points, lines, {lines,triangles}_adjacency,
compare Aggregation of Basic Types output linkage w/per-sample triangles, invocations = integer-constant
sample out
Arrays float[3] foo; float foo[3]; interpolation For fragment shaders only for
sampler2DRectShadow rectangular texture/
comparison • structures and blocks can be arrays linkage between a vertex shader and redeclaring built-in variable gl_FragCoord:
• supports only 1-dimensional arrays attribute ‡ origin_upper_left, pixel_center_integer
sampler[1,2]DArray 1D or 2D array texture OpenGL for per-vertex data
• structure members can be arrays
sampler[1,2]DArrayShadow 1D or 2D array depth Structures struct type-name { linkage between a shader, OpenGL, Output Layout Qualifiers
texture/comparison members uniform For all shader stages:
and the application
} struct-name[]; location = integer-constant
samplerBuffer buffer texture // optional variable declaration, linkage between a vertex shader and
varying ‡ For tessellation control shaders:
sampler2DMS 2D multi-sample texture optionally an array a fragment shader for interpolated vertices = integer-constant
centroid varying ‡
Blocks in/out/uniform block-name { data
sampler2DMSArray 2D multi-sample array For geometry shader outputs:
texture // interface matching by block name points, line_strip, triangle_strip,
patch in tessellation eval. shader input
optionally-qualified members max_vertices = integer-constant,
samplerCubeArray cube map array texture } instance-name[]; patch out tessellation control shader output stream = integer-constant
samplerCubeArrayShadow cube map array depth // optional instance name, optionally
texture with comparison an array ‡ Qualifier is deprecated but not removed from core specification. (Qualifiers Continue >)
Built-In Variables [7] Tessellation Control (continued) Geometry Language Built-In Constants [7.3]
Shaders communicate with fixed-function Inputs (continued): The following built-in constants with minimum
Inputs: values are provided to all shaders. The actual
OpenGL pipeline stages and other shader in int gl_PatchVerticesIn; in gl_PerVertex {
executables through built-in input and output in int gl_PrimitiveID; values used are implementation- dependent, but
vec4 gl_Position;
variables. Redeclare matching subsets of these in int gl_InvocationID; float gl_PointSize; must be at least the value shown.
variables and blocks to establish matching float gl_ClipDistance[]; const int gl_MaxTextureUnits = 2;
interfaces when using multiple programs. Outputs: (... plus deprecated Vertex Language Outputs) const int gl_MaxTextureCoords = 8;
Vertex Language out gl_PerVertex { } gl_in[]; const int gl_MaxClipPlanes = 8;
Inputs:
vec4 gl_Position;
in int gl_PrimitiveIDIn;
const int gl_MaxVertexAttribs = 16;
float gl_PointSize; in int gl_InvocationID; const int gl_MaxVertexUniformComponents = 1024;
in int gl_VertexID; float gl_ClipDistance[]; const int gl_MaxVaryingFloats = 60;
in int gl_InstanceID; (... plus deprecated Vertex Language Outputs) const int gl_MaxVaryingComponents = 60;
in vec4 gl_Color; Outputs: const int gl_MaxVertexOutputComponents = 64;
} gl_out[]; out gl_PerVertex {
in vec4 gl_SecondaryColor; const int gl_MaxGeometryInputComponents = 64;
in vec3 gl_Normal; vec4 gl_Position;
patch out float gl_TessLevelOuter[4]; float gl_PointSize; const int gl_MaxGeometryOutputComponents = 128;
in vec4 gl_Vertex; patch out float gl_TessLevelInner[2]; float gl_ClipDistance[]; const int gl_MaxFragmentInputComponents = 128;
in vec4 gl_MultiTexCoordn // n is 0...7 (... plus deprecated Vertex Language Outputs) const int gl_MaxVertexTextureImageUnits = 16;
in float gl_FogCoord; }; const int gl_MaxCombinedTextureImageUnits = 80;
Outputs: Tessellation Evaluation Language const int gl_MaxTextureImageUnits = 16;
out gl_PerVertex { Inputs:
out int gl_PrimitiveID; const int gl_MaxFragmentUniformComponents = 1024;
out int gl_Layer; const int gl_MaxDrawBuffers = 8;
vec4 gl_Position; in gl_PerVertex { out int gl_ViewportIndex; const int gl_MaxClipDistances = 8;
float gl_PointSize; vec4 gl_Position; const int gl_MaxGeometryTextureImageUnits = 16;
float gl_ClipDistance[]; float gl_PointSize; const int gl_MaxGeometryOutputVertices = 256;
float gl_ClipDistance[];
Fragment Language
vec4 gl_ClipVertex; const int gl_MaxGeometryTotalOutputComponents = 1024;
vec4 gl_FrontColor; (... plus deprecated Vertex Language Outputs) Inputs: const int gl_MaxGeometryUniformComponents = 1024;
vec4 gl_BackColor; } gl_in[gl_MaxPatchVertices]; in vec4 gl_FragCoord; const int gl_MaxGeometryVaryingComponents = 64;
vec4 gl_FrontSecondaryColor; in bool gl_FrontFacing; const int gl_MaxTessControlInputComponents = 128;
in float gl_ClipDistance[]; const int gl_MaxTessControlOutputComponents = 128;
vec4 gl_BackSecondaryColor; in int gl_PatchVerticesIn; in vec2 gl_PointCoord;
vec4 gl_TexCoord[]; in int gl_PrimitiveID; const int gl_MaxTessControlTextureImageUnits = 16;
in int gl_PrimitiveID; const int gl_MaxTessControlUniformComponents = 1024;
float gl_FogFragCoord; in vec3 gl_TessCoord; in int gl_SampleID;
patch in float gl_TessLevelOuter[4]; in vec2 gl_SamplePosition; const int gl_MaxTessControlTotalOutputComponents = 4096;
}; const int gl_MaxTessEvaluationInputComponents = 128;
patch in float gl_TessLevelInner[2]; in float gl_FogFragCoord;
in vec4 gl_TexCoord[]; const int gl_MaxTessEvaluationOutputComponents = 128;
Tessellation Control Language in vec4 gl_Color; const int gl_MaxTessEvaluationTextureImageUnits = 16;
Inputs: Outputs: in vec4 gl_SecondaryColor; const int gl_MaxTessEvaluationUniformComponents = 1024;
in gl_PerVertex { out gl_PerVertex { const int gl_MaxTessPatchComponents = 120;
vec4 gl_Position; vec4 gl_Position; const int gl_MaxPatchVertices = 32;
Outputs: const int gl_MaxTessGenLevel = 64;
float gl_PointSize; float gl_PointSize; out vec4 gl_FragColor;
float gl_ClipDistance[]; float gl_ClipDistance[]; out vec4 gl_FragData[gl_MaxDrawBuffers]; const int gl_MaxViewports = 16;
(... plus deprecated Vertex Language Outputs) out float gl_FragDepth; const int gl_MaxVertexUniformVectors = 256;
(... plus deprecated Vertex Language Outputs) const int gl_MaxFragmentUniformVectors = 256;
} gl_in[gl_MaxPatchVertices]; }; out int gl_SampleMask[];
const int gl_MaxVaryingVectors = 15;
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.
©2010 Khronos Group - Rev. 0610 Reference card production by Miller & Mattson www.millermattson.com www.opengl.org/registry