OpenGL Quick Reference
OpenGL Quick Reference
Page 1
OpenGL Command Syntax [2.2] GL commands are formed from a return type, a name, and optionally up to 4 characters (or character pairs) from the Command Letters table (to the left), as shown by the prototype:
return-type Name{1234}{b s i i64 f d ub us ui ui64}{v} ([args ,] T arg1 , . . . , T argN [, args]);
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 suffixes. N is 1, 2, 3, or 4 if present. If v is present, an array of N items is passed by a pointer. For brevity, the OpenGL documentation and this reference may omit the standard prefixes. The actual names are of the forms:
glFunctionName(), GL_CONSTANT, GLtype
target: see BeginQuery, plus TIMESTAMP pname: CURRENT_QUERY, QUERY_COUNTER_BITS
enum GetError(void);
OpenGL Operation
Letters are used in commands to denote types. ub - ubyte (8 bits) us ui dushort (16 bits) uint (32 bits) double (64 bits)
1-bit sign, 5-bit exponent, 10-bit mantissa no sign bit, 5-bit exponent, 6-bit mantissa no sign bit, 5-bit exponent, 5-bit mantissa
boolean IsQuery(uint id); void GetQueryIndexediv(enum target, uint index, enum pname, int *params);
target: see BeginQuery pname: CURRENT_QUERY, QUERY_COUNTER_BITS
Synchronization
void BeginQueryIndexed(enum target, uint index, uint id); void EndQuery(enum target); void EndQueryIndexed(enum target, uint index); void GetQueryiv(enum target, enum pname, int *params);
(parameters )
void GetQueryObjectiv(uint id, enum pname, int *params); void GetQueryObjectuiv(uint id, enum pname, uint *params); void GetQueryObjecti64v(uint id, enum pname, int64 *params); void GetQueryObjectui64v(uint id, enum pname, uint64 *params);
pname: QUERY_RESULT{_AVAILABLE}
void GetSynciv(sync sync, enum pname, sizei bufSize, sizei *length, int *values); boolean IsSync(sync sync);
uint GetProgramResourceIndex( uint program, enum programInterface, const char *name); void GetProgramResourceName( uint program, enum programInterface, uint index, sizei bufSize, sizei *length, char *name); void GetProgramResourceiv(uint program, enum programInterface, uint index, sizei propCount, const enum *props, sizei bufSize, sizei *length, int *params);
*props: [see Table 7.2]
Timer queries use query objects to track the amount of time needed to fully complete a set of GL commands.
Mapping/Unmapping Buffer Data [6.3] void *MapBufferRange(enum target, intptr offset, sizeiptr length, bitfield access);
access: The logical OR of MAP_{READ, WRITE}_BIT, MAP_INVALIDATE_{BUFFER, RANGE}_BIT, MAP_{FLUSH_EXPLICIT, UNSYNCHRONIZED}_BIT target: see BindBuffer access: READ_ONLY, WRITE_ONLY, READ_WRITE
void *MapBuffer(enum target, enum access); void FlushMappedBufferRange( enum target, intptr offset, sizeiptr length);
target: see BindBuffer target: see BindBuffer
void ShaderSource(uint shader, sizei count, const char * const * string, const int *length); void CompileShader(uint shader); void ReleaseShaderCompiler(void); void DeleteShader(uint shader); boolean IsShader(uint shader); void ShaderBinary(sizei count, const uint *shaders, enum binaryformat, const void *binary, sizei length);
int GetProgramResourceLocation( uint program, enum programInterface, const char *name); int GetProgramResourceLocationIndex( uint program, enum programInterface, const char *name);
void BindBufferRange(enum target, uint index, uint buffer, intptr offset, sizeiptr size);
void InvalidateBufferSubData(uint buffer, intptr offset, sizeiptr length); void InvalidateBufferData(uint buffer);
uint CreateProgram(void); void AttachShader(uint program, uint shader); void DetachShader(uint program, uint shader); void LinkProgram(uint program); void UseProgram(uint program); uint CreateShaderProgramv(enum type, sizei count, const char * const * strings); void ProgramParameteri(uint program, enum pname, int value);
pname: PROGRAM_SEPARABLE, PROGRAM_BINARY_RETRIEVABLE_HINT value: TRUE, FALSE
Program Pipeline Objects [7.4] void GenProgramPipelines(sizei n, uint *pipelines); void DeleteProgramPipelines(sizei n, const uint *pipelines); void BindProgramPipeline(uint pipeline); void UseProgramStages(uint pipeline, bitfield stages, uint program);
void CopyBufferSubData(enum readtarget, enum writetarget, intptr readoffset, intptr writeoffset, sizeiptr size);
readtarget and writetarget: see BindBuffer
stages: ALL_SHADER_BITS or the bitwise OR of TESS_{CONTROL, EVALUATION}_SHADER_BIT, {VERTEX, GEOMETRY, FRAGMENT}_SHADER_BIT, COMPUTE_SHADER_BIT
void BufferData(enum target, sizeiptr size, const void *data, enum usage);
target: see BindBuffer usage: STREAM_{DRAW, READ, COPY}, {DYNAMIC, STATIC}_{DRAW, READ, COPY}
boolean IsBuffer(uint buffer); void GetBufferParameteriv(enum target, enum pname, int *data);
target: see BindBuffer pname: BUFFER_SIZE, BUFFER_USAGE, BUFFER_ACCESS{_FLAGS}, BUFFER_MAPPED, BUFFER_MAP_{OFFSET, LENGTH} target: see BindBuffer pname: see GetBufferParameteriv, target: see BindBuffer
void ClearBufferSubData(enum target, enum internalFormat, intptr offset, sizeiptr size, enum format, enum type, const void *data);
target: see BindBuffer internalformat: see TexBuffer on pg. 2 of this card format: RED, GREEN, BLUE, RG, RGB, RGBA, BGR, BGRA,{RED, GREEN, BLUE, RG, RGB}_INTEGER, {RGBA, BGR, BGRA} _INTEGER, STENCIL_INDEX, DEPTH_{COMPONENT, STENCIL}
void GetBufferParameteri64v(enum target, enum pname, int64 *data); void GetBufferSubData(enum target, intptr offset, sizeiptr size, void *data); void GetBufferPointerv(enum target, enum pname, void **params);
target: see BindBuffer pname: BUFFER_MAP_POINTER
void ClearBufferData(enum target, enum internalformat, enum format, enum type, const void *data);
programInterface: UNIFORM{_BLOCK}, Uniform Variables [7.6] PROGRAM_{INPUT, OUTPUT}, BUFFER_VARIABLE, int GetUniformLocation(uint program, SHADER_STORAGE_BLOCK, const char *name); ATOMIC_COUNTER_BUFFER, {GEOMETRY, VERTEX}_SUBROUTINE, void GetActiveUniformName(uint program, TESS_{CONTROL, EVALUATION}_SUBROUTINE, uint uniformIndex, sizei bufSize, {FRAGMENT, COMPUTE}_SUBROUTINE, sizei *length, char *uniformName); TESS_{CONTROL, EVALUATION}_SUBROUTINE_UNIFORM, void GetUniformIndices(uint program, {GEOMETRY, VERTEX}_SUBROUTINE_UNIFORM, sizei uniformCount, const char **uniformNames, {FRAGMENT, COMPUTE}_SUBROUTINE_UNIFORM, uint *uniformIndices); TRANSFORM_FEEDBACK_VARYING pname: ACTIVE_RESOURCES, MAX_NAME_LENGTH, MAX_NUM_ACTIVE_VARIABLES, (Continued on next page >) MAX_NUM_COMPATIBLE_SUBROUTINES
void GetProgramBinary(uint program, sizei bufSize, sizei *length, enum *binaryFormat, void *binary); void ProgramBinary(uint program, enum binaryFormat, const void *binary, sizei length);
www.opengl.org/registry
Page 2
Shaders and Programs (cont.)
void GetActiveUniform(uint program, uint index, sizei bufSize, sizei *length, int *size, enum *type, char *name);
*type returns: DOUBLE_{VECn, MATn, MATnxn}, DOUBLE, FLOAT_{VECn, MATn, MATnxn}, FLOAT, INT, INT_VECn, UNSIGNED_INT{_VECn}, BOOL, BOOL_VECn, or any value in [Table 7.3]
void GetActiveUniformsiv(uint program, sizei uniformCount, const uint *uniformIndices, void UniformMatrix{234}{f d}v( Subroutine Uniform Variables [7.8] int location, sizei count, boolean transpose, Parameter shadertype for the functions in this enum pname, int *params); const float *value); pname: UNIFORM_{TYPE, SIZE, NAME_LENGTH}, section may be one of
UNIFORM_BLOCK_INDEX, UNIFORM_OFFSET, UNIFORM_{ARRAY, MATRIX}_STRIDE, UNIFORM_IS_ROW_MAJOR, UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX
void Uniform{1234}{i f d}(int location, T value); void UniformBlockBinding(uint program, uint uniformBlockIndex, void Uniform{1234}{i f d}v(int location, uint uniformBlockBinding); sizei count, const T *value); Shader Buffer Variables [7.7] void Uniform{1234}ui(int location, T value); void ShaderStorageBlockBinding( uint program, uint storageBlockIndex, void Uniform{1234}uiv(int location, uint storageBlockBinding); sizei count, const T *value);
barriers: ALL_BARRIER_BITS or the OR of: {VERTEX_ATTRIB_ARRAY, ELEMENT_ARRAY, UNIFORM, TEXTURE_FETCH, BUFFER_UPDATE, SHADER_IMAGE_ACCESS, COMMAND, PIXEL_BUFFER, TEXTURE_UPDATE, FRAMEBUFFER, TRANSFORM_FEEDBACK, ATOMIC_COUNTER, SHADER_STORAGE}_BARRIER_BIT
void UniformMatrix{2x3,3x2,2x4,4x2,3x4, 4x3}{fd}v(int location, sizei count, boolean transpose, const float *value); void ProgramUniform{1234}{i f d}( uint program, int location, T value); void ProgramUniform{1234}{i f d}v( uint program, int location, sizei count, const T *value); void ProgramUniform{1234}ui( uint program, int location, T value); void ProgramUniform{1234}uiv( uint program, int location, sizei count, const T *value); void ProgramUniformMatrix{234}{f d}v( uint program, int location, sizei count, boolean transpose, const float *value);
uint GetUniformBlockIndex(uint program, const char *uniformBlockName); void GetActiveUniformBlockName( uint program, uint uniformBlockIndex, sizei bufSize, sizei length, char *uniformBlockName); void GetActiveUniformBlockiv( uint program, uint uniformBlockIndex, enum pname, int *params);
int GetSubroutineUniformLocation( uint program, enum shadertype, const char *name); uint GetSubroutineIndex(uint program, enum shadertype, const char *name); void GetActiveSubroutineName( uint program, enum shadertype, uint index, sizei bufsize, sizei *length, char *name); void GetActiveSubroutineUniformName( uint program, enum shadertype, uint index, sizei bufsize, sizei *length, char *name); void GetActiveSubroutineUniformiv( uint program, enum shadertype, uint index, enum pname, int *values);
pname: UNIFORM_BLOCK_{BINDING, DATA_SIZE}, UNIFORM_BLOCK_NAME_LENGTH, UNIFORM_BLOCK_ACTIVE_UNIFORMS{_INDICES}, UNIFORM_BLOCK_REFERENCED_BY_x_SHADER, where x may be one of VERTEX, FRAGMENT, COMPUTE, GEOMETRY, TESS_CONTROL, or TESS_EVALUATION
void GetActiveAtomicCounterBufferiv( uint program, uint bufferIndex, enum pname, int *params);
pname: see GetActiveUniformBlockiv
void ProgramUniformMatrixf{2x3,3x2,2x4,4x2, pname: {NUM_}COMPATIBLE_SUBROUTINES 3x4, 4x3}{f d}v( void UniformSubroutinesuiv(enum shadertype, uint program, int location, sizei count, sizei count, const uint *indices); boolean transpose, const float *value);
pname: {DELETE, LINK, VALIDATE}_STATUS, INFO_LOG_LENGTH, ATTACHED_SHADERS, ACTIVE_{UNIFORMS, ATTRIBUTES}, ACTIVE_ATTRIBUTE_MAX_LENGTH, ACTIVE_UNIFORM_{BLOCKS, MAX_LENGTH}, ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, ACTIVE_ATOMIC_COUNTER_BUFFERS, TRANSFORM_FEEDBACK_{BUFFER_MODE, VARYINGS}, TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, GEOMETRY_{INPUT, OUTPUT}_TYPE, COMPUTE_WORK_GROUP_SIZE, GEOMETRY_{SHADER_INVOCATIONS, VERTICES_OUT}
void TexImage1D(enum target, int level, int internalformat, sizei width, int border, enum format, enum type, const void *data);
target: TEXTURE_1D, PROXY_TEXTURE_1D type, internalformat, format: see TexImage3D
void TexSubImage2D(enum target, int level, int xoffset, int yoffset, sizei width, sizei height, enum format, enum type, const void *data);
target: see CopyTexImage2D format, type: see TexImage3D
void CompressedTexSubImage1D( enum target, int level, int xoffset, sizei width, enum format, sizei imageSize, const void *data);
target: see TexSubImage1D format: see TexImage1D
void TexImage2D(enum target, int level, int internalformat, sizei width, sizei height, int border, enum format, enum type, const void *data);
target: PROXY_TEXTURE_CUBE_MAP, POSITIVE_{X, Y, Z}, NEGATIVE_{X, Y, Z} internalformat, format, type: see TexImage3D
void TexSubImage3D(enum target, int level, int xoffset, int yoffset, int zoffset, sizei width, sizei height, sizei depth, enum format, enum type, const void *data);
target: TEXTURE_3D, TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY format, type: see TexImage3D target: see TexSubImage1D
void CompressedTexSubImage2D( enum target, int level, int xoffset, int yoffset, sizei width, sizei height, enum format, sizei imageSize, cont void *data);
target: see TexSubImage2D format: see TexImage2D
void TexImage3D(enum target, int level, int internalformat, sizei width, sizei height, sizei depth, int border, enum format, enum type, const void *data);
void CopyTexSubImage1D(enum target, int level, int xoffset, int x, int y, sizei width); void CopyTexSubImage2D(enum target, int level, int xoffset, int yoffset, int x, int y, sizei width, sizei height);
void GenSamplers(sizei count, uint *samplers); void BindSampler(uint unit, uint sampler); void SamplerParameter{i f}(uint sampler, enum pname, T param);
pname: TEXTURE_x where x may be WRAP_{S, T, R}, {MIN, MAG}_FILTER, {MIN, MAX}_LOD, BORDER_COLOR, LOD_BIAS, COMPARE_{MODE, FUNC}
target: TEXTURE_{3D, 2D_ARRAY, CUBE_MAP_ARRAY}, PROXY_TEXTURE_{3D, 2D_ARRAY, CUBE_MAP_ARRAY} target: see TexSubImage2D internalformat: DEPTH_{COMPONENT, STENCIL}, RED, void CopyTexSubImage3D(enum target, INTENSITY, RG, RGB, RGBA; or a sized internal format int level, int xoffset, int yoffset, int zoffset, from [Tables 8.12 - 8.13], COMPRESSED_{RED_RGTC1}, int x, int y, sizei width, sizei height); COMPRESSED_ {RG_RGTC2}, target: see TexSubImage3D COMPRESSED_SIGNED_{RED_RGTC1, RG_RGTC2}, or a specific compressed format in [Table 8.14] Compressed Texture Images [8.7] format: DEPTH_{COMPONENT, STENCIL}, RED, GREEN, void CompressedTexImage1D(enum target, BLUE, RG, RGB, RGBA, BGR, BGRA, BGRA_INTEGER, int level, enum internalformat, {RED, GREEN, BLUE}_INTEGER, {RG, RGB}_INTEGER, sizei width, int border, sizei imageSize, {RGBA, BGR}_INTEGER [Table 8.3] const void *data); type: {UNSIGNED_}{BYTE, SHORT, INT}, HALF_FLOAT, target: TEXTURE_1D, PROXY_TEXTURE_1D FLOAT, or a value from [Table 8.2] internalformat: values are implementation-dependent
void CompressedTexSubImage3D( enum target, int level, int xoffset, int yoffset, int zoffset, sizei width, sizei height, sizei depth, enum format, sizei imageSize, const void *data);
void TexImage2DMultisample(enum target, sizei samples, int internalformat, sizei width, sizei height, boolean fixedsamplelocations); void TexImage3DMultisample(enum target, sizei samples, int internalformat, sizei width, sizei height, sizei depth, boolean fixedsamplelocations);
void CompressedTexImage2D(enum target, int level, enum internalformat, sizei width, sizei height, int border, sizei imageSize, const void *data);
target: see TexImage2D, omitting compressed rectangular texture formats internalformat: see CompressedTexImage3D, plus COMPRESSED_x where x may be {RGB8, SRGB8}_ETC2, {RGB8, SRGB8}_PUNCHTHROUGH_ALPHA1_ETC2
target: {PROXY_}TEXTURE_2D_MULTISAMPLE_ARRAY internalformat: RED, RG, RGB, RGBA, STENCIL_INDEX, DEPTH_{COMPONENT, STENCIL}, or sized internal formats corresponding to these base formats
void CopyTexImage2D(enum target, int level, enum internalformat, int x, int y, sizei width, sizei height, int border);
void TexSubImage1D(enum target, int level, int xoffset, sizei width, enum format, enum type, const void *data);
target: TEXTURE_1D format, type: see TexImage1D
void CompressedTexImage3D(enum target, int level, enum internalformat, sizei width, sizei height, sizei depth, int border, sizei imageSize, const void *data);
target: see TexImage3D internalformat: COMPRESSED_x where x may be {SIGNED_}RED_RGTC1, {SIGNED_}RG_RGTC2, {RGBA, SRGB_ALPHA}_BPTC_UNORM, RGB_BPTC_{SIGNED, UNSIGNED}_FLOAT
void TexBufferRange(enum target, enum internalFormat, uint buffer, intptr offset, sizeiptr size); void TexBuffer(enum target, enum internalformat, uint buffer);
target: TEXTURE_BUFFER internalformat: R8{I,UI}, R16{F, I, UI}, R32{F, I, UI}, RG8{I, UI}, RG16{F, I, UI}, RG32{F, I, UI}, RGB32{F, I, UI}, RGBA8{I, UI}, RGBA16{F, I, UI}, RGBA32{F, I, UI}
(Continued on next page >)
www.opengl.org/registry
Page 3
void TexStorage3D(enum target, sizei levels, enum internalformat, sizei width, sizei height, sizei depth);
target: TEXTURE_3D, PROXY_TEXTURE_3D, {PROXY_}TEXTURE_{CUBE_MAP, 2D}{_ARRAY} internalformat: see TexStorage1D
void TexParameter{i f}(enum target, enum pname, T param); void TexParameter{i f}v(enum target, enum pname, const T *params);
void GetTexLevelParameter{i f}v(enum target, Texture View [8.18] int lod, enum value, T data); void TextureView(uint texture, enum target, target: {PROXY_}TEXTURE_{1D, 2D, 3D}, uint origtexture, enum internalformat, TEXTURE_BUFFER, PROXY_TEXTURE_CUBE_MAP, uint minlevel, uint numlevels, {PROXY_}TEXTURE_{1D, 2D,CUBE_MAP}_ARRAY, uint minlayer, uint numlayers);
{PROXY_}TEXTURE_RECTANGLE, TEXTURE_CUBE_MAP_{POSITIVE, NEGATIVE}_{X, Y, Z}, {PROXY_}TEXTURE_2D_MULTISAMPLE{_ARRAY} value: TEXTURE_{WIDTH, HEIGHT, DEPTH}, TEXTURE_{SAMPLES, FIXED_SAMPLE_LOCATIONS}, TEXTURE_{INTERNAL_FORMAT, SHARED_SIZE}, TEXTURE_COMPRESSED{_IMAGE_SIZE}, TEXTURE_BUFFER_DATA_STORE_BINDING, TEXTURE_BUFFER_{OFFSET, SIZE}, TEXTURE_STENCIL_SIZE, TEXTURE_x_{SIZE, TYPE} (where x can be RED, GREEN, BLUE, ALPHA, DEPTH)
target: see BindTexture, plus TEXTURE_{BORDER_COLOR, SWIZZLE_RGBA} pname: DEPTH_STENCIL_TEXTURE_MODE or TEXTURE_x where x may be one of void GetTexImage(enum tex, int lod, WRAP_{S, T, R}, BORDER_COLOR, {MIN, MAG}_FILTER, enum format, enum type, void *img); LOD_BIAS,{MIN, MAX}_LOD, {BASE, MAX}_LEVEL, SWIZZLE_{R, G, B, A, RGBA}, COMPARE_{MODE, FUNC} tex: TEXTURE_{1, 2}D{_ARRAY}, TEXTURE_{3D, RECTANGLE, CUBE_MAP_ARRAY}, [Table 8.16] TEXTURE_CUBE_MAP_{POSITIVE, NEGATIVE}_{X, Y, Z} format: see ClearBufferSubData, pg 1 this card Enumerated Queries [8.11] type: {UNSIGNED_}BYTE, SHORT, INT, void GetTexParameter{if}v(enum target, enum value, T data); {HALF_}FLOAT, or value from [Table 8.2] target: see BindTexture void GetCompressedTexImage(enum target, value: see pname for TexParameter
target: TEXTURE_{1D, 2D,CUBE_MAP}{_ARRAY}, TEXTURE_3D, TEXTURE_{RECTANGLE, BUFFER}, TEXTURE_2D_MULTISAMPLE{_ARRAY} internalformat: RGBA{16, 32}{F, UI, I}, RGBA{8,16}{_SNORM}, RGBA8{UI, I}, RGB{16, 32}{F, UI, I}, RGB{8,16}{_SNORM}, RGB8{UI, I}, RGB9_E5, RGB10_{A2UI, A2}, RG{16, 32}{F, UI, I}, RG{8,16}{_SNORM}, RG8{UI, I}, R{16, 32}{F, UI, I}, R{8,16}{_SNORM}, R8{UI, I}, R11F_G11F_B10F, SRGB8{_ALPHA8}, COMPRESSED{_SIGNED}_RED_RGTC1, COMPRESSED{_SIGNED}_RG_RGTC2, COMPRESSED_RGBA_BPTC_UNORM, COMPRESSED_SRGB_ALPHA_BPTC_UNORM, COMPRESSED_RGB_BPTC_{UN}SIGNED_FLOAT
void TexStorage2DMultisample( enum target, sizei samples, enum internalformat, sizei width, sizei height, boolean fixedsamplelocations);
target: {PROXY_}TEXTURE_2D_MULTISAMPLE
void TexStorage3DMultisample( enum target, sizei samples, enum internalformat, sizei width, sizei height, sizei depth, boolean fixedsamplelocations);
target: {PROXY_}TEXTURE_2D_MULTISAMPLE_ARRAY
void InvalidateTexSubImage(uint texture, int level, int xoffset, int yoffset, int zoffset, sizei width, sizei height, sizei depth); void InvalidateTexImage(uint texture, int level);
Enable/Disable(TEXTURE_CUBE_MAP_SEAMLESS);
void TexStorage2D(enum target, sizei levels, enum internalformat, sizei width, sizei height);
Texture Image Loads/Stores [8.25] void BindImageTexture(uint index, uint texture, int level, boolean layered, int layer, enum access, enum format);
access: READ_ONLY, WRITE_ONLY, READ_WRITE format: RGBA{32,16}F, RG{32,16}F, R11F_G11F_B10F, R{32,16}F, RGBA{32,16,8}UI, RGB10_A2UI, RG{32,16,8}UI, R{32,16,8}UI, RGBA{32,16,8}I, RG{32,16,8}I, R{32,16,8}I, RGBA{16,8}, RGB10_A2, RG{16,8}, R{16,8}, RGBA{16,8}_SNORM, RG{16,8}_SNORM, R{16,8}_SNORM [Table 8.25]
Framebuffer Objects
void RenderbufferStorageMultisample( enum target, sizei samples, enum internalformat, sizei width, sizei height);
target: RENDERBUFFER internalformat: see TexImage3DMultisample
void GenFramebuffers(sizei n, uint *ids); void DeleteFramebuffers(sizei n, const uint *framebuffers); boolean IsFramebuffer(uint framebuffer);
void GetUniformSubroutineuiv( enum shadertype, int location, uint *params); void GetProgramStageiv(uint program, enum shadertype, enum pname, int *values);
Specify generic attributes with components of type float (VertexAttrib*), int or uint (VertexAttribI*), or double (VertexAttribL*).
pname: CURRENT_VERTEX_ATTRIB or VERTEX_ATTRIB_ARRAY_x where x is one of BUFFER_BINDING, DIVISOR, ENABLED, INTEGER, LONG, NORMALIZED, SIZE, STRIDE, or TYPE
void GetVertexAttribLdv(uint index, enum pname, double *params); void GetVertexAttribPointerv(uint index, enum pname, void **pointer);
pname: VERTEX_ATTRIB_ARRAY_POINTER
void GetFramebufferAttachmentParameteriv( enum target, enum attachment, enum pname, int *params);
boolean IsProgramPipeline(uint pipeline); void GetProgramPipelineiv(uint pipeline, enum pname, int *params);
pname: ACTIVE_PROGRAM, VALIDATE_STATUS, {VERTEX, FRAGMENT, GEOMETRY}_SHADER, TESS_{CONTROL, EVALUATION}_SHADER, INFO_LOG_LENGTH, COMPUTE_SHADER
void FramebufferTexture(enum target, enum attachment, uint texture, int level); void FramebufferTexture1D(enum target, enum attachment, enum textarget, uint texture, int level); void FramebufferTexture2D(enum target, enum attachment, enum textarget, uint texture, int level);
target: {DRAW_, READ_}FRAMEBUFFER attachment: DEPTH, FRONT_{LEFT, RIGHT}, STENCIL, void GetAttachedShaders(uint program, BACK_{LEFT, RIGHT}, COLOR_ATTACHMENTi, sizei maxCount, sizei *count, uint *shaders); {DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT pname: FRAMEBUFFER_ATTACHMENT_x where x may void GetShaderInfoLog(uint shader, sizei bufSize, sizei *length, char *infoLog); be OBJECT_{TYPE, NAME}, COMPONENT_TYPE, {RED, GREEN, BLUE, ALPHA, DEPTH, STENCIL}_SIZE, void GetProgramInfoLog(uint program, COLOR_ENCODING, TEXTURE_LEVEL, LAYERED, sizei bufSize, sizei *length, char *infoLog); TEXTURE_CUBE_MAP_FACE, TEXTURE_LAYER
textarget: TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z}, TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z}, TEXTURE_{2D, RECTANGLE, 2D_MULTISAMPLE} target, attachment: see FramebufferRenderbuffer
void BindRenderbuffer(enum target, uint renderbuffer); void GenRenderbuffers(sizei n, uint *renderbuffers); void DeleteRenderbuffers(sizei n, const uint *renderbuffers); boolean IsRenderbuffer(uint renderbuffer);
void GetProgramPipelineInfoLog( uint pipeline, sizei bufSize, sizei *length, char *infoLog);
void FramebufferTexture3D(enum target, enum attachment, enum textarget, uint texture, int level, int layer);
void GetShaderSource(uint shader, sizei bufSize, sizei *length, char *source); void GetShaderPrecisionFormat( enum shadertype, enum precisiontype, int *range, int *precision); void GetUniform{f d i ui}v(uint program, int location, T *params);
void FramebufferTextureLayer(enum target, enum attachment, uint texture, int level, int layer);
target, attachment: see FramebufferRenderbuffer
void VertexAttrib{1234}{s f d}(uint index, T values); void VertexAttrib{123}{s f d}v(uint index, const T *values); void VertexAttrib4{b s i f d ub us ui}v( uint index, const T *values); void VertexAttrib4Nub(uint index, T values); void VertexAttrib4N{b si ub us ui}v( uint index, const T *values); void VertexAttribI{1234}{i ui}(uint index, T values); void VertexAttribI{1234}{i ui}v(uint index, const T *values); void VertexAttribI4{b s ub us}v(uint index, const T *values); void VertexAttribL{1234}d(uint index, T values); void VertexAttribL{1234}dv(uint index, const T *values); void VertexAttribP{1234}ui(uint index, enum type, boolean normalized, uint value); void VertexAttribP{1234}uiv(uint index, enum type, boolean normalized, const uint *value);
type: {UNSIGNED_}INT_2_10_10_10_REV
www.opengl.org/registry
Page 4
void VertexAttribDivisor(uint index, void VertexAttribFormat(uint attribindex, uint divisor); int size, enum type, boolean normalized, unit relativeoffset); Enable/Disable(target);
type: {UNSIGNED_}BYTE, {UNSIGNED_}SHORT, {UNSIGNED_}INT, {HALF_}FLOAT, DOUBLE, FIXED, {UNSIGNED_}INT_2_10_10_10_REV
Vertex Arrays
target: PRIMITIVE_RESTART{_FIXED_INDEX}
All states related to definition of data used by vertex processor is in a vertex array object.
void GenVertexArrays(sizei n, uint *arrays); void DeleteVertexArrays(sizei n, const uint *arrays); void BindVertexArray(uint array); boolean IsVertexArray(uint array);
void BindVertexBuffer(uint bindingindex, uint buffer, intptr offset, sizei stride); void VertexAttribBinding(uint attribindex, uint bindingindex); void VertexAttribPointer(uint index, int size, enum type, boolean normalized, sizei stride, const void *pointer);
type: see VertexAttribFormat
void VertexAttribIPointer(uint index, int size, enum type, sizei stride, const void *pointer);
type: see VertexAttribIFormat index: [0, MAX_VERTEX_ATTRIBS - 1]
Clipping [13.5]
Enable/Disable(CLIP_DISTANCEi);
void DrawArraysInstancedBaseInstance( void VertexAttribLPointer(uint index, int size, enum mode, int first, sizei count, enum type, sizei stride, const void *pointer); sizei instancecount, uint baseinstance);
type: DOUBLE index: [0, MAX_VERTEX_ATTRIBS - 1]
void DrawArraysInstanced(enum mode, int first, sizei count, sizei instancecount); void DrawArraysIndirect(enum mode, const void *indirect);
void DepthRangeArrayv(uint first, sizei count, const double *v); void DepthRangeIndexed(uint index, double n, double f); void DepthRange(double n, double f); void DepthRangef(float n, float f); void ViewportArrayv(uint first, sizei count, const float *v); void ViewportIndexedf(uint index, float x, float y, float w, float h); void ViewportIndexedfv(uint index, const float *v); void Viewport(int x, int y, sizei w, sizei h);
Vertex shaders operate on array of 4-component items numbered from slot 0 to MAX_VERTEX_ATTRIBS - 1.
void GetActiveAttrib(uint program, uint index, sizei bufSize, sizei *length, int *size, enum *type, char *name); int GetAttribLocation(uint program, const char *name);
void TransformFeedbackVaryings(uint program, sizei count, const char * const *varyings, enum bufferMode);
bufferMode: {INTERLEAVED, SEPARATE}_ATTRIBS
void GetTransformFeedbackVarying( uint program, uint index, sizei bufSize, sizei *length, sizei *size, enum *type, char *name); void BeginTransformFeedback( enum primitiveMode);
(parameters )
void EndTransformFeedback(void); void PauseTransformFeedback(void); void ResumeTransformFeedback(void); void DrawTransformFeedback( enum mode, uint id);
mode: see Drawing Commands [10.5] above
void DrawTransformFeedbackInstanced( enum mode, uint id, sizei instancecount); void DrawTransformFeedbackStream( enum mode, uint id, uint stream); void DrawTransformFeedbackStreamInstanced( enum mode, uint id, uint stream, sizei instancecount);
Per-Fragment Operations
Flatshading [13.4]
Multisampling [14.3.1]
Enable/Disable(target);
pname: POINT_FADE_THRESHOLD_SIZE, POINT_SPRITE_COORD_ORIGIN param, params: The fade threshold if pname is POINT_FADE_THRESHOLD_SIZE; {LOWER, UPPER}_LEFT if pname is POINT_SPRITE_COORD_ORIGIN. LOWER_LEFT, UPPER_LEFT, pointer to point fade threshold. target: PROGRAM_POINT_SIZE
void PolygonMode(enum face, enum mode); void PolygonOffset(float factor, float units); Enable/Disable(target);
target: POLYGON_OFFSET_{POINT, LINE, FILL}
Enable/Disable(target);
Enable/Disable(SCISSOR_TEST); IsEnabled(SCISSOR_TEST); IsEnabledi(SCISSOR_TEST, uint index); void ScissorArrayv(uint first, sizei count, const int *v); void ScissorIndexed(uint index, int left, int bottom, sizei width, sizei height); void ScissorIndexedv(uint index, int *v); void Scissor(int left, int bottom, sizei width, sizei height);
Points [14.4]
pname: {UN}PACK_x where x may be SWAP_BYTES, LSB_FIRST, ROW_LENGTH, SKIP_{PIXELS, ROWS}, ALIGNMENT, IMAGE_HEIGHT, SKIP_IMAGES, COMPRESSED_BLOCK_{WIDTH, HEIGHT, DEPTH, SIZE}
void SampleCoverage(float value, boolean invert); void SampleMaski(uint maskNumber, bitfield mask);
(Continued on next page >)
www.opengl.org/registry
Page 5
void BlendFunc(enum src, enum dst);
srd, dst: see BlendFuncSeparate
Per-Fragment (cont.)
Enable/Disable(STENCIL_TEST); void StencilFunc(enum func, int ref, uint mask); void StencilFuncSeparate(enum face, enum func, int ref, uint mask);
Blending [17.3.8]
void StencilOp(enum sfail, enum dpfail, enum dppass); void StencilOpSeparate(enum face, enum sfail, enum dpfail, enum dppass);
face: FRONT, BACK, FRONT_AND_BACK sfail, dpfail, dppass: KEEP, ZERO, REPLACE, INCR, DECR, INVERT, INCR_WRAP, DECR_WRAP
src, dst, srcRGB, dstRGB, srcAlpha, dstAlpha: ZERO, ONE, SRC_ALPHA_SATURATE, {SRC, SRC1, DST, CONSTANT}_{COLOR, ALPHA}, ONE_MINUS_{SRC, SRC1}_{COLOR, ALPHA}, ONE_MINUS_{DST, CONSTANT}_{COLOR, ALPHA}
op: CLEAR, AND, AND_REVERSE, COPY, AND_INVERTED, NOOP, XOR, OR, NOR, EQUIV, INVERT, OR_REVERSE, COPY_INVERTED, OR_INVERTED, NAND, SET
void BlendEquation(enum mode); void BlendFunci(uint buf, enum src, enum dst); void BlendEquationSeparate(enum modeRGB, src, dst: see BlendFuncSeparate enum modeAlpha); mode, modeRGB, modeAlpha: MIN, MAX , void BlendFuncSeparatei(uint buf, FUNC_{ADD, SUBTRACT, REVERSE_SUBTRACT} enum srcRGB, enum dstRGB, enum srcAlpha, enum dstAlpha); void BlendEquationi(uint buf, enum mode); void BlendEquationSeparatei(uint buf, enum modeRGB, enum modeAlpha);
mode, modeRGB, modeAlpha: see BlendEquationSeparate dstRGB, dstAlpha, srcRGB, srcAlpha: see BlendFuncSeparate
void BlendColor(clampf red, clampf green, clampf blue, clampf alpha); void ClearBufferfi(enum buffer, int drawbuffer, float depth, int stencil);
buffer: DEPTH_STENCIL drawbuffer: 0
Whole Framebuffer
void ReadPixels(int x, int y, sizei width, sizei height, enum format, enum type, void *data);
void ClearColor(float r, float g, float b, float a); void ClearDepth(double d); void ClearDepthf(float d); void ClearStencil(int s); void ClearBuffer{i f ui}v(enum buffer, int drawbuffer, const T *value);
buffer: COLOR, DEPTH, STENCIL
void InvalidateSubFramebuffer( enum target, sizei numAttachments, const enum *attachments, int x, int y, sizei width, sizei height);
target: {DRAW_ , READ_}FRAMEBUFFER attachments: COLOR_ATTACHMENTi, DEPTH, {DEPTH, STENCIL}_ATTACHMENT, COLOR, {FRONT, BACK}_{LEFT, RIGHT}, AUXi, ACCUM, STENCIL
format: STENCIL_INDEX, RED, GREEN, BLUE, RG, RGB, RGBA, BGR, DEPTH_{COMPONENT, STENCIL}, {RED, GREEN, BLUE, RG, RGB}_INTEGER, {RGBA, BGR, BGRA}_INTEGER, BGRA [Table 8.3] type: {HALF_}FLOAT, {UNSIGNED_}BYTE, {UNSIGNED_}SHORT, {UNSIGNED_}INT, FLOAT_32_UNSIGNED_INT_24_8_REV, UNSIGNED_{BYTE, SHORT, INT}_* values from [Table 8.2] src: NONE, {FRONT, BACK}_{LEFT, RIGHT}, FRONT, BACK, LEFT, RIGHT, FRONT_AND_BACK, COLOR_ATTACHMENTi (i = [0, MAX_COLOR_ATTACHMENTS - 1 ])
target, attachment: see InvalidateSubFramebuffer {COLOR, DEPTH, STENCIL}_COMPONENTS, {COLOR, DEPTH, STENCIL}_RENDERABLE, FRAMEBUFFER_RENDERABLE{_LAYERED}, READ_PIXELS{_FORMAT, _TYPE}, FILTER, {GET_}TEXTURE_IMAGE_{FORMAT, TYPE}, {AUTO_GENERATE, GENERATE_}MIPMAP, COLOR_ENCODING, TEXTURE_SHADOW, SRGB_{READ, WRITE, DECODE}, TESS_{CONTROL, EVALUATION}_TEXTURE, {GEOMETRY, FRAGMENT}_TEXTURE, {COMPUTE, VERTEX}_TEXTURE, CLEAR_BUFFER, TEXTURE_GATHER{_SHADOW}, IMAGE_TEXEL_SIZE, SHADER_IMAGE_{LOAD, STORE, ATOMIC}, {IMAGE, VIEW}_COMPATIBILITY_CLASS, IMAGE_PIXEL_{FORMAT, TYPE}, IMAGE_FORMAT_COMPATIBILITY_TYPE, SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST, SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE, SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST, SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE, TEXTURE_{COMPRESSED, VIEW}, TEXTURE_COMPRESSED_BLOCK_{WIDTH, HEIGHT}, TEXTURE_COMPRESSED_BLOCK_SIZE
Copying Pixels [18.3] void BlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, bitfield mask, enum filter);
mask: Bitwise OR of {COLOR, DEPTH, STENCIL}_BUFFER_BIT filter: LINEAR, NEAREST
A complete list of symbolic constants for states is shown in the tables in [6.2].
void GetBooleanv(enum pname, boolean *data); void GetIntegerv(enum pname, int *data); void GetInteger64v(enum pname, int64 *data); void GetFloatv(enum pname, float *data); void GetDoublev(enum pname, double *data); void GetDoublei_v(enum target, uint index, double *data); void GetBooleani_v(enum target, uint index, boolean *data); void GetIntegeri_v(enum target, uint index, int *data); void GetFloati_v(enum target, uint index, float *data); void GetInteger64i_v(enum target, uint index, int64 *data); boolean IsEnabled(enum cap); boolean IsEnabledi(enum target, uint index);
ubyte *GetStringi(enum name, uint index); void GetPointerv(enum pname, void **params);
void CopyImageSubData(uint srcName, enum srcTarget, int srcLevel, int srcX, int srcY, int srcZ, uint dstName, enum dstTarget, int dstLevel, int dstX, int dstY, int dstZ, sizei srcWidth, sizei srcHeight, sizei srcDepth);
srcTarget, dstTarget: see target for BindTexture in section [8.1] on this card, plus GL_RENDERTARGET
void GetInternalformati64v(enum target, enum internalformat, enum pname, sizei bufSize, int64 *params);
target: TEXTURE_{1D,2D,3D}, TEXTURE_{1D,2D,CUBE_MAP}_ARRAY, TEXTURE_2D_MULTISAMPLE{_ARRAY}, TEXTURE_{BUFFER, RECTANGLE}, RENDERBUFFER pname: NUM_SAMPLE_COUNTS, SAMPLES, INTERNALFORMAT_{SUPPORTED, PREFERRED}, INTERNALFORMAT_{RED, GREEN, BLUE}_SIZE, INTERNALFORMAT_{DEPTH, STENCIL}_SIZE, void GetInternalformativ(enum target, INTERNALFORMAT_{ALPHA, SHARED}_SIZE, enum internalformat, enum pname, INTERNALFORMAT_{RED, GREEN}_TYPE, sizei bufSize, int *params); INTERNALFORMAT_{BLUE, ALPHA}_TYPE, internalformat: any valid internalformat INTERNALFORMAT_{DEPTH, STENCIL}_TYPE, target: see GetInternalformati64v, plus MAX_{WIDTH, HEIGHT, DEPTH, LAYERS}, TEXTURE_ CUBE_MAP MAX_COMBINED_DIMENSIONS, FRAMEBUFFER_BLEND, pname:see GetInternalformati64v, plus (more parameters ) INTERNALFORMAT_ALPHA_TYPE source: DEBUG_SOURCE_x where x may be API, SHADER_COMPILER, WINDOW_SYSTEM, THIRD_PARTY, APPLICATION, OTHER type: DEBUG_TYPE_x where x may be ERROR, MARKER, OTHER, DEPRECATED_BEHAVIOR, UNDEFINED_BEHAVIOR, PERFORMANCE, PORTABILITY, {PUSH, POP}_GROUP severity: DEBUG_SEVERITY_{HIGH, MEDIUM}, DEBUG_SEVERITY_{LOW, NOTIFICATION}
Compute Shaders [19] void DispatchCompute( uint num_group_x, uint num_groups_y, uint num_groups_z);
void DispatchComputeIndirect(intptr indirect);
Hints [21.5]
void Hint(enum target, enum hint);
target: FRAGMENT_SHADER_DERIVATIVE_HINT, TEXTURE_COMPRESSION_HINT, {LINE, POLYGON}_SMOOTH_HINT hint: FASTEST, NICEST, DONT_CARE
Debug Output [20] Enable/Disable(DEBUG_OUTPUT); void ObjectPtrLabel(void* ptr, sizei length, const char *label); void GetObjectPtrLabel(void* ptr, sizei bufSize, sizei *length, char *label);
Debug Message Callback [20.2]
void DebugMessageCallback( DEBUGPROC callback, void *userParam); DEBUGPROC callback function type: void callback(enum source, enum type, uint id, enum severity, sizei length, const char *message, void *userParam);
(parameters )
void PushDebugGroup(enum source, uint id, sizei length, const char *message); void PopDebugGroup(void);
void DebugMessageControl(enum source, enum type, enum severity, sizei count, const uint *ids, boolean enabled);
void ObjectLabel(enum identifier, uint name, sizei length, const char *label);
identifier: BUFFER, FRAMEBUFFER, RENDERBUFFER, PROGRAM_PIPELINE, PROGRAM, QUERY, SAMPLER, SHADER, TEXTURE, TRANSFORM_FEEDBACK, VERTEX_ARRAY
uint GetDebugMessageLog(uint count, sizei logSize, enum *sources, enum *types, enum *ids, enum *severities, sizei *lengths, char *messageLog); void GetObjectLabel(enum identifier, uint name, sizei bufSize, sizei *length, char *label);
www.opengl.org/registry
Page 6
The OpenGL Shading Language is used to create shaders for each of the programmable processors contained in the OpenGL processing pipeline. The OpenGL Shading Language is actually several closely related languages. Currently, these processors are the vertex, tessellation control, tessellation evaluation, geometry, fragment, and compute shaders. [n.n.n] and [Table n.n] refer to sections and tables in the OpenGL Shading Language 4.30 specification at www.opengl.org/registry
The following operators are numbered in order of precedence. Relational and equality operators evaluate to Boolean. Also see lessThan(), equal(), etc.
1.
Preprocessor [3.3]
Predefined Macros
#elif #ifdef #line #if #ifndef #endif #else #undef #pragma
__LINE__ __FILE__ __VERSION__ GL_core_profile GL_es_profile GL_compatibility_profile
Decimal integer constants. __FILE__ says which source string is being processed. Decimal integer, e.g.: 430 Defined as 1 1 if the implementation supports the es profile Defined as 1 if the implementation supports the compatibility profile.
Preprocessor Operators
#version 430 #version 430 profile
Required when using version 4.30. profile is core, compatibility, or es. behavior: require, enable, warn, #extension extension_name : behavior disable extension_name: extension #extension all : behavior supported by compiler, or all
11. 12. 13. 14. 15. | && ^^ ||
3. 4. 5. 6. 7. 8. 9. 10.
() [] () . ++ --
parenthetical grouping array subscript function call, constructor, structure field, selector, swizzle postfix increment and decrement
2.
prefix increment and decrement unary */% multiplicative +additive << >> bit-wise shift < > <= >= relational == != equality & bit-wise and
^
++ -+-~!
bit-wise exclusive or
bit-wise inclusive or logical and logical exclusive or logical inclusive or selects an entire operand.
Transparent Types
void bool int, uint float double vec2, vec3, vec4 dvec2, dvec3, dvec4 bvec2, bvec3, bvec4 ivec2, ivec3, ivec4 uvec2, uvec3, uvec4 mat2, mat3, mat4 mat2x2, mat2x3, mat2x4 mat3x2, mat3x3, mat3x4 mat4x2, mat4x3, mat4x4 dmat2, dmat3, dmat4 dmat2x2, dmat2x3, dmat2x4 dmat3x2, dmat3x3, dmat3x4 dmat4x2, dmat4x3, dmat4x4 no function return value Boolean signed/unsigned integers single-precision floating-point scalar double-precision floating scalar floating point vector double precision floating-point vectors Boolean vectors signed and unsigned integer vectors 2x2, 3x3, 4x4 float matrix 2-column float matrix of 2, 3, or 4 rows 3-column float matrix of 2, 3, or 4 rows 4-column float matrix of 2, 3, or 4 rows 2x2, 3x3, 4x4 double-precision float matrix 2-col. double-precision float matrix of 2, 3, 4 rows 3-col. double-precision float matrix of 2, 3, 4 rows 4-column double-precision float matrix of 2, 3, 4 rows
Types [4.1]
1D, 2D, or 3D texture cube mapped texture rectangular texture 1D or 2D array texture buffer texture 2D multi-sample texture 2D multi-sample array texture cube map array texture
int. 2D rectangular image integer 1D, 2D array texture integer 1D, 2D array image integer buffer texture integer buffer image int. 2D multi-sample texture int. 2D multi-sample image int. 2D multi-sample array tex. int. 2D multi-sample array image int. cube map array texture int. cube map array image uint atomic counter uint 1D, 2D, or 3D texture uint 1D, 2D, or 3D image uint cube mapped texture uint cube mapped image uint rectangular texture uint rectangular image 1D or 2D array texture 1D or 2D array image uint buffer texture uint buffer image uint 2D multi-sample texture uint 2D multi-sample image uint 2D multi-sample array tex. Continue
Implicit Conversions
int int, uint int, uint, float ivec2 ivec3 ivec4 ivec2 ivec3 ivec4 uvec2 uvec3 uvec4 ivec2 ivec3 ivec4 -> -> -> -> -> -> -> -> -> -> -> -> -> -> ->
1D or 2D depth texture with comparison rectangular tex. / compare 1D or 2D array depth texture with comparison cube map depth texture with comparison samplerCubeArrayShadow cube map array depth texture with comparison
uint float double uvec2 uvec3 uvec4 vec2 vec3 vec4 vec2 vec3 vec4 dvec2 dvec3 dvec4
uvec2 uvec3 uvec4 vec2 vec3 vec4 mat2 mat3 mat4 mat2x3 mat2x4 mat3x2 mat3x4 mat4x2 mat4x3
-> -> -> -> -> -> -> -> -> -> -> -> -> -> ->
dvec2 dvec3 dvec4 dvec2 dvec3 dvec4 dmat2 dmat3 dmat4 dmat2x3 dmat2x4 dmat3x2 dmat3x4 dmat4x2 dmat4x4
integer 1D, 2D, or 3D texture integer 1D, 2D, or 3D image integer cube mapped texture integer cube mapped image int. 2D rectangular texture Continue
// Structures, blocks, and structure members // can be arrays. Arrays of arrays supported.
in/out/uniform block-name {
// optional variable declaration // interface matching by block name // optional instance name, optionally an array
Qualifiers
Declarations may have one storage qualifier. (default) local read/write memory, or input parameter read-only variable linkage into shader from previous stage linkage out of a shader to next stage linkage between a shader, OpenGL, and the application accessible by shaders and OpenGL API compute shader only, shared among work items in a local work group
Interface Blocks [4.3.9] Input, output, uniform, and buffer variable declarations can be grouped. For example: uniform Transform { mat4 ModelViewMatrix; // allowed restatement qualifier uniform mat3 NormalMatrix; };
Geometry Shader points, lines, {lines,triangles}_adjacency, triangles, invocations = integer-constant Fragment Shader For redeclaring built-in variable gl_FragCoord: origin_upper_left, pixel_center_integer For in only (not with variable declarations): early_fragment_tests Compute Shader local_size_x = integer-constant, local_size_y = integer-constant, local_size_z = integer-constant
Output Layout Qualifiers [4.4.2] For all shader stages: location = integer-constant, index = integer-constant
Auxiliary Storage Qualifiers Use to qualify some input and output variables: centroid sampler patch centroid-based interpolation per-sample interpolation per-tessellation-patch attributes
Input Layout Qualifiers [4.4.1] For all shader stages: location = integer-constant
Tessellation Evaluation triangles, quads, equal_spacing, isolines, fractional_{even,odd}_spacing, cw, ccw, point_mode
Tessellation Control vertices = integer-constant Geometry Shader points, line_strip, triangle_strip, max_vertices = integer-constant, stream = integer-constant
www.opengl.org/registry
Page 7
Vector & Matrix [5.4.2]
These are for vertex, tessellation, geometry, and fragment languages. #pragma STDGL force all output variables invariant(all) to be invariant
Inputs
Outputs Inputs
Outputs
Inputs
in int gl_PatchVerticesIn; in int gl_PrimitiveID; in int gl_InvocationID; out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_out[]; Outputs
Inputs
Outputs
Inputs
Inputs
Outputs
For tessellation control shaders: invariant gl_Position; qualify a previously binding = integer-constant, declared variable rgba{32,16}f, rg{32,16}f, r{32,16}f, invariant centroid out qualify as part of a rgba{16,8}, r11f_g11f_b10f, rgb10_a2{ui}, vec3 Color; variable declaration rg{16,8}, r{16,8}, rgba{32,16,8}i, rg{32,16,8} i,r{32,16,8}i, rgba{32,16,8}ui, rg{32,16,8}ui, Precise Qualifier [4.9] r{32,16,8}ui, rgba{16,8}_snorm, Ensures that operations are executed in stated rg{16,8}_snorm, r{16,8}_snorm order with operator consistency. For example, a fused multiply-add cannot be used in the Interpolation Qualifiers [4.5] following; it requires two identical multiplies, Qualify outputs from vertex shader and inputs followed by an add. to fragment shader. precise out vec4 Position = a * b + c * d; smooth perspective correct interpolation Memory Qualifiers [4.10] flat no interpolation Variables qualified as image can have one or noperspective linear interpolation more memory qualifiers.
.length() for matrices returns number of columns .length() for vectors returns number of components mat2(vec2, vec2); // 1 col./arg. mat2x3(vec2, float, vec2, float); // col. 2 dmat2(dvec2, dvec2); // 1 col./arg. dmat3(dvec3, dvec3, dvec3); // 1 col./arg.
Select structure fields or length() method of an array using the period (.) operator. Other operators:
== != equality
=
[]
assignment
indexing (arrays only)
coherent
Input values copied in at function call time, output values copied out at function return. (default) same as in for function parameters passed into function for function parameters that cannot be written to for function parameters passed back out of function, but not initialized when passed in for function parameters passed both into and out of a function
reads and writes are coherent with other shader invocations volatile underlying values may be changed by other sources restrict wont be accessed by other code readonly read only writeonly write only
Array elements are accessed using the array Examples of access components of a matrix with subscript operator ( [ ] ), e.g.: array subscripting syntax: diffuseColor += lightIntensity[3]*NdotL; mat4 m; // m is a matrix
m[1] = vec4(2.0); // sets 2nd col. to all 2.0 m[0][0] = 1.0; // sets upper left element to 1.0 m[2][3] = 2.0; // sets 4th element of 3rd col. to 2.0
Precision qualifiers have no effect on precision; they aid code portability with OpenGL ES: highp, mediump, lowp
When multiple qualifiers are present in a declaration they may appear in any order, but must all appear before the type. The layout qualifier is the only qualifier that can appear more than once. Further, a declaration can have at most one storage qualifier, at most one auxiliary storage qualifier, and at most one interpolation qualifier. Multiple memory qualifiers can be used. Any violation of these rules will cause a compiletime error.
Subroutines [6.1.2]
Subroutine type variables are assigned to functions through the UniformSubroutinesuiv command in the OpenGL API. Declare types with the subroutine keyword:
subroutine returnType subroutineTypeName(type0 arg0, type1 arg1, ..., typen argn);
Declare subroutine type variables with a specific subroutine type in a subroutine uniform variable declaration:
subroutine uniform subroutineTypeName subroutineVarName;
Associate functions with subroutine types of matching declarations by defining the functions with the subroutine keyword and a list of subroutine types the function matches:
subroutine(subroutineTypeName0, ..., subroutineTypeNameN) returnType functionName(type0 arg0, type1 arg1, ..., typen argn){ ... } // function body
Selection
call by value-return for (;;) { break, continue } while ( ) { break, continue } do { break, continue } while ( ); if ( ) { } if ( ) { } else { } switch ( ) { case integer: break; default: } void main() break, continue, return (There is no goto) return in main() discard // Fragment shader only
Shaders communicate with fixed-function OpenGL pipeline stages and other shader executables through built-in variables.
Geometry Language
in gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_in[]; in int gl_PrimitiveIDIn; in int gl_InvocationID; out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; }; out int gl_PrimitiveID; out int gl_Layer; out int gl_ViewportIndex;
Vertex Language
in int in int
gl_VertexID; gl_InstanceID;
out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; }; in gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_in[gl_MaxPatchVertices];
Fragment Language
in in in in in in in in in in vec4 bool float vec2 int int vec2 int int int gl_FragCoord; gl_FrontFacing; gl_ClipDistance[]; gl_PointCoord; gl_PrimitiveID; gl_SampleID; gl_SamplePosition; gl_SampleMask[]; gl_Layer; gl_ViewportIndex;
Compute Language
in int gl_PatchVerticesIn; in int gl_PrimitiveID; in vec3 gl_TessCoord; patch in float gl_TessLevelOuter[4]; patch in float gl_TessLevelInner[2]; out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[];
};
The following are provided to all shaders. The actual values are implementation-dependent, but must be at least the value shown. const ivec3 gl_MaxComputeWorkGroupCount[] = {65535, 65535, 65535} ; const ivec3 gl_MaxComputeLocalWorkSize[] = {1024, 1024, 64}; const int gl_MaxComputeUniformComponents = 1024; const int gl_MaxComputeTextureImageUnits = 16; const int gl_MaxComputeImageUniforms = 8; const int gl_MaxComputeAtomicCounters = 8; const int gl_MaxComputeAtomicCounterBuffers = 1; const int gl_MaxVertexAttribs = 16; const int gl_MaxVertexUniformComponents = 1024; const int gl_MaxVaryingComponents= 60; const int gl_MaxVertexOutputComponents = 64; const int gl_MaxGeometryInputComponents = 64; const int gl_MaxGeometryOutputComponents = 128; const int gl_MaxFragmentInputComponents = 128; const int gl_MaxVertexTextureImageUnits = 16; const int gl_MaxCombinedTextureImageUnits = 80; const int gl_MaxTextureImageUnits = 16; const int gl_MaxImageUnits = 8; const int gl_ MaxCombinedImageUnitsAndFragmentOutputs = 8; const int gl_MaxImageSamples = 0; const int gl_MaxVertexImageUniforms= 0; const int gl_MaxTessControlImageUniforms = 0; const int gl_MaxTessEvaluationImageUniforms = 0; const int gl_MaxGeometryImageUniforms = 0; const int gl_MaxFragmentImageUniforms = 8; const int gl_MaxCombinedImageUniforms = 8; const int gl_MaxFragmentUniformComponents = 1024; const int gl_MaxDrawBuffers = 8; const int gl_MaxClipDistances = 8; const int gl_MaxGeometryTextureImageUnits = 16;
const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const
int gl_MaxGeometryOutputVertices = 256; int gl_MaxGeometryTotalOutputComponents = 1024; int gl_MaxGeometryUniformComponents = 1024; int gl_MaxGeometryVaryingComponents = 64; int gl_MaxTessControlInputComponents = 128; int gl_MaxTessControlOutputComponents = 128; int gl_MaxTessControlTextureImageUnits = 16; int gl_MaxTessControlUniformComponents = 1024; int gl_MaxTessControlTotalOutputComponents = 4096; int gl_MaxTessEvaluationInputComponents = 128; int gl_MaxTessEvaluationOutputComponents = 128; int gl_MaxTessEvaluationTextureImageUnits = 16; int gl_MaxTessEvaluationUniformComponents = 1024; int gl_MaxTessPatchComponents = 120; int gl_MaxPatchVertices = 32; int gl_MaxTessGenLevel = 64; int gl_MaxViewports = 16; int gl_MaxVertexUniformVectors = 256; int gl_MaxFragmentUniformVectors = 256; int gl_MaxVaryingVectors = 15; int gl_MaxVertexAtomicCounters = 0; int gl_MaxTessControlAtomicCounters = 0; int gl_MaxTessEvaluationAtomicCounters = 0; int gl_MaxGeometryAtomicCounters = 0; int gl_MaxFragmentAtomicCounters = 8; int gl_MaxCombinedAtomicCounters = 8; int gl_MaxAtomicCounterBindings = 1; int gl_MaxVertexAtomicCounterBuffers = 0; int gl_MaxTessControlAtomicCounterBuffers = 0; int gl_MaxTessEvaluationAtomicCounterBuffers = 0; int gl_MaxGeometryAtomicCounterBuffers = 0; int gl_MaxFragmentAtomicCounterBuffers = 1; int gl_MaxCombinedAtomicCounterBuffers = 1; int gl_MaxAtomicCounterBufferSize = 16384; int gl_MinProgramTexelOffset = -8; int gl_MaxProgramTexelOffset = 7;
www.opengl.org/registry
Page 8
Functions will not result in a divide-by-zero error. If the divisor of a ratio is 0, then results will be undefined. Component-wise operation. Parameters specified as angle are in units of radians. Tf=float, vecn.
Tf radians(Tf degrees) Tf degrees(Tf radians) Tf sin(Tf angle) Tf cos(Tf angle) Tf tan(Tf angle) Tf asin(Tf x) Tf acos(Tf x) Tf atan(Tf y, Tf x) Tf atan(Tf y_over_x) Tf sinh(Tf x) Tf cosh(Tf x) Tf tanh(Tf x) Tf asinh(Tf x) Tf acosh(Tf x) Tf atanh(Tf x) degrees to radians radians to degrees sine cosine tangent arc sine arc cosine arc tangent hyperbolic sine hyperbolic cosine hyperbolic tangent hyperbolic sine hyperbolic cosine hyperbolic tangent
Built-In Functions
Type Abbreviations for Built-in Functions: In vector types, n is 2, 3, or 4. Tf=float, vecn. Td =double, dvecn. Tfd= float, vecn, double, dvecn. Tb= bool, bvecn. Tu=uint, uvecn. Ti=int, ivecn. Tiu=int, ivecn, uint, uvecn. Tvec=vecn, uvecn, ivecn. Within any one function, type sizes and dimensionality must correspond after implicit type conversions. For example, float round(float) is supported, but float round(vec4) is not.
Returns min(max(x, minVal), maxVal): Tfd clamp(Tfd x, Tfd minVal, Tfd maxVal) Tf clamp(Tf x, float minVal, float maxVal) Td clamp(Td x, double minVal, double maxVal) Tiu clamp(Tiu x, Tiu minVal, Tiu maxVal) Ti clamp(Ti x, int minVal, int maxVal) Tu clamp(Tu x, uint minVal, uint maxVal)
Returns linear blend of x and y: Tfd mix(Tfd x, Tfd y, Tfd a) Tf mix(Tf x, Tf y, float a) Td mix(Td x, Td y, double a) Returns true if components in a select components from y, else from x: Tfd mix(Tfd x, Tfd y, Tb a) Returns 0.0 if x < edge, else 1.0: Tfd step(Tfd edge, Tfd x) Td step(double edge, Td x) Tf step(float edge, Tf x) Clamps and smoothes: Tfd smoothstep(Tfd edge0, Tfd edge1, Tfd x) Tf smoothstep(float edge0, float edge1, Tf x) Td smoothstep(double edge0, double edge1, Td x) Returns true if x is NaN: Tb isnan(Tfd x) Returns true if x is positive or negative infinity: Tb isinf(Tfd x) Returns signed int or uint value of the encoding of a float: Ti floatBitsToInt(Tf value) Tu floatBitsToUint(Tf value) Returns float value of a signed int or uint encoding of a float: Tf intBitsToFloat(Ti value) Tf uintBitsToFloat(Tu value) Computes and returns a*b + c. Treated as a single operation when using precise: Tfd fma(Tfd a, Tfd b, Tfd c)
These functions operate on vectors as vectors, not component-wise. Tf=float, vecn. Td =double, dvecn. Tfd= float, vecn, double, dvecn.
float length(Tf x) double length(Td x) length of vector
float distance(Tf p0, Tf p1) distance between points double distance(Td p0, Td p1) float dot(Tf x, Tf y) double dot(Td x, Td y) dot product
vec3 cross(vec3 x, vec3 y) cross product dvec3 cross(dvec3 x, dvec3 y) Tfd normalize(Tfd x) Tfd faceforward(Tfd N, Tfd I, Tfd Nref) Tfd reflect(Tfd I, Tfd N) Tfd refract(Tfd I, Tfd N, float eta) normalize vector to length 1 returns N if dot(Nref, I) < 0, else -N reflection direction I - 2 * dot(N,I) * N refraction vector
Component-wise operation. Tf=float, vecn. Td= double, dvecn. Tfd= Tf, Td Tf pow(Tf x, Tf y) Tf exp(Tf x) Tf log(Tf x) Tf exp2(Tf x) Tf log2(Tf x) Tfd sqrt(Tfd x) Tfd inversesqrt(Tfd x) xy ex ln 2x log2 square root inverse square root
Available to vertex, geometry, and fragment shaders. See tables on next page.
Component-wise operation. Tf=float, vecn. Tb=bool, bvecn. Ti=int, ivecn. Tu=uint, uvecn. Splits x into a floating-point significand in the range [0.5, 1.0) Td= double, dvecn. Tfd= Tf, Td. Tiu= Ti, Tu. and an integer exponent of 2: Tfd frexp(Tfd x, out Ti exp) Returns absolute value: Ti abs(Ti x) Tfd abs(Tfd x) Builds a floating-point number from x and the corresponding Returns -1.0, 0.0, or 1.0: integral exponent of 2 in exp: Ti sign(Ti x) Tfd sign(Tfd x) Tfd ldexp(Tfd x, in Ti exp)
Returns nearest integer <= x: Tfd floor(Tfd x) Returns nearest integer with absolute value <= absolute value of x: Tfd trunc(Tfd x) Returns nearest integer, implementation-dependent rounding mode: Tfd round(Tfd x) Returns nearest integer, 0.5 rounds to nearest even integer: Tfd roundEven(Tfd x) Returns nearest integer >= x: Tfd ceil(Tfd x) Returns x - floor(x): Tfd fract(Tfd x) Returns modulus: Tfd mod(Tfd x, Tfd y) Tf mod(Tf x, float y) Td mod(Td x, double y)
Operates on individual integers in buffer-object or shared-variable storage. OP is Add, Min, Max, And, Or, Xor, Exchange, or CompSwap.
uint atomicOP(inout uint mem, uint data)
Compare x and y component-wise. Sizes of the input and return vectors for any particular call must match. Tvec=vecn, uvecn, ivecn. bvecn lessThan(Tvec x, Tvec y) < <= > >= == !=
bvecn lessThanEqual(Tvec x, Tvec y) bvecn greaterThan(Tvec x, Tvec y) bvecn greaterThanEqual(Tvec x, Tvec y) bvecn equal(Tvec x, Tvec y) bvecn equal(bvecn x, bvecn y) bvecn notEqual(Tvec x, Tvec y) bvecn notEqual(bvecn x, bvecn y) bool any(bvecn x) bool all(bvecn x) bvecn not(bvecn x)
true if any component of x is true true if all comps. of x are true logical complement of x
Packs components of v into a 64-bit value and returns a double-precision value: double packDouble2x32(uvec2 v) Returns a 2-component vector representation of v: uvec2 unpackDouble2x32(double v) Returns a uint by converting the components of a twocomponent floating-point vector: uint packHalf2x16(vec2 v) Returns a two-component floating-point vector: vec2 unpackHalf2x16(uint v)
Returns the dimensions of the images or images: int imageSize(gimage{1D,Buffer} image) ivec2 imageSize(gimage{2D,Cube,Rect,1DArray, 2DMS} image) ivec3 imageSize(gimage{Cube,2D,2DMS}Array image) vec3 imageSize(gimage3D image)
Loads texel at the coordinate P from the image unit image: gvec4 imageLoad(readonly IMAGE_PARAMS)
Returns separate integer and fractional parts: Tfd modf(Tfd x, out Tfd i)
Component-wise operation. Tu=uint, uvecn. Ti=int, ivecn. Tiu=int, ivecn, uint, uvecn.
Adds 32-bit uint x and y, returning the sum modulo 232: Tu uaddCarry(Tu x, Tu y, out Tu carry) Subtracts y from x, returning the difference if non-negative, otherwise 232 plus the difference: Tu usubBorrow(Tu x, Tu y, out Tu borrow)
(Continue )
Returns minimum value: Tfd min(Tfd x, Tfd y) Tf min(Tf x, float y) Td min(Td x, double y) Tiu min(Tiu x, Tiu y) Ti min(Ti x, int y) Tu min(Tu x, uint y)
(Continue )
Stores data into the texel at the coordinate P from the image specified by image: void imageStore(writeonly IMAGE_PARAMS, gvec4 data)
(Continued on next page >)
www.opengl.org/registry
Page 9
Interpolation fragment-processing functions
Return value of interpolant sampled inside pixel and the primitive: Tf interpolateAtCentroid(Tf interpolant) Return value of interpolant at location of sample # sample: Tf interpolateAtSample(Tf interpolant, int sample) Return value of interpolant sampled at fixed offset offset from pixel center: Tf interpolateAtOffset(Tf interpolant, vec2 offset)
Takes the minimum of the value of data and the contents of the selected texel: uint imageAtomicMin(IMAGE_PARAMS, uint data) int imageAtomicMin(IMAGE_PARAMS, int data) Takes the maximum of the value data and the contents of the selected texel: uint imageAtomicMax(IMAGE_PARAMS, uint data) int imageAtomicMax(IMAGE_PARAMS, int data) Performs a bit-wise AND of the value of data and the contents of the selected texel: uint imageAtomicAnd(IMAGE_PARAMS, uint data) int imageAtomicAnd(IMAGE_PARAMS, int data) Performs a bit-wise OR of the value of data and the contents of the selected texel: uint imageAtomicOr(IMAGE_PARAMS, uint data) int imageAtomicOr(IMAGE_PARAMS, int data)
(Continue )
void memoryBarrier()
Controls ordering of memory transactions as viewed by other invocations in a compute work group:
void groupMemoryBarrier()
Order reads and writes accessible to other invocations:
Available to vertex, geometry, and fragment shaders. gvec4=vec4, ivec4, uvec4. gsampler* =sampler*, isampler*, usampler*. The P argument needs to have enough components to specify each dimension, array layer, or comparison for the selected sampler. The dPdx and dPdy arguments need enough components to specify the derivative for each dimension of the sampler.
Projective texture lookup with offset added before Use texture coordinate P to do a lookup in the texture texture lookup. bound to sampler. For shadow forms, compare is gvec4 textureProjOffset(gsampler{1D,2D[Rect],3D} sampler, used as Dref and the array layer comes from P.w. vec{2,3,4} P, {int,ivec2,ivec3} offset [, float bias]) For non-shadow forms, the array layer comes from the last component of P. float textureProjOffset(
Texture lookup both projectively as in textureProj, and with explicit gradient as in textureGrad.
gvec4 textureProjGrad(gsampler{1D,2D[Rect],3D} sampler, {vec2,vec3,vec4} P, {float,vec2,vec3} dPdx, {float,vec2,vec3} dPdy) float textureProjGrad(sampler{1D,2D[Rect]}Shadow sampler, vec4 P, {float,vec2} dPdx, {float,vec2} dPdy)
gvec4 texture( gsampler{1D[Array],2D[Array,Rect],3D,Cube[Array]} sampler, {float,vec2,vec3,vec4} P [, float bias]) float texture( sampler{1D[Array],2D[Array,Rect],Cube}Shadow sampler, {vec3,vec4} P [, float bias]) float texture(gsamplerCubeArrayShadow sampler, vec4 P, float compare)
Texture lookup projectively and with explicit gradient as in textureProjGrad, as well as with offset as in textureOffset.
gvec4 textureProjGradOffset( gsampler{1D,2D[Rect],3D} sampler, vec{2,3,4} P, {float,vec2,vec3} dPdx, {float,vec2,vec3} dPdy, {int,ivec2,ivec3} offset) float textureProjGradOffset( sampler{1D,2D[Rect]Shadow sampler, vec4 P, {float,vec2} dPdx, {float,vec2} dPdy, {ivec2,int,vec2} offset)
textureSize functions return dimensions of lod (if present) for the texture bound to sampler. Components in return value are filled in with the Texture lookup with projection. width, height, depth of the texture. For array forms, the last component of the return value is gvec4 textureProj(gsampler{1D,2D[Rect],3D} sampler, the number of layers in the texture array. vec{2,3,4} P [, float bias]) float textureProj(sampler{1D,2D[Rect]}Shadow sampler, {int,ivec2,ivec3} textureSize( vec4 P [, float bias]) gsampler{1D[Array],2D[Rect,Array],Cube} sampler[, int lod]) Texture lookup as in texture but with explicit LOD. {int,ivec2,ivec3} textureSize( gsampler{Buffer,2DMS[Array]}sampler) gvec4 textureLod( {int,ivec2,ivec3} textureSize( gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler, sampler{1D, 2D, 2DRect,Cube[Array]}Shadow sampler[, {float,vec2,vec3} P, float lod) int lod]) float textureLod(sampler{1D[Array],2D}Shadow sampler, ivec3 textureSize(samplerCubeArray sampler, int lod) vec3 P, float lod) Offset added before texture lookup. textureQueryLod functions return the mipmap array(s) that would be accessed in the x gvec4 textureOffset( component of the return value. Returns the gsampler{1D[Array],2D[Array,Rect],3D} sampler, computed level of detail relative to the base level {float,vec2,vec3} P, {int,ivec2,ivec3} offset [, float bias]) in the y component of the return value. float textureOffset( vec2 textureQueryLod( sampler{1D[Array],2D[Rect,Array]}Shadow sampler, gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler, {vec3, vec4} P, {int,ivec2} offset [, float bias]) {float,vec2,vec3} P) vec2 textureQueryLod( sampler{1D[Array],2D[Array],Cube[Array]}Shadow sampler, Use integer texture coordinate P to lookup a single texel from sampler. {float,vec2,vec3} P)
These functions take components of a floating-point vector operand as a texture coordinate, determine a set of four texels to sample from the base level of detail of the specified texture image, and return one component from each texel in a four-component result vector.
gvec4 textureGather( gsampler{2D[Array,Rect],Cube[Array]} sampler, {vec2,vec3,vec4} P [, int comp]) vec4 textureGather( sampler{2D[Array,Rect],Cube[Array]}Shadow sampler, {vec2,vec3,vec4} P, float refZ)
Texture gather as in textureGather by offset as described in textureOffset except minimum and maximum offset values are given by {MIN, MAX}_PROGRAM_TEXTURE_GATHER_OFFSET.
gvec4 textureGatherOffset(gsampler2D[Array,Rect] sampler, {vec2,vec3} P, ivec2 offset [, int comp]) vec4 textureGatherOffset( sampler2D[Array,Rect]Shadow sampler, {vec2,vec3} P, float refZ, ivec2 offset)
float textureGrad( sampler{1D[Array],2D[Rect,Array], Cube}Shadow sampler, gvec4 texelFetch( {vec3,vec4} P, {float,vec2} dPdx, {float,vec2, vec3} dPdy) textureQueryLevels functions return the number gsampler{1D[Array],2D[Array,Rect],3D} sampler, of mipmap levels accessible in the texture {int,ivec2,ivec3} P[, {int,ivec2} lod]) associated with sampler. Texture lookup with both explicit gradient and offset. gvec4 texelFetch(gsampler{Buffer, 2DMS[Array]} sampler, {int,ivec2,ivec3} P[, int sample]) int textureQueryLevels( gvec4 textureGradOffset( gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler) gsampler{1D[Array],2D[Rect,Array],3D} sampler, Fetch single texel with offset added before texture lookup. int textureQueryLevels( {float,vec2,vec3} P, {float,vec2,vec3} dPdx, sampler{1D[Array],2D[Array],Cube[Array]}Shadow sampler) {float,vec2,vec3} dPdy, {int,ivec2,ivec3} offset) gvec4 texelFetchOffset( gsampler{1D[Array],2D[Array],3D} sampler, float textureGradOffset( {int,ivec2,ivec3} P, int lod, {int,ivec2,ivec3} offset) sampler{1D[Array],2D[Rect,Array]}Shadow sampler, {vec3,vec4} P, {float,vec2} dPdx, {float,vec2}dPdy, gvec4 texelFetchOffset( {int,ivec2} offset) gsampler2DRect sampler, ivec2 P, ivec2 offset)
Texture gather as in textureGatherOffset except offsets determines location of the four texels to sample.
gvec4 textureGatherOffsets(gsampler2D[Array,Rect] sampler, {vec2,vec3} P, ivec2 offsets[4] [, int comp]) vec4 textureGatherOffsets( sampler2D[Array,Rect]Shadow sampler, {vec2,vec3} P, float refZ, ivec2 offsets[4])
www.opengl.org/registry
www.opengl.org/registry
Page 11
gl_NumWorkGroups = (4,2,0)
Use the barrier function to synchronize invocations in a work group: void barrier(); Use the memoryBarrier* or groupMemoryBarrier functions to order reads/writes accessible to other invocations: void memoryBarrier(); void memoryBarrierAtomicCounter(); void memoryBarrierBuffer(); void memoryBarrierImage(); void memoryBarrierShared(); // Only for compute shaders void groupMemoryBarrier(); // Only for compute shaders
= = = =
Use the compute shader built-in variables to specifiy work groups and invocations: in vec3 gl_NumWorkGroups; // Number of workgroups dispatched const vec3 gl_WorkGroupSize; // Size of each work group for current shader in vec3 gl_WorkGroupID; // Index of current work group being executed in vec3 gl_LocalInvocationID; // index of current invocation in a work group in vec3 gl_GlobalInvocationID; // Unique ID across all work groups and threads. (gl_GlobalInvocationID = gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID)
Texture state set with TextureView() enum enum uint uint uint uint internalformat target minlevel numlevels minlayer numlayers // // // // // // base internal format texture target first level of mipmap number of mipmap levels first layer of array texture number of layers in array
Sampler Parameters (mutable) TEXTURE_BORDER_COLOR TEXTURE_COMPARE_{FUNC,MODE} TEXTURE_LOD_BIAS TEXTURE_{MAX,MIN}_LOD TEXTURE_{MAG,MIN}_FILTER TEXTURE_SRGB_DECODE TEXTURE_WRAP_{S,T,R}
Texture Parameters (immutable) TEXTURE_WIDTH TEXTURE_HEIGHT TEXTURE_DEPTH TEXTURE_SAMPLES TEXTURE_FIXED_SAMPLE_LOCATIONS TEXTURE_COMPRESSED TEXTURE_COMPRESSED_IMAGE_SIZE TEXTURE_IMMUTABLE_FORMAT
Texture View Parameters (immutable) <target> TEXTURE_INTERNAL_FORMAT TEXTURE_VIEW_{MIN,NUM}_LEVEL TEXTURE_VIEW_{MIN,NUM}_LAYER TEXTURE_IMMUTABLE_LEVELS TEXTURE_SHARED_SIZE TEXTURE_{RED,GREEN,BLUE,ALPHA,DEPTH,STENCIL}_SIZE TEXTURE_{RED,GREEN,BLUE,ALPHA,DEPTH}_TYPE IMAGE_FORMAT_COMPATIBILITY_TYPE
www.opengl.org/registry
Page 12
OpenGL API and OpenGL Shading Language Reference Card Index
A
ActiveShaderProgram ActiveTexture Angle Functions Arrays Atomic Counter Functions Atomic Memory Functions AttachShader 1 2 8 7 8 8 1 4 1 5 4 4 1 3 4 3 1 3 2 2 4 4 5 5 5 5 1 2 1 3 5 5 1 5 5 5 5 1 5 1 8 1 2 2 11 5 7 7 6 1 5 2 2 1 1 3 4 5 1 DeleteFramebuffers DeleteProgram{Pipelines} DeleteQueries DeleteRenderbuffers DeleteSamplers DeleteShader DeleteSync DeleteTextures DeleteTransformFeedbacks DeleteVertexArrays DepthFunc DepthMask DepthRange* Derivative Functions DetachShader DispatchCompute* Dithering DrawArrays* DrawBuffer{s} DrawElements* DrawRangeElements{BaseVertex} DrawTransformFeedback* 3 1 1 3 2 1 1 2 4 4 5 5 4 9 1 5 5 4 5 4 4 4 4 1 1 6 8 1 1 4 1 8 1 1 4,5 9 4 5 2 3 3 3 4 5 GetBoolean* 1 GetBufferParameter* 1 GetBufferPointerv 1 GetBufferSubData 3 GetCompressedTexImage 5 GetDebugMessageLog 5 GetDouble* 1 GetError 5 GetFloat* 4 GetFragData* 3 GetFramebufferAttachment... 3 GetFramebufferParameteriv 5 GetInteger* 1 GetInteger64v 5 GetIntegerv 5 GetInternalFormat* 4 GetMultisamplefv 5 GetObject{Ptr}Label 5 GetPointerv 1 GetProgram* 2 GetProgramiv 1 GetProgramBinary 3 GetProgram{Pipeline}InfoLog 3 GetProgram{Pipeline, Stage}iv 1 GetQuery* 3 GetRenderbufferParameteriv 2 GetSamplerParameter* 2 GetShaderiv 3 GetShaderInfoLog 3 GetShaderPrecisionFormat 3 GetShaderSource 5 GetString* 2 GetSubroutineIndex GetSubroutineUniformLocation 2 1 GetSynciv 3 GetTexImage 3 GetTex{Level}Parameter* GetTransformFeedbackVarying 4 1,2 GetUniform* 3 GetUniform{f d i ui}v 3 GetUniformSubroutineuiv 3 GetVertexAttrib* 1 GL Command Syntax IsTransformFeedback IsVertexArray Iteration and Jumps
The following index shows each item included on this card along with the page on which it is described. The color of the row in the table below is the color of the pane to which you should refer.
L
Layout Qualifiers LineWidth LinkProgram LogicOp
S
SampleCoverage SampleMaski Sampler Queries SamplerParameter* Scissor{Indexed}* ScissorArrayv Shaders and Programs Shader{Binary, Source} ShadersStorageBlockBinding State and State Requests Statements StencilFunc{Separate} StencilMask{Separate} StencilOp{Separate} Structures Subroutine Uniform Variables Subroutines Synchronization 4 4 2 2 4 4 1,2 1 2 5 7 5 5 5 7 2 7 1 11 2 2 3 3 2 3 9 9 3 11 2,3 1 4 4 8 6 6 1,2 2 2 2 2 1 1 4 7 7 8 11 4 3 4 4 4 4 4 1
B
BeginConditionalRender BeginQuery{Indexed} BeginQuery BeginTransformFeedback BindAttribLocation BindBuffer* BindFramebuffer BindFragData* BindImageTexture BindProgramPipeline BindRenderbuffer BindSampler BindTexture BindTransformFeedback BindVertex{Buffer, Array} BlendColor BlendEquation{Separate}* BlendFunc{Separate}* BlitFramebuffer Buffer Objects Buffer Textures Buffer{Sub}Data
M
Macros MapBuffer{Range} Matrices Matrix Examples Matrix Functions MemoryBarrier MemoryBarrier Memory Qualifiers MinSampleShading MultiDraw{Arrays, Elements}* MultiDrawElementsBaseVertex Multisample Fragment Ops Multisample Textures Multisampling
E
EnableVertexAttribArray EndQuery{Indexed} Errors Evaluators Exponential Functions
T
Tessellation Diagram TexBuffer TexImage* TexImage*Multisample TexStorage{1, 2, 3}D TexSubImage* TexParameter* Texture/Texel Functions Texture Queries TextureView Texture View/State Diagram Texturing Timer Queries Transform Feedback TransformFeedbackVaryings Trigonometry Functions Types
N
Noise Functions
O
Object{Ptr}Label Occlusion Queries OpenGL Pipeline Diagram OpenGL Shading Language Operators
F
FenceSync Finish Flatshading Floating-point Numbers Floating-Point Pack/Unpack Func. Flush FlushMappedBufferRange Fragment Operations Fragment Processing Functions Fragment Shaders Framebuffer Framebuffer Objects FramebufferParameteri FramebufferRenderbuffer FramebufferTexture* FrontFace
C
CheckFramebufferStatus ClampColor Clear ClearBuffer{Sub}Data ClearBuffer* ClearColor ClearDepth{f} ClearStencil ClientWaitSync ColorMask{i} Command Letters Common Functions CompileShader CompressedTexImage* CompressedTexSubImage* Compute Programming Diagram Compute Shaders Constants Constructors Conversions CopyBufferSubData CopyImageSubData CopyTexImage* CopyTexSubImage* CreateProgram CreateShader{Programv} Cube Map Texture Select CullFace
P
Pack/Unpack Functions Parameter Qualifiers PatchParameterfv PauseTransformFeedback Pipeline Diagram PixelStore{if} PointParameter* PointSize Polygon{Mode, Offset} Precise & Precision Qualifiers Predefined Macros Preprocessor PrimitiveRestartIndex Program Objects Program Queries ProgramBinary ProgramParameteri ProgramUniform{Matrix}* ProvokingVertex {Push, Pop}Group
U
Uniform Qualifiers Uniform Variables Uniform* UniformBlockBinding UniformMatrix* UniformSubroutinesuiv UnmapBuffer UseProgram{Stages}
H
Hint 5 8,9 8 9 7 1 3 7 1 5 3 1 3 1 3 2 1 1 2
G
GenBuffers 1 GenerateMipmap 3 GenFramebuffers 3 GenProgramPipelines 1 GenQueries 1 GenRenderbuffers 3 GenSamplers 2 GenTextures 2 GenTransformFeedbacks 4 GenVertexArrays 4 Geometric Functions 8 Geometry & Follow-on Diagram 11 GetActiveAtomicCounterBuffer 2 GetActiveAttrib 4 GetActiveSubroutine* 2 GetActiveUniform* 1,2 GetAttachedShaders 3 GetAttribLocation 4
I
Image Functions Integer Functions Interpolation Functions Interpolation Qualifiers InvalidateBuffer* InvalidateTex{Sub}Image Invariant Qualifiers IsBuffer IsEnabled* IsFramebuffer IsProgram IsProgramPipeline IsQuery IsRenderbuffer IsSampler IsShader IsSync IsTexture
V
ValidateProgram{Pipeline} Variables Vector & Matrix Vector Relational Functions Vertex & Tessellation Diagram Vertex Arrays VertexAttrib* VertexAttrib*Format VertexAttrib*Pointer VertexAttrib{Binding, Divisor} VertexBindingDivisor Viewport*
Q
Qualifiers QueryCounter
R
Rasterization ReadBuffer ReadPixels ReleaseShaderCompiler Renderbuffer Object Queries
D
DebugMessage* DeleteBuffers
W
WaitSync
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.
www.opengl.org/registry