[go: up one dir, main page]

0% found this document useful (0 votes)
82 views13 pages

Opengl46 Quick Reference Card

Uploaded by

sinhamonu348
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views13 pages

Opengl46 Quick Reference Card

Uploaded by

sinhamonu348
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

OpenGL 4.

6 API Reference Guide Page 1


OpenGL® is the only cross-platform graphics API that enables
developers to create high-performance, visually-compelling graphics
software applications, in markets such as CAD, content creation,
energy, entertainment, game development, manufacturing, medical,
• See FunctionName refers to functions on this reference card.
and virtual reality.
• [n.n.n] and [Table n.n] refer to sections and tables in the OpenGL 4.6 core specification.
Specifications are available at www.khronos.org/opengl • [n.n.n] refers to sections in the OpenGL Shading Language 4.60.1 specification.

Command Execution [2.3] Floating-Point Numbers [2.3.4] OpenGL Command Syntax [2.2]
16-Bit 1-bit sign, 5-bit exp., 10-bit mant. GL commands are formed from a return type, a name, and optionally up to 4 characters
OpenGL Errors [2.3.1] (or character pairs) from the Command Letters table (to the left), as shown by the prototype:
enum GetError(void); Unsigned 11-Bit no sign bit, 5-bit exp., 6-bit mant.
Graphics Reset Recovery [2.3.2] Unsigned 10-Bit no sign bit, 5-bit exp., 5-bit mant. return-type Name{1234}{b s i i64 f d ub us ui ui64}{v} ([args ,] T arg1 , . . . , T argN [, args]);
enum GetGraphicsResetStatus(void); Command Letters [Tables 2.1, 2.2] The arguments enclosed in brackets ([args ,] and [, args]) may or may not be present.
Returns: NO_ERROR, GUILTY_CONTEXT_RESET, Where a letter denotes a type in a function
{INNOCENT, UNKNOWN}_CONTEXT_RESET name, T within the prototype is the same type. The argument type T and the number N of arguments may be indicated by the command name
GetIntegerv(RESET_NOTIFICATION_STRATEGY); b - byte (8 bits) suffixes. N is 1, 2, 3, or 4 if present. If “v” is present, an array of N items is passed by a pointer.
ub - ubyte (8 bits) For brevity, the OpenGL documentation and this reference may omit the standard prefixes.
Returns: NO_RESET_NOTIFICATION, s - short (16 bits) us - ushort (16 bits)
LOSE_CONTEXT_ON_RESET The actual names are of the forms: glFunctionName(), GL_CONSTANT, GLtype
i - int (32 bits) ui - uint (32 bits)
Flush and Finish [2.3.3] i64 - int64 (64 bits) ui64 - uint64 (64 bits)
void Flush(void); void Finish(void); f - float (32 bits) d - double (64 bits)
Asynchronous Queries [4.2, 4.2.1] void EndQueryIndexed(enum target,
void GenQueries(sizei n, uint *ids); uint index);
Timer Queries [4.3] void QueryCounter(uint id, TIMESTAMP); void CreateQueries(enum target, sizei n, boolean IsQuery(uint id);
Timer queries track the amount of time needed void GetIntegerv(TIMESTAMP, int *data); uint *ids); void GetQueryiv(enum target, enum pname,
to fully complete a set of GL commands. void GetInteger64v(TIMESTAMP, int64 *data); target: See BeginQuery, plus TIMESTAMP int *params);
void DeleteQueries(sizei n, const uint *ids); target: See BeginQuery, plus TIMESTAMP
pname: CURRENT_QUERY, QUERY_COUNTER_BITS
Synchronization Waiting for Sync Objects [4.1.1] void BeginQuery(enum target, uint id);
void GetQueryIndexediv(enum target,
Sync Objects and Fences [4.1] enum ClientWaitSync(sync sync, target: ANY_SAMPLES_PASSED[_CONSERVATIVE],
bitfield flags, uint64 timeout_ns); PRIMITIVES_GENERATED, SAMPLES_PASSED, uint index, enum pname, int *params);
void DeleteSync(sync sync); TIME_ELAPSED, {PRIMITIVES, VERTICES}_SUBMITTED, target: See BeginQuery, plus TIMESTAMP
flags: SYNC_FLUSH_COMMANDS_BIT, or zero
sync FenceSync(enum condition, bitfield flags); TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, pname: CURRENT_QUERY, QUERY_COUNTER_BITS
condition: SYNC_GPU_COMMANDS_COMPLETE
void WaitSync(sync sync, bitfield flags, TRANSFORM_FEEDBACK_[STREAM_]OVERFLOW,
uint64 timeout); {COMPUTE, VERTEX}_SHADER_INVOCATIONS, void GetQueryObjectiv(uint id, enum pname,
flags: must be 0 int *params);
timeout: TIMEOUT_IGNORED {FRAGMENT, GEOMETRY}_SHADER_INVOCATIONS,
Sync Object Queries [4.1.3] TESS_EVALUATION_SHADER_INVOCATIONS, void GetQueryObjectuiv(uint id,
Buffer Objects [6] void GetSynciv(sync sync, enum pname,
TESS_CONTROL_SHADER_PATCHES,
GEOMETRY_SHADER_PRIMITIVES_EMITTED,
enum pname, uint *params);
void GenBuffers(sizei n, uint *buffers); sizei bufSize, sizei *length, int *values); CLIPPING_{INPUT, OUTPUT}_PRIMITIVES void GetQueryObjecti64v(uint id,
void CreateBuffers(sizei n, uint *buffers); pname: OBJECT_TYPE, SYNC_{STATUS, CONDITION, FLAGS}
void BeginQueryIndexed(enum target, enum pname, int64 *params);
void DeleteBuffers(sizei n, const uint *buffers); boolean IsSync(sync sync); uint index, uint id); void GetQueryObjectui64v(uint id,
Create and Bind Buffer Objects [6.1] target: See BeginQuery enum pname, uint64 *params);
void BindBuffer(enum target, uint buffer); void BufferSubData(enum target, void EndQuery(enum target); pname: QUERY_TARGET,
target: [Table 6.1] {ARRAY, UNIFORM}_BUFFER, intptr offset, sizeiptr size, QUERY_RESULT[_NO_WAIT, _AVAILABLE]
{ATOMIC_COUNTER, QUERY}_BUFFER, const void *data);
COPY_{READ, WRITE}_BUFFER, target: See BindBuffer
{DISPATCH, DRAW}_INDIRECT_BUFFER, void NamedBufferSubData(uint buffer, void *MapBuffer(enum target, enum access); void GetBufferParameteri[64]v(
{ELEMENT_ARRAY, TEXTURE}_BUFFER, intptr offset, sizeiptr size, access: See MapBufferRange enum target, enum pname, int[64]*data);
PIXEL_[UN]PACK_BUFFER, const void *data); void *MapNamedBuffer(uint buffer, target: See BindBuffer
{PARAMETER, SHADER_STORAGE}_BUFFER, pname: [Table 6.2] BUFFER_SIZE, BUFFER_USAGE,
TRANSFORM_FEEDBACK_BUFFER void ClearBufferSubData(enum target, enum access);
BUFFER_{ACCESS[_FLAGS]}, BUFFER_MAPPED,
enum internalFormat, intptr offset, access: See MapBufferRange BUFFER_MAP_{OFFSET, LENGTH},
void BindBufferRange(enum target, sizeiptr size, enum format, enum type,
uint index, uint buffer, intptr offset, void FlushMappedBufferRange(intptr offset, BUFFER_{IMMUTABLE_STORAGE, ACCESS_FLAGS}
const void *data); sizeiptr length);
sizeiptr size); target: See BindBuffer void GetNamedBufferParameteri[64]v(
target: ATOMIC_COUNTER_BUFFER, internalformat: See TexBuffer on pg. 3 of this card void FlushMappedNamedBufferRange( uint buffer, enum pname, int[64]*data);
{SHADER_STORAGE, UNIFORM}_BUFFER, uint buffer, intptr offset, sizeiptr length);
TRANSFORM_FEEDBACK_BUFFER format: RED, GREEN, BLUE, RG, RGB, RGBA, BGR, void GetBufferPointerv(enum target,
BGRA, {RED, GREEN, BLUE, RG, RGB}_INTEGER, boolean UnmapBuffer(enum target); enum pname, const void **params);
void BindBufferBase(enum target, {RGBA, BGR, BGRA} _INTEGER, STENCIL_INDEX, target: See BindBuffer target: See BindBuffer
uint index, uint buffer); DEPTH_{COMPONENT, STENCIL} boolean UnmapNamedBuffer(uint buffer); pname: BUFFER_MAP_POINTER
target: See BindBufferRange void ClearNamedBufferSubData(
Invalidate Buffer Data [6.5] void GetNamedBufferPointerv(uint buffer,
void BindBuffersRange(enum target, uint buffer, enum internalFormat, enum pname, const void **params);
uint first, sizei count, const uint *buffers, intptr offset, sizeiptr size, enum format, void InvalidateBufferSubData(uint buffer,
enum type, const void *data); intptr offset, sizeiptr length); pname: BUFFER_MAP_POINTER
const intptr *offsets, const sizeiptr *size);
target: See BindBufferRange internalformat, format, type: See Copy Between Buffers [6.6]
ClearBufferSubData void InvalidateBufferData(uint buffer);
void BindBuffersBase(enum target, void CopyBufferSubData(enum readTarget,
uint first, sizei count, void ClearBufferData(enum target, Buffer Object Queries [6, 6.7] enum writeTarget, intptr readOffset,
const uint *buffers); enum internalformat, enum format, boolean IsBuffer(uint buffer); intptr writeOffset, sizeiptr size);
target: See BindBufferRange
enum type, const void *data); readTarget and writeTarget: See BindBuffer
target, internalformat, format: See void GetBufferSubData(enum target,
Create/Modify Buffer Object Data [6.2] ClearBufferSubData intptr offset, sizeiptr size, void *data); void CopyNamedBufferSubData(
target: See BindBuffer uint readBuffer, uint writeBuffer,
void BufferStorage(enum target, void ClearNamedBufferData(uint buffer, intptr readOffset, intptr writeOffset,
sizeiptr size, const void *data, enum internalformat, enum format, void GetNamedBufferSubData(uint buffer, sizeiptr size);
bitfield flags); enum type, const void *data); intptr offset, sizeiptr size, void *data);
target: See BindBuffer internalformat, format, type: See ClearBufferData
flags: Bitwise OR of MAP_{READ, WRITE}_BIT,
{DYNAMIC, CLIENT}_STORAGE_BIT, Map/Unmap Buffer Data [6.3] Shaders and Programs boolean IsShader(uint shader);
MAP_{COHERENT, PERSISTENT}_BIT void *MapBufferRange(enum target, void ShaderBinary(sizei count,
void NamedBufferStorage(uint buffer, intptr offset, sizeiptr length, Shader Objects [7.1-2] const uint *shaders, enum binaryformat,
sizeiptr size, const void *data, bitfield access); uint CreateShader(enum type); const void *binary, sizei length);
target: See BindBuffer
bitfield flags); type: {COMPUTE, FRAGMENT}_SHADER, void SpecializeShader(uint shader,
access: The Bitwise OR of MAP_X_BIT, where X may {GEOMETRY, VERTEX}_SHADER,
flags: See BufferStorage be READ, WRITE, PERSISTENT, COHERENT, const char *pEntryPoint,
TESS_{EVALUATION, CONTROL}_SHADER uint numSpecializationConstants,
void BufferData(enum target, sizeiptr size, INVALIDATE_{BUFFER, RANGE},
const void *data, enum usage); FLUSH_EXPLICIT, UNSYNCHRONIZED void ShaderSource(uint shader, sizei count, const uint *pConstantIndex,
target: See BindBuffer const char * const * string, const int const int *pConstantValue );
void *MapNamedBufferRange(uint buffer,
usage: DYNAMIC_{DRAW, READ, COPY}, intptr offset, sizeiptr length, *length);
Program Objects [7.3]
{STATIC, STREAM}_{DRAW, READ, COPY} bitfield access); void CompileShader(uint shader); uint CreateProgram(void);
void NamedBufferData(uint buffer, sizeiptr target: See BindBuffer
access: See MapBufferRange void ReleaseShaderCompiler(void); void AttachShader(uint program, uint shader);
size, const void *data, enum usage);
void DeleteShader(uint shader); (Continued on next page)

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


Page 2 OpenGL 4.6 API Reference Guide
Shaders and Programs (cont.) void ActiveShaderProgram(uint pipeline,
uint program);
void ProgramUniform{1234}{i f d}(
uint program, int location, T value);
Shader and Program Queries [7.13]
void GetShaderiv(uint shader, enum pname,
void DetachShader(uint program, int *params);
uint shader); Program Binaries [7.5] void ProgramUniform{1234}{i f d}v(
uint program, int location, sizei count, pname: SHADER_TYPE, INFO_LOG_LENGTH,
void LinkProgram(uint program); void GetProgramBinary(uint program, {DELETE, COMPILE}_STATUS, COMPUTE_SHADER,
sizei bufSize, sizei *length, const T *value);
void UseProgram(uint program); SHADER_SOURCE_LENGTH, SPIR_V_BINARY
enum *binaryFormat, void *binary); void ProgramUniform{1234}uiv(
uint CreateShaderProgramv(enum type, void ProgramBinary(uint program, uint program, int location, sizei count, void GetProgramiv(uint program,
sizei count, const char * const * strings); enum binaryFormat, const void *binary, const T *value); enum pname, int *params);
sizei length); pname: ACTIVE_ATOMIC_COUNTER_BUFFERS,
void ProgramParameteri(uint program, void ProgramUniform{1234}ui( ACTIVE_ATTRIBUTES,
enum pname, int value); Uniform Variables [7.6] uint program, int location, T value); ACTIVE_ATTRIBUTE_MAX_LENGTH,
pname: PROGRAM_SEPARABLE, int GetUniformLocation(uint program, void ProgramUniformMatrix{234}{f d}v( ACTIVE_UNIFORMS, ACTIVE_UNIFORM_BLOCKS,
PROGRAM_BINARY_RETRIEVABLE_HINT const char *name); uint program, int location, sizei count, ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH,
value: TRUE, FALSE void GetActiveUniformName(uint program, boolean transpose, const T *value); ACTIVE_UNIFORM_MAX_LENGTH,
uint uniformIndex, sizei bufSize, ATTACHED_SHADERS, VALIDATE_STATUS,
void DeleteProgram(uint program); void ProgramUniformMatrixf{2x3,3x2,2x4, COMPUTE_WORK_GROUP_SIZE, DELETE_STATUS,
sizei *length, char *uniformName);
boolean IsProgram(uint program); 4x2, 3x4, 4x3}{f d}v( GEOMETRY_{INPUT, OUTPUT}_TYPE,
void GetUniformIndices(uint program, uint program, int location, sizei count, GEOMETRY_SHADER_INVOCATIONS,
Program Interfaces [7.3.1] sizei uniformCount, boolean transpose, const T *value); GEOMETRY_VERTICES_OUT, INFO_LOG_LENGTH,
void GetProgramInterfaceiv(uint program, const char * const *uniformNames, LINK_STATUS, PROGRAM_SEPARABLE,
uint *uniformIndices); Uniform Buffer Object Bindings PROGRAM_BINARY_RETRIEVABLE_HINT,
enum programInterface, enum pname,
int *params); void UniformBlockBinding(uint program, TESS_CONTROL_OUTPUT_VERTICES,
void GetActiveUniform(uint program, uint uniformBlockIndex,
programInterface: uint index, sizei bufSize, sizei *length, TESS_GEN_{MODE, SPACING},
ATOMIC_COUNTER_BUFFER, BUFFER_VARIABLE, int *size, enum *type, char *name); uint uniformBlockBinding); TESS_GEN_{VERTEX_ORDER, POINT_MODE},
UNIFORM[_BLOCK], PROGRAM_{INPUT, OUTPUT}, *type returns: DOUBLE_{VECn, MATn, MATmxn}, Shader Buffer Variables [7.8] TRANSFORM_FEEDBACK_BUFFER_MODE,
SHADER_STORAGE_BLOCK, DOUBLE, FLOAT_{VECn, MATn, MATmxn}, FLOAT, TRANSFORM_FEEDBACK_VARYINGS,
{GEOMETRY, VERTEX}_SUBROUTINE, void ShaderStorageBlockBinding( TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH
INT, INT_VECn, UNSIGNED_INT[_VECn], BOOL, uint program, uint storageBlockIndex,
TESS_{CONTROL, EVALUATION}_SUBROUTINE, BOOL_VECn, or any value in [Table 7.3]
{FRAGMENT, COMPUTE}_SUBROUTINE, uint storageBlockBinding); void GetProgramPipelineiv(uint pipeline,
TESS_CONTROL_SUBROUTINE_UNIFORM, void GetActiveUniformsiv(uint program, Subroutine Uniform Variables [7.9] enum pname, int *params);
TESS_EVALUATION_SUBROUTINE_UNIFORM, sizei uniformCount, Parameter shadertype for the functions in this pname: ACTIVE_PROGRAM, VALIDATE_STATUS,
{GEOMETRY, VERTEX}_SUBROUTINE_UNIFORM, const uint *uniformIndices, enum pname, section may be {COMPUTE, VERTEX}_SHADER, {VERTEX, FRAGMENT, GEOMETRY}_SHADER,
{FRAGMENT, COMPUTE}_SUBROUTINE_UNIFORM, int *params); TESS_{CONTROL, EVALUATION}_SHADER, or TESS_{CONTROL, EVALUATION}_SHADER,
TRANSFORM_FEEDBACK_{BUFFER, VARYING} pname: [Table 7.6] {FRAGMENT, GEOMETRY}_SHADER INFO_LOG_LENGTH, COMPUTE_SHADER
pname: ACTIVE_RESOURCES, MAX_NAME_LENGTH, UNIFORM_{NAME_LENGTH, TYPE, OFFSET}, void GetAttachedShaders(uint program,
MAX_NUM_ACTIVE_VARIABLES, UNIFORM_{SIZE, BLOCK_INDEX, UNIFORM}, int GetSubroutineUniformLocation(
uint program, enum shadertype, sizei maxCount, sizei *count,
MAX_NUM_COMPATIBLE_SUBROUTINES UNIFORM_{ARRAY, MATRIX}_STRIDE, uint *shaders);
UNIFORM_IS_ROW_MAJOR, const char *name);
uint GetProgramResourceIndex( UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX void GetShaderInfoLog(uint shader,
uint program, enum programInterface, uint GetSubroutineIndex(uint program,
enum shadertype, const char *name); sizei bufSize, sizei *length, char *infoLog);
const char *name); uint GetUniformBlockIndex(uint program,
const char *uniformBlockName); void GetActiveSubroutineName( void GetProgramInfoLog(uint program,
void GetProgramResourceName( uint program, enum shadertype, sizei bufSize, sizei *length, char *infoLog);
uint program, enum programInterface, void GetActiveUniformBlockName( uint index, sizei bufsize, sizei *length,
uint index, sizei bufSize, sizei *length, uint program, uint uniformBlockIndex, char *name); void GetProgramPipelineInfoLog(
char *name); sizei bufSize, sizei length, uint pipeline, sizei bufSize,
char *uniformBlockName); void GetActiveSubroutineUniformName( sizei *length, char *infoLog);
void GetProgramResourceiv(uint program, uint program, enum shadertype,
enum programInterface, uint index, void GetActiveUniformBlockiv( uint index, sizei bufsize, sizei *length, void GetShaderSource(uint shader,
sizei propCount, const enum *props, uint program, uint uniformBlockIndex, char *name); sizei bufSize, sizei *length, char *source);
sizei bufSize, sizei *length, int *params); enum pname, int *params);
pname: UNIFORM_BLOCK_{BINDING, DATA_SIZE}, void GetActiveSubroutineUniformiv( void GetShaderPrecisionFormat(
*props: [See Table 7.2] enum shadertype, enum precisiontype,
UNIFORM_BLOCK_NAME_LENGTH, uint program, enum shadertype,
int GetProgramResourceLocation( UNIFORM_BLOCK_ACTIVE_UNIFORMS[_INDICES], uint index, enum pname, int *values); int *range, int *precision);
uint program, enum programInterface, UNIFORM_BLOCK_REFERENCED_BY_X_SHADER, pname: [NUM_]COMPATIBLE_SUBROUTINES shadertype: {VERTEX, FRAGMENT}_SHADER
const char *name); where X may be one of VERTEX, FRAGMENT, precisiontype: {LOW, MEDIUM, HIGH}_{FLOAT, INT}
COMPUTE, GEOMETRY, TESS_CONTROL, or void UniformSubroutinesuiv(
int GetProgramResourceLocationIndex( enum shadertype, sizei count, void GetUniform{f d i ui}v(uint program,
uint program, enum programInterface, TESS_EVALUATION [Table 7.7]
const uint *indices); int location, T *params);
const char *name); void GetActiveAtomicCounterBufferiv( Shader Memory Access [7.12.2]
uint program, uint bufferIndex, void GetnUniform{f d i ui}v(uint program,
Program Pipeline Objects [7.4] See diagram on page 6 for more information. int location, sizei bufSize, T *params);
enum pname, int *params);
void GenProgramPipelines(sizei n, pname: See GetActiveUniformBlockiv, however void MemoryBarrier(bitfield barriers); void GetUniformSubroutineuiv(
uint *pipelines); replace the prefix UNIFORM_BLOCK_ with barriers: ALL_BARRIER_BITS or the OR of enum shadertype, int location,
void DeleteProgramPipelines(sizei n, ATOMIC_COUNTER_BUFFER_ X_BARRIER_BIT where X may be: QUERY_BUFFER, uint *params);
const uint *pipelines); VERTEX_ATTRIB_ARRAY, ELEMENT_ARRAY,
Load Uniform Vars. in Default Uniform Block UNIFORM, TEXTURE_FETCH, BUFFER_UPDATE, void GetProgramStageiv(uint program,
boolean IsProgramPipeline(uint pipeline); void Uniform{1234}{i f d ui}(int location, SHADER_IMAGE_ACCESS, COMMAND, enum shadertype, enum pname,
T value); PIXEL_BUFFER, TEXTURE_UPDATE, FRAMEBUFFER, int *values);
void BindProgramPipeline(uint pipeline); TRANSFORM_FEEDBACK, ATOMIC_COUNTER, pname: ACTIVE_SUBROUTINES,
void Uniform{1234}{i f d ui}v(int location, SHADER_STORAGE, CLIENT_MAPPED_BUFFER, ACTIVE_SUBROUTINE_X where X may be
void CreateProgramPipelines(sizei n, sizei count, const T *value);
uint *pipelines); UNIFORMS, MAX_LENGTH, UNIFORM_LOCATIONS,
void MemoryBarrierByRegion(bitfield UNIFORM_MAX_LENGTH
void UniformMatrix{234}{f d}v( barriers);
void UseProgramStages(uint pipeline, int location, sizei count, boolean transpose, barriers: ALL_BARRIER_BITS or the OR of
bitfield stages, uint program); const float *value);
stages: ALL_SHADER_BITS or the bitwise OR of X_BARRIER_BIT where X may be:
TESS_{CONTROL, EVALUATION}_SHADER_BIT, void ATOMIC_COUNTER, FRAMEBUFFER,
{VERTEX, GEOMETRY, FRAGMENT}_SHADER_BIT, UniformMatrix{2x3,3x2,2x4,4x2,3x4, 4x3} SHADER_IMAGE_ACCESS, SHADER_STORAGE,
COMPUTE_SHADER_BIT {fd}v( int location, sizei count, TEXTURE_FETCH, UNIFORM
boolean transpose, const float *value);

Textures and Samplers [8] void BindTextureUnit(uint unit, uint texture); void SamplerParameter{i f}(uint sampler,
enum pname, T param);
Sampler Queries [8.3]
void ActiveTexture(enum texture); void CreateTextures(enum target, sizei n, void GetSamplerParameter{i f}v(
texture: TEXTUREi (where i is uint *textures); void SamplerParameter{i f}v(uint sampler, uint sampler, enum pname, T *params);
[0, max(MAX_TEXTURE_COORDS, target: See BindTexture enum pname, const T *param); pname: See SamplerParameter{if}
MAX_COMBINED_TEXTURE_IMAGE_UNITS)-1]) void GetSamplerParameterI{i ui}v(
void DeleteTextures(sizei n, void SamplerParameterI{i ui}v(uint sampler,
Texture Objects [8.1] const uint *textures); enum pname, const T *params); uint sampler, enum pname, T *params);
void GenTextures(sizei n, uint *textures); pname: for all SamplerParameter* functions: pname: See SamplerParameter{if}
boolean IsTexture(uint texture);
TEXTURE_X where X may be WRAP_{S, T, R},
void BindTexture(enum target, uint texture); Pixel Storage Modes [8.4.1]
Sampler Objects [8.2] {MIN, MAG}_FILTER, {MIN, MAX}_LOD,
void PixelStore{i f}(enum pname, T param);
target: TEXTURE_{1D, 2D}[_ARRAY], void GenSamplers(sizei count, uint *samplers); BORDER_COLOR, LOD_BIAS, MAX_ANISOTROPY
TEXTURE_{3D, RECTANGLE, BUFFER}, COMPARE_{MODE, FUNC} [Table 23.18] pname: [Tables 8.1, 18.1] [UN]PACK_X where X may
TEXTURE_CUBE_MAP[_ARRAY], void CreateSamplers(sizei n, uint *samplers); be SWAP_BYTES, LSB_FIRST, ROW_LENGTH,
TEXTURE_2D_MULTISAMPLE[_ARRAY] void DeleteSamplers(sizei count, SKIP_{IMAGES, PIXELS, ROWS}, ALIGNMENT,
void BindSampler(uint unit, uint sampler); const uint *samplers); IMAGE_HEIGHT, COMPRESSED_BLOCK_WIDTH,
void BindTextures(uint first, sizei count, COMPRESSED_BLOCK_{HEIGHT, DEPTH, SIZE}
const uint *textures); void BindSamplers(uint first, sizei count, boolean IsSampler(uint sampler);
target: See BindTexture const uint *samplers); (Continued on next page)
©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl
OpenGL 4.6 API Reference Guide Page 3
Textures and Samplers (cont.) void TextureSubImage1D(uint texture, int level, Buffer Textures [8.9]
int xoffset, sizei width, enum format,
void GetTextureLevelParameter{i f}v(
uint texture, int level, enum pname,
void TexBufferRange(enum target,
Texture Image Spec. [8.5] enum type, const void *pixels); enum internalFormat, uint buffer, T *params);
void TexImage3D(enum target, int level, format, type: See TexImage3D intptr offset, sizeiptr size); pname: See GetTexLevelParameter{i f}v
int internalformat, sizei width, sizei height, void CopyTextureSubImage3D(uint texture,
sizei depth, int border, enum format, void TextureBufferRange(uint texture, void GetTexImage(enum target, int level,
int level, int xoffset, int yoffset, int zoffset, enum internalFormat, uint buffer, enum format, enum type, void *pixels);
enum type, const void *data); int x, int y, sizei width, sizei height); intptr offset, sizeiptr size);
target: [PROXY_]TEXTURE_CUBE_MAP_ARRAY, target: TEXTURE_{1, 2}D[_ARRAY],
internalformat: See TexBuffer TEXTURE_{3D, RECTANGLE, CUBE_MAP_ARRAY},
[PROXY_]TEXTURE_2D_ARRAY, [PROXY_]TEXTURE_3D void CopyTextureSubImage2D(uint texture,
internalformat: STENCIL_INDEX, RED, int level, int xoffset, int yoffset, int x, void TexBuffer(enum target, TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z},
DEPTH_{COMPONENT, STENCIL}, RG, RGB, RGBA, int y, sizei width, sizei height); enum internalformat, uint buffer); TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z}
COMPRESSED_{RED, RG, RGB, RGBA, SRGB, target: TEXTURE_BUFFER format: See TexImage3D
void CopyTextureSubImage1D(uint texture,
SRGB_ALPHA), a sized internal format from int level, int xoffset, int x, int y, sizei width); internalformat: [Table 8.16] R8, R8{I, UI}, R16, type: [UNSIGNED_]BYTE, SHORT, INT,
[Tables 8.12 - 8.13], or a COMPRESSED_ format R16{F, I, UI}, R32{F, I, UI}, RG8, RG8{I, UI}, RG16, [HALF_]FLOAT, or a value from [Table 8.2]
from [Table 8.14] Compressed Texture Images [8.7] RG16{F, I, UI}, RG32{F, I, UI}, RGB32F, RGB32{I, UI}, void GetTextureImage(uint texture, int level,
format: DEPTH_{COMPONENT, STENCIL}, RED, void CompressedTexImage3D(enum target, RGBA8, RGBA8{I, UI}, RGBA16, RGBA16{F, I, UI}, enum format, enum type, sizei bufSize,
GREEN, BLUE, RG, RGB, RGBA, BGR, BGRA, int level, enum internalformat, sizei width, RGBA32{F, I, UI} void *pixels);
{BGRA, RED, GREEN, BLUE}_INTEGER, sizei height, sizei depth, int border,
{RG, RGB, RGBA, BGR}_INTEGER, void TextureBuffer(uint texture, level: LOD level
sizei imageSize, const void *data);
STENCIL_INDEX, [Table 8.3] target: See TexImage3D enum internalformat, uint buffer); format, type: See GetTexImage
type: [UNSIGNED_]{BYTE, SHORT, INT}, internalformat: See TexBuffer void GetnTexImage(enum tex, int level,
internalformat: A COMPRESSED_
[HALF_]FLOAT, or a value from [Table 8.2] format from [Table 8.14] Texture Parameters [8.10] enum format, enum type, sizei bufSize,
void TexImage2D(enum target, int level, void TexParameter{i f}(enum target, void *pixels);
void CompressedTexImage2D(enum target,
int internalformat, sizei width, int level, enum internalformat, enum pname, T param); tex: TEXTURE_{1D, 2D, 3D}[_ARRAY], TEXTURE_3D,
sizei height, int border, enum format, sizei width, sizei height, int border, target: See BindTexture TEXTURE_{CUBE_MAP_ARRAY, RECTANGLE},
enum type, const void *data); sizei imageSize, const void *data); TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z},
target: [PROXY_]TEXTURE_{2D, RECTANGLE}, void TexParameter{i f}v(enum target, TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z}
target: See TexImage2D
[PROXY_]TEXTURE_{1D_ARRAY, CUBE_MAP}, enum pname, const T *params); level, format, type: See GetTextureImage
internalformat: May be one of the COMPRESSED_
TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z}, target: See BindTexture
formats from [Table 8.14] void GetTextureSubImage(uint texture,
TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z} void TexParameterI{i ui}v(enum target, int level, int xoffset, int yoffset, int zoffset,
internalformat, format, type: See TexImage3D void CompressedTexImage1D(enum target,
int level, enum internalformat, enum pname, const T *params); sizei width, sizei height, sizei depth,
void TexImage1D(enum target, int level, sizei width, int border, sizei imageSize, target: See BindTexture enum format, enum type, sizei bufSize,
int internalformat, sizei width, int border, const void *data); void *pixels);
pname for all TexParameter* functions:
enum format, enum type, const void *data); target: TEXTURE_1D, PROXY_TEXTURE_1D level, format, type: See GetTextureImage
DEPTH_STENCIL_TEXTURE_MODE or
target: TEXTURE_1D, PROXY_TEXTURE_1D internalformat: See TexImage1D, omitting TEXTURE_X where X may be one of void GetCompressedTexImage(enum target,
type, internalformat, format: See TexImage3D compressed rectangular texture formats WRAP_{S, T, R}, BORDER_COLOR, int level, void *pixels);
{MIN, MAG}_FILTER, LOD_BIAS,{MIN, MAX}_LOD, target: See GetTextureImage
Alternate Texture Image Spec. [8.6] void CompressedTexSubImage3D( {BASE, MAX}_LEVEL, SWIZZLE_{R, G, B, A, RGBA},
enum target, int level, int xoffset, COMPARE_{MODE, FUNC} [Table 8.17] void
void CopyTexImage2D(enum target, int yoffset, int zoffset, sizei width,
int level, enum internalformat, int x, GetCompressedTextureImage(uint texture,
sizei height, sizei depth, enum format, void TextureParameter{i f}(uint texture, int level, sizei bufSize, void *pixels);
int y, sizei width, sizei height, int border); sizei imageSize, const void *data); enum pname, T param);
target: TEXTURE_{2D, RECTANGLE, 1D_ARRAY}, level: See GetTextureImage
target: See TexSubImage3D pname: See BindTexture
TEXTURE_CUBE_MAP_{POSITIVE, NEGATIVE}_{X, Y, Z} format: See internalformat for void GetnCompressedTexImage(enum target,
internalformat: See TexImage3D CompressedTexImage3D void TextureParameter{i f}v(uint texture, int level, sizei bufsize, void *pixels);
void CompressedTexSubImage2D( enum pname, const T *params); target: See GetCompressedTexImage
void CopyTexImage1D(enum target,
int level, enum internalformat, int x, enum target, int level, int xoffset, pname: See BindTexture level: LOD level
int y, sizei width, int border); int yoffset, sizei width, sizei height, void TextureParameterI{i ui}v(uint texture, void GetCompressedTextureSubImage(
target: TEXTURE_1D enum format, sizei imageSize, enum pname, const T *params); uint texture, int level, int xoffset, int yoffset,
internalformat: See TexImage3D cont void *data); int zoffset, sizei width, sizei height,
target: See TexSubImage2D pname for all TextureParameter* functions:
void TexSubImage3D(enum target, int level, TEXTURE_{3D, RECTANGLE, MAX_ANISOTROPY}, sizei depth, sizei bufSize, void *pixels);
format: See internalformat for
int xoffset, int yoffset, int zoffset, CompressedTexImage2D TEXTURE_{1D, 2D, CUBE_MAP}[_ARRAY], level: LOD level
sizei width, sizei height, sizei depth, TEXTURE_2D_MULTISAMPLE[_ARRAY]
void CompressedTexSubImage1D( Cube Map Texture Select [8.13.1]
enum format, enum type, enum target, int level, int xoffset, Texture Queries [8.11]
const void *data); Enable/Disable/IsEnabled(
sizei width, enum format, sizei imageSize, void GetTexParameter{if}v(enum target, TEXTURE_CUBE_MAP_SEAMLESS);
target: TEXTURE_3D, TEXTURE_2D_ARRAY, const void *data);
TEXTURE_CUBE_MAP_ARRAY enum pname, T * params);
target: See TexSubImage1D target: See BindTexture Manual Mipmap Generation [8.14.4]
format, type: See TexImage3D format: See internalformat for void GenerateMipmap(enum target);
pname: See GetTexParameterI{i ui}v
void TexSubImage2D(enum target, CompressedTexImage1D target: TEXTURE_{1D, 2D, 3D},
int level, int xoffset, int yoffset, sizei width, void CompressedTextureSubImage3D( void GetTexParameterI{i ui}v(enum target, TEXTURE_{1D, 2D}_ARRAY,
sizei height, enum format, enum type, uint texture, int level, int xoffset, enum pname, T * params); TEXTURE_CUBE_MAP[_ARRAY]
const void *data); int yoffset, int zoffset, sizei width, target: See BindTexture void GenerateTextureMipmap(uint texture);
target: See CopyTexImage2D sizei height, sizei depth, enum format, pname: IMAGE_FORMAT_COMPATIBILITY_TYPE,
format, type: See TexImage3D sizei imageSize, const void *data); TEXTURE_IMMUTABLE_{FORMAT, LEVELS}, Texture Views [8.18]
format: See internalformat for TEXTURE_VIEW_MIN_{LEVEL, LAYER}, void TextureView(uint texture, enum target,
void TexSubImage1D(enum target, int level, TEXTURE_VIEW_NUM_{LEVELS, LAYERS},
int xoffset, sizei width, enum format, CompressedTexImage3D uint origtexture, enum internalformat,
DEPTH_STENCIL_TEXTURE_MODE, or TEXTURE_X uint minlevel, uint numlevels, uint minlayer,
enum type, const void *data); void CompressedTextureSubImage2D( where X may be one of WRAP_{S, T, R},
target, format, type: See CopyTexImage1D uint texture, int level, int xoffset, uint numlayers);
BORDER_COLOR, TARGET, {MIN, MAG}_FILTER,
int yoffset, sizei width, sizei height, LOD_BIAS,{MIN, MAX}_LOD, {BASE, MAX}_LEVEL, target: TEXTURE_{1D, 2D,CUBE_MAP}[_ARRAY],
void CopyTexSubImage3D(enum target, enum format, sizei imageSize, SWIZZLE_{R, G, B, A, RGBA}, TEXTURE_3D, TEXTURE_RECTANGLE,
int level, int xoffset, int yoffset, int zoffset, cont void *data); COMPARE_{MODE, FUNC} [Table 8.17] TEXTURE_2D_MULTISAMPLE[_ARRAY]
int x, int y, sizei width, sizei height); format: See internalformat for internalformat:
target: See TexSubImage3D CompressedTexImage2D void GetTextureParameter{if}v(uint texture, R8, R8{UI, I}, R8_SNORM, R11F_G11F_B10F,
void CopyTexSubImage2D(enum target, enum pname, T *data); R16{F, UI, I}, R16[_SNORM],
void CompressedTextureSubImage1D( pname: See GetTexParameterI{i ui}v R32{F, UI, I}, SRGB8[UI, I],
int level, int xoffset, int yoffset, int x, uint texture, int level, int xoffset, RG8{F, UI, I}, RG8[_SNORM],
int y, sizei width, sizei height); sizei width, enum format, sizei imageSize, void GetTextureParameterI{i ui}v(uint texture, RG16{F, UI, I}, RG16[_SNORM], RG32{F, UI, I},
target: See TexImage2D const void *data); enum pname, T *data); RGB8[_SNORM], RGB9_E5, RGB10_A2[UI],
void CopyTexSubImage1D(enum target, format: See internalformat for pname: See GetTexParameterI{i ui}v RGBA8{UI, I}, RGBA8[_SNORM],
int level, int xoffset, int x, int y, sizei width); CompressedTexImage1D RGB16{F, UI, I}, RGB16[_SNORM], RGB32{F, UI, I},
target: See TexSubImage1D Multisample Textures [8.8] void GetTexLevelParameter{i f}v(enum target, RGBA16{F, UI, I}, RGBA16[_SNORM],
int level, enum pname, T *params); RGBA32{F, UI, I}, SRGB8_ALPHA8;
void TextureSubImage3D(uint texture, int level, void TexImage3DMultisample(enum target, target: [PROXY_]TEXTURE_{1D, 2D, 3D}, COMPRESSED_X where X may be
int xoffset, int yoffset, int zoffset, sizei samples, int internalformat, [SIGNED]_RED_RGTC1, [SIGNED]_RG_RGTC2,
sizei width, sizei height, sizei depth, TEXTURE_BUFFER, PROXY_TEXTURE_CUBE_MAP,
sizei width, sizei height, sizei depth, [PROXY_]TEXTURE_{1D, 2D,CUBE_MAP}_ARRAY, {RGBA, SRGB_ALPHA}_BPTC_UNORM,
enum format, enum type, boolean fixedsamplelocations); RGB_BPTC_[UN]SIGNED_FLOAT
target: [PROXY_]TEXTURE_2D_MULTISAMPLE_ARRAY [PROXY_]TEXTURE_RECTANGLE,
const void *pixels); TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z},
format, type: See TexImage3D internalformat: RED, RG, RGB, RGBA, RGBA{32, 32UI},
TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z}, Immutable-Format Tex. Images [8.19]
DEPTH_COMPONENT[16, 24, 32, 32F], void TexStorage1D(enum target, sizei levels,
void TextureSubImage2D(uint texture, int level, DEPTH{24, 32F}_STENCIL8, STENCIL_INDEX{1, 4, 8, 16} [PROXY_]TEXTURE_2D_MULTISAMPLE[_ARRAY]
pname: TEXTURE _*, where * may be WIDTH, enum internalformat, sizei width);
int xoffset, int yoffset, sizei width, void TexImage2DMultisample(enum target, target: TEXTURE_1D
sizei height, enum format, enum type, HEIGHT, DEPTH, FIXED_SAMPLE_LOCATIONS,
sizei samples, int internalformat, sizei width, INTERNAL_FORMAT, SHARED_SIZE, COMPRESSED, internalformat: any of the sized internal color, depth,
const void *pixels); sizei height, boolean fixedsamplelocations); COMPRESSED_IMAGE_SIZE, SAMPLES, and stencil formats in [Tables 8.18-20]
format, type: See TexImage3D target: [PROXY_]TEXTURE_2D_MULTISAMPLE BUFFER_{OFFSET, SIZE}, or X_{SIZE, TYPE}
internalformat: See TexImage3DMultisample where X can be RED, GREEN, BLUE, ALPHA, DEPTH (Continued on next page)

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


Page 4 OpenGL 4.6 API Reference Guide
Textures and Samplers (cont.) void TextureStorage3D(uint texture,
sizei levels, enum internalformat,
void TextureStorage3DMultisample(
uint texture, sizei samples,
void ClearTexImage(uint texture,
int level, enum format, enum type,
void TexStorage2D(enum target, sizei levels, sizei width, sizei height, sizei depth); enum internalformat, sizei width, const void *data);
enum internalformat, sizei width, internalformat: See TexStorage1D sizei height, sizei depth,
sizei height); format, type: See TexImage3D, pg 2 this card
boolean fixedsamplelocations);
target: TEXTURE_{RECTANGLE, CUBE_MAP}, void TexStorage2DMultisample( Texture Image Loads/Stores [8.26]
TEXTURE_{1D_ARRAY, 2D} enum target, sizei samples, Invalidate Texture Image Data [8.20]
enum internalformat, sizei width, void BindImageTexture(uint index,
internalformat: See TexStorage1D
sizei height, boolean fixedsamplelocations); voidintInvalidateTexSubImage(uint texture,
level, int xoffset, int yoffset, int zoffset,
uint texture, int level, boolean layered,
void TexStorage3D(enum target, sizei levels, target: TEXTURE_2D_MULTISAMPLE int layer, enum access, enum format);
enum internalformat, sizei width, sizei width, sizei height, sizei depth); access: READ_ONLY, WRITE_ONLY, READ_WRITE
sizei height, sizei depth); void TexStorage3DMultisample( format: RGBA{32,16}F, RG{32,16}F, R11F_G11F_B10F,
target: TEXTURE_3D, enum target, sizei samples, void InvalidateTexImage(uint texture, int level);
R{32,16}F, RGBA{32,16,8}UI, RGB10_A2UI,
TEXTURE_{CUBE_MAP, 2D}[_ARRAY] enum internalformat, sizei width, Clear Texture Image Data [8.21] RG{32,16,8}UI, R{32,16,8}UI, RGBA{32,16,8}I,
internalformat: See TexStorage1D sizei height, sizei depth, RG{32,16,8}I, R{32,16,8}I, RGBA{16,8}, RGB10_A2,
boolean fixedsamplelocations); void ClearTexSubImage(uint texture,
void TextureStorage1D(uint texture, sizei levels, target: TEXTURE_2D_MULTISAMPLE_ARRAY int level, int xoffset, int yoffset, int zoffset, RG{16,8}, R{16,8}, RGBA{16,8}_SNORM,
enum internalformat, sizei width); sizei width, sizei height, sizei depth, RG{16,8}_SNORM, R{16,8}_SNORM [Table 8.26]
internalformat: See TexStorage1D void TextureStorage2DMultisample( enum format, enum type, const void *data);
uint texture, sizei samples, void BindImageTextures(uint first,
void TextureStorage2D(uint texture, format, type: See TexImage3D, pg 2 this card sizei count, const uint *textures);
enum internalformat, sizei width,
sizei levels, enum internalformat, sizei height, boolean fixedsamplelocations);
sizei width, sizei height);
internalformat: See TexStorage1D

Framebuffer Objects attachment: DEPTH, FRONT_{LEFT, RIGHT}, STENCIL, void NamedRenderbufferStorage(


BACK_{LEFT, RIGHT}, COLOR_ATTACHMENTi, uint renderbuffer, enum internalformat,
void NamedFramebufferTexture(
uint framebuffer, enum attachment,
Binding and Managing [9.2] {DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT sizei width, sizei height); uint texture, int level);
void BindFramebuffer(enum target, pname: FRAMEBUFFER_ATTACHMENT_ X where X internalformat: See TexImage3DMultisample attachment: See FramebufferRenderbuffer
uint framebuffer); may be OBJECT_{TYPE, NAME}, COMPONENT_TYPE, void FramebufferTexture1D(enum target,
target: [DRAW_, READ_]FRAMEBUFFER {RED, GREEN, BLUE, ALPHA, DEPTH, STENCIL}_SIZE, Renderbuffer Object Queries [9.2.6] enum attachment, enum textarget,
COLOR_ENCODING, TEXTURE_{LAYER, LEVEL}, void GetRenderbufferParameteriv( uint texture, int level);
void CreateFramebuffers(sizei n, LAYERED, TEXTURE_CUBE_MAP_FACE enum target, enum pname, int *params); textarget: TEXTURE_1D
uint *framebuffers); target, attachment: See FramebufferRenderbuffer
void GetNamedFramebufferAttachment- target: RENDERBUFFER
void GenFramebuffers(sizei n, Parameteriv(uint framebuffer, pname: [Table 23.27] void FramebufferTexture2D(enum target,
uint *framebuffers); enum attachment, enum pname, RENDERBUFFER_X where X may be WIDTH, enum attachment, enum textarget,
void DeleteFramebuffers(sizei n, int *params); HEIGHT, INTERNAL_FORMAT, SAMPLES, uint texture, int level);
const uint *framebuffers); attachment, pname: See GetFramebufferParameteriv {RED, GREEN, BLUE, ALPHA, DEPTH, STENCIL}_SIZE textarget: TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z},
TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z},
boolean IsFramebuffer(uint framebuffer); Renderbuffer Objects [9.2.4] void GetNamedRenderbufferParameteriv( TEXTURE_{2D, RECTANGLE, 2D_MULTISAMPLE}
void BindRenderbuffer(enum target, uint renderbuffer, enum pname, (unspecified if texture is 0)
Framebuffer Object Parameters [9.2.1] uint renderbuffer); int *params); target, attachment: See FramebufferRenderbuffer
void FramebufferParameteri( target: RENDERBUFFER pname: See GetRenderbufferParameteriv
enum target, enum pname, int param); void FramebufferTexture3D(enum target,
target: [DRAW_, READ_]FRAMEBUFFER void {Create, Gen}Renderbuffers(sizei n, Attaching Renderbuffer Images [9.2.7] enum attachment, enum textarget,
uint *renderbuffers); void FramebufferRenderbuffer( uint texture, int level, int layer);
pname: FRAMEBUFFER_DEFAULT_X where X may
be WIDTH, HEIGHT, FIXED_SAMPLE_LOCATIONS, enum target, enum attachment, textarget: TEXTURE_3D (unspecified if texture is 0)
void DeleteRenderbuffers(sizei n, enum renderbuffertarget, target, attachment: See FramebufferRenderbuffer
SAMPLES, LAYERS const uint *renderbuffers); uint renderbuffer);
void NamedFramebufferParameteri( target: [DRAW_, READ_]FRAMEBUFFER void FramebufferTextureLayer(enum target,
boolean IsRenderbuffer(uint renderbuffer); enum attachment, uint texture,
uint framebuffer, enum pname, int param); attachment: [Table 9.1]
pname: See FramebufferParameteri void RenderbufferStorageMultisample( int level, int layer);
{DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT,
enum target, sizei samples, COLOR_ATTACHMENTi where i is target, attachment: See FramebufferRenderbuffer
Framebuffer Object Queries [9.2.3] enum internalformat, sizei width, [0, MAX_COLOR_ATTACHMENTS - 1] void NamedFramebufferTextureLayer(
void GetFramebufferParameteriv( sizei height); renderbuffertarget: RENDERBUFFER if renderbuffer is uint framebuffer, enum attachment,
enum target, enum pname, int *params); target: RENDERBUFFER non-zero, else undefined uint texture, int level, int layer);
target: See FramebufferParameteri internalformat: See TexImage3DMultisample attachment: See FramebufferRenderbuffer
pname: See FramebufferParameteri plus void NamedFramebufferRenderbuffer(
DOUBLEBUFFER, SAMPLES, SAMPLE_BUFFERS, void uint framebuffer, enum attachment, Feedback Loops [9.3.1]
IMPLEMENTATION_COLOR_READ_FORMAT, NamedRenderbufferStorageMultisample( enum renderbuffertarget,
uint renderbuffer); void TextureBarrier(void);
IMPLEMENTATION_COLOR_READ_TYPE, STEREO uint renderbuffer, sizei samples,
enum internalformat, sizei width, attachment, renderbuffertarget: See Framebuffer Completeness [9.4.2]
void GetNamedFramebufferParameteriv( sizei height); FramebufferRenderbuffer
uint framebuffer, enum pname, int enum CheckFramebufferStatus(enum target);
internalformat: See TexImage3DMultisample target: [DRAW_, READ_]FRAMEBUFFER
*params); Attaching Texture Images [9.2.8]
pname: See GetFramebufferParameteri void RenderbufferStorage(enum target, void FramebufferTexture(enum target, returns: FRAMEBUFFER_COMPLETE or a constant
enum internalformat, sizei width, enum attachment, uint texture, int level); indicating the violating value
void GetFramebufferAttachmentParameteriv( sizei height);
enum target, enum attachment, target: [DRAW_, READ_]FRAMEBUFFER enum CheckNamedFramebufferStatus(
enum pname, int *params); target: RENDERBUFFER attachment: See FramebufferRenderbuffer uint framebuffer, enum target);
target: [DRAW_, READ_]FRAMEBUFFER internalformat: See TexImage3DMultisample target: See CheckFramebufferStatus

Vertices void VertexAttrib{1234}{s f d}(uint index,


T values);
void VertexAttribI{1234}{i ui}(uint index,
T values);
const T *values);
Separate Patches [10.1.15] void VertexAttribP{1234}ui(uint index,
void VertexAttrib{123}{s f d}v(uint index, void VertexAttribI{1234}{i ui}v(uint index, enum type, boolean normalized, uint value);
void PatchParameteri(enum pname, int value); const T *values); const T *values);
pname: PATCH_VERTICES void VertexAttribP{1234}uiv(uint index,
void VertexAttrib4{b s i f d ub us ui}v( void VertexAttribI4{b s ub us}v(uint index, enum type, boolean normalized,
Current Vertex Attribute Values [10.2] uint index, const T *values); const T *values); const uint *value);
Use the commands VertexAttrib*for attributes void VertexAttrib4Nub(uint index, ubyte x, void VertexAttribL{1234}d(uint index, type: [UNSIGNED_]INT_2_10_10_10_REV, or
of type float, VertexAttribI* for int or uint, or ubyte y, ubyte z, ubyte w); const T values); UNSIGNED_INT_10F_11F_11F_REV (except for
VertexAttribL* for double. VertexAttribP4uiv)
void VertexAttrib4N{b s i ub us ui}v( void VertexAttribL{1234}dv(uint index,
uint index, const T *values);

Vertex Arrays Generic Vertex Attribute Arrays [10.3.2] void VertexArrayAttribFormat(uint vaobj,
void VertexAttribFormat(uint attribindex, uint attribindex, int size, enum type,
void VertexArrayVertexBuffer(uint vaobj,
uint bindingindex, uint buffer, intptr offset,
Vertex Array Objects [10.3.1] int size, enum type, boolean normalized, boolean normalized, uint relativeoffset); sizei stride);
All states related to definition of data used by unit relativeoffset); type: See VertexAttribFormat
vertex processor is in a vertex array object. type: [UNSIGNED_]BYTE, [UNSIGNED_]SHORT, void BindVertexBuffers(uint first,
[UNSIGNED_]INT, [HALF_]FLOAT, DOUBLE, FIXED, void VertexArrayAttribIFormat(uint vaobj, sizei count, const uint *buffers,
void GenVertexArrays(sizei n, uint *arrays); uint attribindex, int size, enum type, const intptr *offsets, const sizei *strides);
[UNSIGNED_]INT_2_10_10_10_REV,
void DeleteVertexArrays(sizei n, UNSIGNED_INT_10F_11F_11F_REV uint relativeoffset); void VertexArrayVertexBuffers(uint vaobj,
const uint *arrays); type: See VertexAttribIFormat
uint first, sizei count, const uint *buffers,
void VertexAttribIFormat(uint attribindex,
void BindVertexArray(uint array); int size, enum type, unit relativeoffset); void VertexArrayAttribLFormat(uint vaobj, const intptr *offsets, const sizei *strides);
void CreateVertexArrays(sizei n, uint *arrays); type: [UNSIGNED_]BYTE, [UNSIGNED_]SHORT, uint attribindex, int size, enum type, void VertexAttribBinding(uint attribindex,
[UNSIGNED_]INT uint relativeoffset); uint bindingindex);
boolean IsVertexArray(uint array); type: See VertexAttribLFormat
void VertexAttribLFormat(uint attribindex,
void VertexArrayElementBuffer(uint vaobj, int size, enum type, unit relativeoffset); void BindVertexBuffer(uint bindingindex,
uint buffer); type: DOUBLE uint buffer, intptr offset, sizei stride); (Continued on next page)

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


OpenGL 4.6 API Reference Guide Page 5
Vertex Arrays (cont.) Drawing Commands [10.4] void MultiDrawElements(enum mode,
const sizei *count, enum type,
Vertex Array Queries [10.5]
For all the functions in this section: void GetVertexArrayiv(uint vaobj,
void VertexArrayAttribBinding(uint vaobj, mode: POINTS, PATCHES, LINE_STRIP, const void * const *indices, enum pname, int *param);
uint attribindex, uint bindingindex); LINE_LOOP, TRIANGLE_STRIP, TRIANGLE_FAN, sizei drawcount); pname: ELEMENT_ARRAY_BUFFER_BINDING
void VertexAttribPointer(uint index, int size, LINES, LINES_ADJACENCY, TRIANGLES, void DrawRangeElements(enum mode,
TRIANGLES_ADJACENCY, LINE_STRIP_ADJACENCY, void GetVertexArrayIndexdiv(uint vaobj,
enum type, boolean normalized, uint start, uint end, sizei count, uint index, enum pname, int *param);
sizei stride, const void *pointer); TRIANGLE_STRIP_ADJACENCY enum type, const void *indices);
type: UNSIGNED_{BYTE, SHORT, INT} pname: VERTEX_ATTRIB_RELATIVE_OFFSET or
type: See VertexAttribFormat VERTEX_ATTRIB_ARRAY_X where X is one of
void DrawElementsBaseVertex(enum mode, ENABLED, SIZE, STRIDE, TYPE, NORMALIZED,
void VertexAttribIPointer(uint index, void DrawArrays(enum mode, int first, sizei count, enum type, const void *indices,
int size, enum type, sizei stride, sizei count); INTEGER, LONG, DIVISOR
int basevertex);
const void *pointer); void DrawArraysInstancedBaseInstance( void GetVertexArrayIndexd64iv(uint vaobj,
type: See VertexAttribIFormat void DrawRangeElementsBaseVertex( uint index, enum pname, int64 *param);
enum mode, int first, sizei count, enum mode, uint start, uint end,
index: [0, MAX_VERTEX_ATTRIBS - 1] sizei instancecount, uint baseinstance); sizei count, enum type, const void *indices, pname: VERTEX_BINDING_OFFSET
void VertexAttribLPointer(uint index, int size, void DrawArraysInstanced(enum mode, int basevertex); void GetVertexAttrib{d f i}v(uint index,
enum type, sizei stride, const void*pointer); int first, sizei count, sizei instancecount); enum pname, T *params);
void DrawElementsInstancedBaseVertex(
type: DOUBLE enum mode, sizei count, enum type, pname: See GetVertexArrayIndexediv plus
void DrawArraysIndirect(enum mode, VERTEX_ATTRIB_ARRAY_BUFFER_BINDING,
void EnableVertexAttribArray(uint index); const void *indirect); const void *indices, sizei instancecount, VERTEX_ATTRIB_BINDING,
int basevertex); CURRENT_VERTEX_ATTRIB
void EnableVertexArrayAttrib(uint vaobj, void MultiDrawArrays(enum mode,
uint index); const int *first, const sizei *count, void DrawElementsInstancedBase- void GetVertexAttribI{i ui}v(uint index,
void DisableVertexAttribArray(uint index); sizei drawcount); VertexBaseInstance(enum mode, enum pname, T *params);
sizei count, enum type,
void DisableVertexArrayAttrib(uint vaobj, void MultiDrawArraysIndirect(enum mode, const void *indices, sizei instancecount, pname: See GetVertexAttrib{d f i}v
uint index); const void *indirect, sizei drawcount, int basevertex, uint baseinstance); void GetVertexAttribLdv(uint index,
sizei stride); enum pname, double *params);
Vertex Attribute Divisors [10.3.4] void DrawElementsIndirect(enum mode,
void MultiDrawArraysIndirectCount( enum type, const void *indirect); pname: See GetVertexAttrib{d f i}v
void VertexBindingDivisor(uint bindingindex, enum mode, const void *indirect,
uint divisor); intptr drawcount, intptr maxdrawcount, void MultiDrawElementsIndirect( void GetVertexAttribPointerv(uint index,
void VertexArrayBindingDivisor(uint vaobj, sizei stride); enum mode, enum type, enum pname, const void **pointer);
uint bindingindex, uint divisor); const void *indirect, sizei drawcount, pname: VERTEX_ATTRIB_ARRAY_POINTER
void DrawElements(enum mode, sizei count, sizei stride);
void VertexAttribDivisor(uint index, enum type, const void *indices); Conditional Rendering [10.9]
uint divisor); void MultiDrawElementsIndirectCount(
void DrawElementsInstancedBaseInstance( enum mode, enum type, const void *indirect, void BeginConditionalRender(uint id,
Primitive Restart [10.3.6] enum mode, sizei count, enum type, intptr drawcount, sizei maxdrawcount, enum mode);
const void *indices, sizei instancecount, sizei stride); mode: QUERY _[NO_]WAIT[_INVERTED],
Enable/Disable/IsEnabled(target); QUERY_BY_REGION_[NO_]WAIT[_INVERTED]
target: PRIMITIVE_RESTART[_FIXED_INDEX] uint baseinstance);
void MultiDrawElementsBaseVertex(
void PrimitiveRestartIndex(uint index); void DrawElementsInstanced(enum mode, enum mode, const sizei *count, void EndConditionalRender(void);
sizei count, enum type, const void *indices, enum type, const void *const *indices,
sizei instancecount); sizei drawcount, const int *basevertex);

Vertex Attributes [11.1.1] int GetAttribLocation(uint program,


const char *name);
void GetTransformFeedbackVarying(
uint program, uint index, sizei bufSize,
Shader Execution [11.1.3]
Vertex shaders operate on array of void ValidateProgram(uint program);
4-component items numbered from slot 0 to sizei *length, sizei *size, enum *type,
Transform Feedback Variables [11.1.2] char *name); void ValidateProgramPipeline(uint pipeline);
MAX_VERTEX_ATTRIBS - 1. void TransformFeedbackVaryings( *type returns NONE, FLOAT , FLOAT_VECn, Tessellation Prim. Generation [11.2.2]
void BindAttribLocation(uint program, uint program, sizei count, DOUBLE , DOUBLE_VECn, INT, UNSIGNED_INT,
uint index, const char *name); const char * const *varyings, INT_VECn, UNSIGNED_INT_VECn, void PatchParameterfv(enum pname,
enum bufferMode); MATnxm, FLOAT_MATnxm, DOUBLE_MATnxm, const float *values);
void GetActiveAttrib(uint program, bufferMode: FLOAT_MATn, DOUBLE_MATn pname: PATCH_DEFAULT_INNER_LEVEL,
uint index, sizei bufSize, sizei *length, INTERLEAVED_ATTRIBS, SEPARATE_ATTRIBS PATCH_DEFAULT_OUTER_LEVEL
int *size, enum *type, char *name);

Vertex Post-Processing [13] void EndTransformFeedback(void); void DrawTransformFeedbackStream(


enum mode, uint id, uint stream);
Controlling Viewport [13.6.1]
Transform Feedback [13.2] void PauseTransformFeedback(void); void DepthRangeArrayv(uint first,
void sizei count, const double *v);
void GenTransformFeedbacks(sizei n, void ResumeTransformFeedback(void);
uint *ids); DrawTransformFeedbackStreamInstanced( void DepthRangeIndexed(uint index,
void TransformFeedbackBufferRange( enum mode, uint id, uint stream, double n, double f);
void DeleteTransformFeedbacks(sizei n, uint xfb, uint index, uint buffer, intptr offset, sizei instancecount);
const uint *ids); sizeiptr size); void DepthRange(double n, double f);
Flatshading [13.4]
boolean IsTransformFeedback(uint id); void TransformFeedbackBufferBase( void ProvokingVertex(enum provokeMode); void DepthRangef(float n, float f);
void BindTransformFeedback( uint xfb, uint index, uint buffer); provokeMode: {FIRST, LAST}_VERTEX_CONVENTION void ViewportArrayv(uint first, sizei count,
enum target, uint id); Transform Feedback Drawing [13.2.3] const float *v);
Primitive Clipping [13.5]
target: TRANSFORM_FEEDBACK void ViewportIndexedf(uint index, float x,
void DrawTransformFeedback( Enable/Disable/IsEnabled(target);
void CreateTransformFeedbacks( enum mode, uint id); target: DEPTH_CLAMP, CLIP_DISTANCEi where float y, float w, float h);
sizei n, uint *ids); mode: See Drawing Commands [10.4] above i = [0..MAX_CLIP_DISTANCES - 1] void ViewportIndexedfv(uint index,
void BeginTransformFeedback( void DrawTransformFeedbackInstanced( void ClipControl(enum origin, enum depth); const float *v);
enum primitiveMode); enum mode, uint id, sizei instancecount); origin: LOWER_LEFT or UPPER_LEFT void Viewport(int x, int y, sizei w, sizei h);
primitiveMode: TRIANGLES, LINES, POINTS depth: NEGATIVE_ONE_TO_ONE or ZERO_TO_ONE

Rasterization [13.4, 14] void PointParameter{i f}v(enum pname,


const T *params);
void FrontFace(enum dir);
dir: CCW, CW
Fragment Shaders [15.2]
Enable/Disable/IsEnabled(target); pname: POINT_FADE_THRESHOLD_SIZE, void BindFragDataLocationIndexed(
target: RASTERIZER_DISCARD POINT_SPRITE_COORD_ORIGIN void CullFace(enum mode); uint program, uint colorNumber,
params: The fade threshold if pname is mode: FRONT, BACK, FRONT_AND_BACK uint index, const char *name);
Multisampling [14.3.1] POINT_FADE_THRESHOLD_SIZE;
Use to antialias points, and lines. Polygon Rast. & Depth Offset [14.6.4-5] void BindFragDataLocation(uint program,
{LOWER, UPPER}_LEFT if pname is uint colorNumber, const char *name);
Enable/Disable/IsEnabled(target); POINT_SPRITE_COORD_ORIGIN void PolygonMode(enum face, enum mode);
target: MULTISAMPLE, SAMPLE_SHADING face: FRONT_AND_BACK int GetFragDataLocation(uint program,
Enable/Disable/IsEnabled(target); const char *name);
void GetMultisamplefv(enum pname, mode: POINT, LINE, FILL
target: PROGRAM_POINT_SIZE
uint index, float *val); void PolygonOffsetClamp(float factor, int GetFragDataIndex(uint program,
pname: SAMPLE_POSITION Line Segments [14.5] float units, float clamp); const char *name);
Enable/Disable/IsEnabled(target);
void MinSampleShading(float value); target: LINE_SMOOTH void PolygonOffset(float factor, float units);
Points [14.4] void LineWidth(float width); Enable/Disable/IsEnabled(target); Compute Shaders [19]
void PointSize(float size); target: POLYGON_OFFSET_{POINT, LINE, FILL}
void DispatchCompute(uint num_groups_x,
Polygons [14.6, 14.6.1] uint num_groups_y, uint num_groups_z);
void PointParameter{i f}(enum pname, Enable/Disable/IsEnabled(target);
T param); void DispatchComputeIndirect(
target: POLYGON_SMOOTH, CULL_FACE
pname, param: See PointParameter{if}v intptr indirect);

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


Page 6 OpenGL 4.6 API Reference Guide
Per-Fragment Operations void StencilFunc(enum func, int ref,
uint mask);
Blending [17.3.8] void BlendFunci(uint buf, enum src, enum dst);
src, dst: See BlendFuncSeparate
Scissor Test [17.3.2] Enable/Disable/IsEnabled(BLEND);
func: NEVER, ALWAYS, LESS, GREATER, EQUAL,
Enable/Disable/IsEnabled(SCISSOR_TEST); LEQUAL, GEQUAL, NOTEQUAL Enablei/Disablei/IsEnabledi(BLEND, void BlendFuncSeparatei(uint buf,
uint index); enum srcRGB, enum dstRGB,
Enablei/Disablei/IsEnabledi(SCISSOR_TEST, void StencilFuncSeparate(enum face, enum srcAlpha, enum dstAlpha);
uint index); enum func, int ref, uint mask); void BlendEquation(enum mode); dstRGB, dstAlpha, srcRGB, srcAlpha:
void ScissorArrayv(uint first, sizei count, func: See StencilFunc void BlendEquationSeparate(enum modeRGB, See BlendFuncSeparate
const int *v); void StencilOp(enum sfail, enum dpfail, enum modeAlpha); void BlendColor(float red, float green, float blue,
enum dppass); modeRGB, modeAlpha: MIN, MAX , float alpha);
void ScissorIndexed(uint index, int left, FUNC_{ADD, SUBTRACT, REVERSE_SUBTRACT}
int bottom, sizei width, sizei height); void StencilOpSeparate(enum face,
void BlendEquationi(uint buf, enum mode); Dithering [17.3.10]
void ScissorIndexedv(uint index, int *v); enum sfail, enum dpfail, enum dppass); Enable/Disable/IsEnabled(DITHER);
face: FRONT, BACK, FRONT_AND_BACK void BlendEquationSeparatei(uint buf,
void Scissor(int left, int bottom, sizei width, sfail, dpfail, dppass: KEEP, ZERO, REPLACE, INCR, enum modeRGB, enum modeAlpha); Logical Operation [17.3.11]
sizei height); DECR, INVERT, INCR_WRAP, DECR_WRAP modeRGB, modeAlpha: Enable/Disable/IsEnabled(COLOR_LOGIC_OP);
Multisample Fragment Ops. [17.3.3] Depth Buffer Test [17.3.6]
See BlendEquationSeparate
void LogicOp(enum op);
Enable/Disable/IsEnabled(target); Enable/Disable/IsEnabled(DEPTH_TEST); void BlendFunc(enum src, enum dst); op: CLEAR, AND, AND_REVERSE, COPY, AND_INVERTED,
target: SAMPLE_ALPHA_TO_{COVERAGE, ONE}, src, dst: See BlendFuncSeparate NOOP, XOR, OR, NOR, EQUIV, INVERT, OR_REVERSE,
SAMPLE_COVERAGE, SAMPLE_MASK void DepthFunc(enum func); COPY_INVERTED, OR_INVERTED, NAND, SET
func: See StencilFunc void BlendFuncSeparate(enum srcRGB,
void SampleCoverage(float value, enum dstRGB, enum srcAlpha,
boolean invert); Occlusion Queries [17.3.7] enum dstAlpha); Hints [21.5]
void SampleMaski(uint maskNumber, BeginQuery(enum target, uint id); srcRGB, dstRGB, srcAlpha, dstAlpha:
bitfield mask); ZERO, ONE, SRC_ALPHA_SATURATE, void Hint(enum target, enum hint);
EndQuery(enum target); {SRC, SRC1, DST, CONSTANT}_{COLOR, ALPHA}, target: FRAGMENT_SHADER_DERIVATIVE_HINT,
Stencil Test [17.3.5] target: SAMPLES_PASSED, ANY_SAMPLES_PASSED, ONE_MINUS_{SRC, SRC1}_{COLOR, ALPHA}, TEXTURE_COMPRESSION_HINT,
Enable/Disable/IsEnabled(STENCIL_TEST); ANY_SAMPLES_PASSED_CONSERVATIVE ONE_MINUS_{DST, CONSTANT}_{COLOR, ALPHA} {LINE, POLYGON}_SMOOTH_HINT
hint: FASTEST, NICEST, DONT_CARE

Whole Framebuffer Fine Control of Buffer Updates [17.4.2] void ClearBuffer{i f ui}v(enum buffer,
int drawbuffer, const T *value); attachments: COLOR_ATTACHMENTi, DEPTH, COLOR,
void ColorMask(boolean r, boolean g,
Selecting Buffers for Writing [17.4.1] boolean b, boolean a); buffer: COLOR, DEPTH, STENCIL {DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT,
void DrawBuffer(enum buf); {FRONT, BACK}_{LEFT, RIGHT}, STENCIL
buf: [Tables 17.4-5] NONE, void ColorMaski(uint buf, boolean r, void ClearNamedFramebuffer{i f ui}v(
{FRONT, BACK}_{LEFT, RIGHT}, FRONT, BACK, LEFT, boolean g, boolean b, boolean a); uint framebuffer, enum buffer, void InvalidateNamedFramebufferSubData(
RIGHT, FRONT_AND_BACK,
int drawbuffer, const T *value); uint framebuffer, sizei numAttachments,
void DepthMask(boolean mask); buffer: See ClearBuffer{i f ui}v const enum *attachments, int x, int y,
COLOR_ATTACHMENTi (i = [0,
MAX_COLOR_ATTACHMENTS - 1 ]) void StencilMask(uint mask); sizei width, sizei height);
void ClearBufferfi(enum buffer, attachments: See InvalidateSubFramebuffer
void NamedFramebufferDrawBuffer( void StencilMaskSeparate(enum face, int drawbuffer, float depth, int stencil);
uint framebuffer, enum buf); uint mask); buffer: DEPTH_STENCIL void InvalidateFramebuffer(
buf: See DrawBuffer
face: FRONT, BACK, FRONT_AND_BACK enumtarget, sizei numAttachments,
void ClearNamedFramebufferfi( const enum *attachments);
void DrawBuffers(sizei n, const enum *bufs); Clearing the Buffers [17.4.3] uint framebuffer, enum buffer, target, *attachments: See InvalidateSubFramebuffer
int drawbuffer, float depth, int stencil);
*bufs: [Tables 17.5-6] {FRONT, BACK}_{LEFT, RIGHT}, void Clear(bitfield buf);
NONE, COLOR_ATTACHMENTi (i = [0, buf: 0 or the OR of buffer: See ClearBufferi void InvalidateNamedFramebufferData(
MAX_COLOR_ATTACHMENTS - 1 ]) {COLOR, DEPTH, STENCIL}_BUFFER_BIT uint framebuffer, sizei numAttachments,
Invalidating Framebuffers [17.4.4] const enum *attachments);
void NamedFramebufferDrawBuffers( void ClearColor(float r, float g, float b, float a); void InvalidateSubFramebuffer( *attachments: See InvalidateSubFramebuffer
uint framebuffer, sizei n, void ClearDepth(double d); enum target, sizei numAttachments,
const enum *bufs); const enum *attachments, int x, int y,
void ClearDepthf(float d); sizei width, sizei height); Debug Labels [20.7]
*bufs: See DrawBuffers
void ClearStencil(int s); target: [DRAW_ , READ_]FRAMEBUFFER void ObjectLabel(enum identifier, uint name,
sizei length, const char *label);
identifier: BUFFER, FRAMEBUFFER, RENDERBUFFER,
Reading and Copying Pixels Debug Output [20] severity: DEBUG_SEVERITY_{HIGH, MEDIUM},
DEBUG_SEVERITY_{LOW, NOTIFICATION} PROGRAM_PIPELINE, PROGRAM,
Reading Pixels [18.2] Enable/Disable/IsEnabled(DEBUG_OUTPUT); QUERY, SAMPLER, SHADER, TEXTURE,
void ReadBuffer(enum src); Controlling Debug Messages [20.4] TRANSFORM_FEEDBACK, VERTEX_ARRAY
Debug Message Callback [20.2]
src: NONE, {FRONT, BACK}_{LEFT, RIGHT}, void DebugMessageControl(enum source, void ObjectPtrLabel(void* ptr, sizei length,
FRONT, BACK, LEFT, RIGHT,
void DebugMessageCallback( enum type, enum severity, sizei count,
DEBUGPROC callback, const char *label);
FRONT_AND_BACK, COLOR_ATTACHMENTi const uint *ids, boolean enabled);
(i = [0, MAX_COLOR_ATTACHMENTS - 1 ])
const void *userParam); Synchronous Debug Output [20.8]
source, type, severity: See DebuckMessageCallback
callback: has the following prototype: (above), plus DONT_CARE Enable/Disable/IsEnabled(
void NamedFramebufferReadBuffer( void callback(enum source, enum type,
uint framebuffer, enum src); DEBUG_OUTPUT_SYNCHRONOUS);
uint id, enum severity, sizei length, Externally Generated Messages [20.5]
src: See ReadBuffer const char *message, void DebugMessageInsert(enum source, Debug Output Queries [20.9]
void ReadPixels(int x, int y, sizei width, const void*userParam); enum type, uint id, enum severity, uint GetDebugMessageLog(uint count,
sizei height, enum format, enum type, source: DEBUG_SOURCE_X where X may be API, int length, const char *buf); sizei bufSize, enum *sources, enum *types,
void *data); SHADER_COMPILER, WINDOW_SYSTEM, source: DEBUG_SOURCE_{APPLICATION, THIRD_PARTY} uint *ids, enum *severities, sizei *lengths,
format: STENCIL_INDEX, RED, GREEN, BLUE, THIRD_PARTY, APPLICATION, OTHER type, severity: See DebugMessageCallback char *messageLog);
RG, RGB, RGBA, BGR, DEPTH_{COMPONENT, type: DEBUG_TYPE_X where X may be ERROR, void GetObjectLabel(enum identifier,
STENCIL}, {RED, GREEN, BLUE, RG, RGB}_ MARKER, OTHER, DEPRECATED_BEHAVIOR, Debug Groups [20.6] uint name, sizei bufSize, sizei *length,
INTEGER, {RGBA, BGR, BGRA}_INTEGER, UNDEFINED_BEHAVIOR, PERFORMANCE, void PushDebugGroup(enum source, char *label);
BGRA [Table 8.3] PORTABILITY, {PUSH, POP}_GROUP uint id, sizei length, const char *message);
source: See DebugMessageInsert void GetObjectPtrLabel(void* ptr, sizei bufSize,
type: [HALF_]FLOAT, [UNSIGNED_]BYTE, sizei *length, char *label);
[UNSIGNED_]SHORT, [UNSIGNED_]INT, mask: Bitwise 0 of the bitwise OR of void PopDebugGroup(void);
FLOAT_32_UNSIGNED_INT_24_8_REV, {COLOR, DEPTH, STENCIL}_BUFFER_BIT
UNSIGNED_{BYTE, SHORT, INT}_* filter: LINEAR, NEAREST
values in [Table 8.2]
void BlitNamedFramebuffer( State and State Requests void GetIntegeri_v(enum target, uint index,
int *data);
void ReadnPixels(int x, int y, sizei width, uint readFramebuffer, A complete list of symbolic constants for states is
sizei height, enum format, enum type, uint drawFramebuffer, int srcX0, shown in the tables in [23]. void GetFloati_v(enum target, uint index,
sizei bufSize, void *data); int srcY0, int srcX1, int srcY1, int dstX0, float *data);
Simple Queries [22.1]
format, type: See ReadPixels int dstY0, int dstX1, int dstY1,
bitfield mask, enum filter); void GetBooleanv(enum pname, boolean *data); void GetInteger64i_v(enum target, uint index,
int64 *data);
Final Conversion [18.2.8] mask, filter: See BlitFramebuffer void GetIntegerv(enum pname, int *data);
void ClampColor(enum target, enum clamp); boolean IsEnabled(enum cap);
void CopyImageSubData(uint srcName, void GetInteger64v(enum pname, int64 *data);
target: CLAMP_READ_COLOR boolean IsEnabledi(enum target, uint index);
enum srcTarget, int srcLevel, int srcX, void GetFloatv(enum pname, float *data);
clamp: TRUE, FALSE, FIXED_ONLY int srcY, int srcZ, uint dstName, String Queries [22.2]
enum dstTarget, int dstLevel, int dstX, void GetDoublev(enum pname, double *data); void GetPointerv(enum pname, void **params);
Copying Pixels [18.3] int dstY, int dstZ, sizei srcWidth, void GetDoublei_v(enum target, uint index,
sizei srcHeight, sizei srcDepth); ubyte *GetString(enum name);
void BlitFramebuffer(int srcX0, int srcY0, double *data); name: RENDERER, VENDOR, VERSION,
int srcX1, int srcY1, int dstX0, int dstY0, srcTarget, dstTarget: See target for BindTexture in
section [8.1] on this card, plus void GetBooleani_v(enum target, uint index, SHADING_LANGUAGE_VERSION
int dstX1, int dstY1, bitfield mask,
enum filter); GL_RENDERTARGET boolean *data);
(Continued on next page)

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


OpenGL 4.6 API Reference Guide Page 7
States, State Requests (cont.) pname:
CLEAR_{BUFFER, TEXTURE},
NUM_SAMPLE_COUNTS,
READ_PIXELS[_FORMAT, _TYPE],
enum pname, uint index, int *param);
pname: TRANSFORM_FEEDBACK_BUFFER_BINDING
ubyte *GetStringi(enum name, uint index); COLOR_ENCODING, SAMPLES, SHADER_IMAGE_ATOMIC,
name: EXTENSIONS, SHADING_LANGUAGE_VERSION, COLOR_{COMPONENTS, RENDERABLE}, SHADER_IMAGE_{LOAD, STORE}, void GetTransformFeedbacki64_v(uint xfb,
SPIR_V_EXTENSIONS COMPUTE_TEXTURE, SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST, enum pname, uint index, int64 *param);
index: DEPTH_{COMPONENTS, RENDERABLE}, SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE, pname: TRANSFORM_FEEDBACK_BUFFER_START,
[0, NUM_EXTENSIONS - 1] (if name is EXTENSIONS); FILTER, FRAMEBUFFER_BLEND, SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST, TRANSFORM_FEEDBACK_BUFFER_SIZE
[0, NUM_SHADING_LANGUAGE_VERSIONS-1] FRAMEBUFFER_RENDERABLE[_LAYERED], SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE,
(if name is SHADING_LANGUAGE_VERSION) {FRAGMENT, GEOMETRY}_TEXTURE, SRGB_{READ, WRITE},
GET_TEXTURE_IMAGE_FORMAT, STENCIL_{COMPONENTS, RENDERABLE},
Internal Format Queries [22.3] GET_TEXTURE_IMAGE_TYPE, TESS_{CONTROL, EVALUATION}_TEXTURE,
void GetInternalformativ(enum target, IMAGE_COMPATIBILITY_CLASS, TEXTURE_COMPRESSED[_BLOCK_SIZE],
enum internalformat, enum pname, IMAGE_PIXEL_{FORMAT, TYPE}, TEXTURE_COMPRESSED_BLOCK_{HEIGHT, WIDTH}
sizei bufSize, int *params); IMAGE_FORMAT_COMPATIBILITY_TYPE, TEXTURE_GATHER[_SHADOW],
target, pname, internalformat: IMAGE_TEXEL_SIZE, TEXTURE_IMAGE_FORMAT,
See GetInternalformati64v INTERNALFORMAT_{PREFERRED, SUPPORTED}, TEXTURE_IMAGE_TYPE,
INTERNALFORMAT_{RED, GREEN, BLUE}_SIZE, TEXTURE_{SHADOW, VIEW},
void GetInternalformati64v(enum target, INTERNALFORMAT_{DEPTH, STENCIL}_SIZE, VERTEX_TEXTURE,
enum internalformat, enum pname, INTERNALFORMAT_{ALPHA, SHARED}_SIZE, VIEW_COMPATIBILITY_CLASS
sizei bufSize, int64 *params); INTERNALFORMAT_{RED, GREEN}_TYPE,
target: [Table 22.2] INTERNALFORMAT_{BLUE, ALPHA}_TYPE, TransformFeedback Queries [22.4]
TEXTURE_{1D, 2D, 3D, CUBE_MAP}[_ARRAY], INTERNALFORMAT_{DEPTH, STENCIL}_TYPE, void GetTransformFeedbackiv(uint xfb,
TEXTURE_2D_MULTISAMPLE[_ARRAY], [MANUAL_GENERATE_]MIPMAP, enum pname, int *param);
TEXTURE_{BUFFER, RECTANGLE}, RENDERBUFFER MAX_COMBINED_DIMENSIONS, pname: TRANSFORM_FEEDBACK_{PAUSED, ACTIVE}
internalformat: any value MAX_{WIDTH, HEIGHT, DEPTH, LAYERS},
void GetTransformFeedbacki_v(uint xfb,

OpenGL Compute Programming Model and Compute Memory Hierarchy

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 gl_WorkGroupSize = (4,2,0)
void groupMemoryBarrier(); // Only for compute shaders gl_WorkGroupID = (2,0,0)
gl_LocalInvocationID = (1,0,0)
Use the compute shader built-in variables to specifiy work groups and invocations:
gl_GlobalInvocationID = (9,3,0)
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)

OpenGL Texture Views and Texture Object State

Texture state set with TextureView()


enum internalformat // base internal format uint minlevel // first level of mipmap uint minlayer // first layer of array texture
enum target // texture target uint numlevels // number of mipmap levels uint numlayers // number of layers in array

Sampler Parameters (mutable) Texture Parameters (immutable) Texture View Parameters (immutable)
TEXTURE_BORDER_COLOR TEXTURE_WIDTH TEXTURE_HEIGHT <target>
TEXTURE_COMPARE_{FUNC,MODE} TEXTURE_DEPTH TEXTURE_FIXED_SAMPLE_LOCATIONS TEXTURE_INTERNAL_FORMAT TEXTURE_SHARED_SIZE
TEXTURE_LOD_BIAS TEXTURE_COMPRESSED TEXTURE_COMPRESSED_IMAGE_SIZE TEXTURE_VIEW_{MIN,NUM}_LEVEL TEXTURE_VIEW_{MIN,NUM}_LAYER
TEXTURE_{MAX,MIN}_LOD TEXTURE_IMMUTABLE_FORMAT TEXTURE_SAMPLES TEXTURE_IMMUTABLE_LEVELS IMAGE_FORMAT_COMPATIBILITY_TYPE
TEXTURE_{MAG,MIN}_FILTER Texture Parameters (mutable) TEXTURE_{RED,GREEN,BLUE,ALPHA,DEPTH}_TYPE
TEXTURE_MAX_ANISTOPY TEXTURE_SWIZZLE_{R,G,B,A} TEXTURE_MAX_LEVEL TEXTURE_{RED,GREEN,BLUE,ALPHA,DEPTH,STENCIL}_SIZE
TEXTURE_WRAP_{S,T,R} TEXTURE_BASE_LEVEL DEPTH_STENCIL_TEXTURE_MODE

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


Page 8 OpenGL 4.6 API Reference Guide
OpenGL Pipeline
A typical program that uses OpenGL
begins with calls to open a window into
the framebuffer into which the program
will draw. Calls are made to allocate a GL
context which is then associated with the
window, then OpenGL commands can be
issued.
The heavy black arrows in this illustration
show the OpenGL pipeline and indicate
data flow.

Blue blocks indicate various buffers


that feed or get fed by the OpenGL
pipeline.
Green blocks indicate fixed function
stages.
Yellow blocks indicate programmable
stages.
T Texture binding
B Buffer binding

Vertex & Tessellation Details


Each vertex is processed either by a vertex shader
or fixed-function vertex processing (compatibility
only) to generate a transformed vertex, then
assembled into primitives. Tessellation (if enabled)
operates on patch primitives, consisting of a fixed-
size collection of vertices, each with per-vertex
attributes and associated per-patch attributes.
Tessellation control shaders (if enabled) transform
an input patch and compute per-vertex and per-
patch attributes for a new output patch.
A fixed-function primitive generator
subdivides the patch according to
tessellation levels computed in the
tessellation control shaders or specified
as fixed values in the API (TCS disabled).
The tessellation evaluation shader
computes the position and attributes of
each vertex produced by the tessellator.
Orange blocks indicate features of the Core
specification.
Purple blocks indicate features of the
Compatibility specification.
Green blocks indicate features new or
significantly changed with OpenGL 4.x.

Geometry & Follow-on Details


Geometry shaders (if enabled) consume
individual primitives built in previous primitive
assembly stages. For each input primitive,
the geometry shader can output zero or more
vertices, with each vertex directed at a specific
vertex stream. The vertices emitted to each
stream are assembled into primitives according
to the geometry shader’s output primitive type.
Transform feedback (if active) writes selected
vertex attributes of the primitives of all vertex
streams into buffer objects attached to one or
more binding points.
Primitives on vertex stream zero are then
processed by fixed-function stages, where they
are clipped and prepared for rasterization.
Orange blocks indicate features of the Core
specification.
Purple blocks indicate features of the
Compatibility specification.
Green blocks indicate features new or
significantly changed with OpenGL 4.x.

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


OpenGL Shading Language 4.60.1 Reference Card Page 9
The OpenGL® Shading Language is used to create Preprocessor [3.3] Predefined Macros
shaders for each of the programmable processors Decimal integer constants. __FILE__ says
Preprocessor Operators __LINE__ __FILE__
which source string is being processed.
contained in the OpenGL processing pipeline. The #version 450 Required when using version 4.50. __VERSION__ Decimal integer, e.g.: 450
OpenGL Shading Language is actually several closely #version 450 profile profile is core, compatibility, or es (for
ES versions 1.00, 3.00, or 3.10). GL_core_profile Defined as 1
related languages. Currently, these processors are the GL_es_profile 1 if the ES profile is supported
#extension • behavior: require, enable, warn,
vertex, tessellation control, tessellation evaluation, extension_name : disable GL_compatibility_profile
Defined as 1 if the implementation
geometry, fragment, and compute shaders. behavior • extension_name: extension supports the compatibility profile.
#extension all : behavior supported by compiler, or “all” Defined and equals 100 when shaders are
GL_SPIRV
[n.n.n] and [Table n.n] refer to sections and tables in compiled for OpenGL SPIR-V.
the OpenGL Shading Language 4.60.1 specification at Preprocessor Directives
www.khronos.org/opengl # #define #elif #else #endif #error #extension
#if #ifdef #ifndef #line #pragma #undef #version

Operators and Expressions [5.1] 3.


++ -- prefix increment and decrement 11. | bit-wise inclusive or Vector & Scalar Components [5.5]
The following operators are numbered in order +-~! unary 12. && logical and In addition to array numeric subscript syntax,
of precedence. Relational and equality operators 4. */% multiplicative 13. ^^ logical exclusive or names of vector and scalar components are
evaluate to Boolean. Also See lessThan(), equal(). denoted by a single letter. Components can be
5. +- additive 14. || logical inclusive or
1. () parenthetical grouping 6. << >> bit-wise shift 15. ?: selects an entire operand swizzled and replicated. Scalars have only an x, r,
= += -= or s component.
7. < > <= >= relational
[] array subscript *= /= assignment {x, y, z, w} Points or normals
() function call, constructor, structure 8. == != equality 16.
2. %= <<= >>= arithmetic assignments {r, g, b, a} Colors
. field, selector, swizzle 9. & bit-wise and &= ^= |=
++ -- postfix increment and decrement 10. ^ bit-wise exclusive or 17. , sequence {s, t, p, q} Texture coordinates

Types [4.1] Floating-Point Opaque Types Signed Integer Opaque Types (cont’d) Unsigned Integer Opaque Types (cont’d)
sampler{1D,2D,3D} 1D, 2D, or 3D texture iimage2DRect
int. 2D rectangular image uimage2DMSArray uint 2D multi-sample array image
Transparent Types image{1D,2D,3D}
void no function return value isampler[1,2]DArray
integer 1D, 2D array texture usamplerCubeArray uint cube map array texture
samplerCube cube mapped texture iimage[1,2]DArray
integer 1D, 2D array image
bool Boolean imageCube uimageCubeArray uint cube map array image
isamplerBuffer
integer buffer texture
int, uint signed/unsigned integers sampler2DRect rectangular texture Implicit Conversions
image2DRect iimageBuffer
integer buffer image int -> uint uvec2 -> dvec2
float single-precision floating-point
scalar sampler{1D,2D}Array 1D or 2D array texture isampler2DMS
int. 2D multi-sample texture int, uint -> float uvec3 -> dvec3
double double-precision floating scalar image{1D,2D}Array iimage2DMSint. 2D multi-sample image int, uint, float -> double uvec4 -> dvec4
vec2, vec3, vec4 floating point vector samplerBuffer buffer texture ivec2 -> uvec2 vec2 -> dvec2
imageBuffer isampler2DMSArray
int. 2D multi-sample array tex.
dvec2, dvec3, dvec4 double precision floating-point ivec3 -> uvec3 vec3 -> dvec3
vectors sampler2DMS 2D multi-sample texture iimage2DMSArray
int. 2D multi-sample array image ivec4 -> uvec4 vec4 -> dvec4
bvec2, bvec3, bvec4 Boolean vectors image2DMS isamplerCubeArray
int. cube map array texture ivec2 -> vec2 mat2 -> dmat2
sampler2DMSArray 2D multi-sample array iimageCubeArray
int. cube map array image ivec3 -> vec3 mat3 -> dmat3
ivec2, ivec3, ivec4 signed and unsigned integer ivec4 -> vec4 mat4 -> dmat4
uvec2, uvec3, uvec4 vectors image2DMSArray texture
samplerCubeArray cube map array texture Unsigned Integer Opaque Types uvec2 -> vec2 mat2x3 -> dmat2x3
mat2, mat3, mat4 2x2, 3x3, 4x4 float matrix uvec3 -> vec3 mat2x4 -> dmat2x4
mat2x2, mat2x3, 2-column float matrix of imageCubeArray
atomic_uint uint atomic counter uvec4 -> vec4 mat3x2 -> dmat3x2
mat2x4 2, 3, or 4 rows sampler1DShadow 1D or 2D depth texture ivec2 -> dvec2 mat3x4 -> dmat3x4
sampler2DShadow with comparison usampler[1,2,3]D uint 1D, 2D, or 3D texture
mat3x2, mat3x3, 3-column float matrix of
mat3x4 2, 3, or 4 rows sampler2DRectShadow rectangular tex. / compare uimage[1,2,3]D uint 1D, 2D, or 3D image ivec3 -> dvec3 mat4x2 -> dmat4x2
mat4x2, mat4x3, 4-column float matrix of sampler1DArrayShadow 1D or 2D array depth usamplerCube uint cube mapped texture ivec4 -> dvec4 mat4x3 -> dmat4x4
mat4x4 2, 3, or 4 rows sampler2DArrayShadow texture with comparison uimageCube uint cube mapped image
dmat2, dmat3, 2x2, 3x3, 4x4 double-precision samplerCubeShadow cube map depth texture usampler2DRect
Aggregation of Basic Types
uint rectangular texture Arrays float[3] foo; float foo[3]; int a [3][2];
dmat4 float matrix with comparison
dmat2x2, dmat2x3, 2-col. double-precision float uimage2DRect uint rectangular image // Structures, blocks, and structure members
samplerCubeArrayShadow cube map array depth usampler[1,2]DArray 1D or 2D array texture // can be arrays. Arrays of arrays supported.
dmat2x4 matrix of 2, 3, 4 rows texture with comparison
dmat3x2, dmat3x3, 3-col. double-precision float uimage[1,2]DArray 1D or 2D array image Structures struct type-name {
dmat3x4 matrix of 2, 3, 4 rows Signed Integer Opaque Types usamplerBuffer uint buffer texture members
dmat4x2, dmat4x3, 4-column double-precision float } struct-name[];
isampler[1,2,3]D integer 1D, 2D, or 3D texture uimageBuffer uint buffer image // optional variable declaration
dmat4x4 matrix of 2, 3, 4 rows
iimage[1,2,3]D integer 1D, 2D, or 3D image usampler2DMS uint 2D multi-sample texture Blocks in/out/uniform block-name {
isamplerCube integer cube mapped texture // interface matching by block name
uimage2DMS uint 2D multi-sample image
iimageCube integer cube mapped image optionally-qualified members
Qualifiers isampler2DRect int. 2D rectangular texture
usampler2DMSArray uint 2D multi-sample array tex. } instance-name[];
Storage Qualifiers [4.3] Continue Continue // optional instance name, optionally an array
Declarations may have one storage qualifier.
(default) local read/write memory, Layout Qualifiers [4.4]
none Layout Qualifier Qualif. Indiv. Block
or input parameter
The following table summarizes the use of layout qualifiers applied to non- Only Var. Block Mem. Allowed Interfaces
const read-only variable opaque types and the kinds of declarations they may be applied to. origin_upper_left
FC
Op = Opaque types only, FC = gl_FragCoord only, FD = gl_FragDepth only. pixel_center_integer fragment in
in linkage into shader from previous stage
early_fragment_tests X
out linkage out of a shader to next stage Layout Qualifier Qualif. Indiv. Block
Only Var. Block Mem. Allowed Interfaces local_size_{x, y, z} = X compute in
shared, packed, std{140, 430} X X local_size_{x,y,z}_id = X compute in
linkage between a shader, OpenGL,
uniform {row, column}_major X X X xfb_{buffer, stride} = X X X X vertex, tessellation, and
and the application
binding = Op X uniform/buffer xfb_offset = X X X geometry out
buffer accessible by shaders and OpenGL API vertices = X tessellation control out
offset = X
compute shader only, shared among work align = X X [ points ], line_strip,
shared X
items in a local work group triangle_strip
uniform/buffer and geometry out
location = X max_vertices = X
subroutine variables
Auxiliary Storage Qualifiers stream = X X X X
location = X X X all in/out, except for
Use to qualify some input and output variables: depth_{any, greater, less,
component = X X compute FD fragment out
unchanged}
centroid centroid-based interpolation fragment out and scalar
index = X constant_id const
sampler per-sample interpolation subroutine functions only

patch per-tessellation-patch attributes triangles, quads, isolines X Opaque Uniform Layout Qualifiers [4.4.6]
equal_spacing, Used to bind opaque uniform variables to specific buffers or units.
fractional_even_spacing, X tessellation evaluation
Interface Blocks [4.3.9] binding = integer-constant-expression
fractional_odd_spacing in
in, out, uniform, and buffer variable cw, ccw X Atomic Counter Layout Qualifiers
declarations can be grouped. For example: point_mode X binding = integer-constant-expression
uniform Transform { points X geometry in/out offset = integer-constant-expression
// allowed restatement qualifier: [ points ], lines, triangles,
mat4 ModelViewMatrix; X geometry in
{triangles, lines}_adjacency
uniform mat3 NormalMatrix; invocations = X geometry in
}; (Continued on next page)

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


Page 10 OpenGL Shading Language 4.60.1 Reference Guide
Qualifiers (continued) Invariant Qualifiers Examples [4.8] Operations and Constructors Examples of operations on matrices and vectors:
m = f * m; // scalar * matrix component-wise
These are for vertex, tessellation, geometry,
Format Layout Qualifiers and fragment languages. Vector & Matrix [5.4.2] v = f * v; // scalar * vector component-wise
One qualifier may be used with variables #pragma STDGL force all output variables .length() for matrices returns number of columns v = v * v; // vector * vector component-wise
declared as “image” to specify the image invariant(all) to be invariant .length() for vectors returns number of components m = m +/- m; // matrix +/- matrix comp.-wise
format. m = m * m; // linear algebraic multiply
qualify a previously mat2(vec2, vec2); // 1 col./arg.
invariant gl_Position; f = dot(v, v); // vector dot product
binding = integer-constant-expression, declared variable mat2x3(vec2, float, vec2, float); // col. 2 v = cross(v, v); // vector cross product
rgba{32,16}f, rg{32,16}f, r{32,16}f, invariant centroid out qualify as part of a dmat2(dvec2, dvec2); // 1 col./arg.
rgba{16,8}, r11f_g11f_b10f, rgb10_a2{ui}, vec3 Color; variable declaration dmat3(dvec3, dvec3, dvec3); // 1 col./arg. Array Example [5.4.4]
rg{16,8}, r{16,8}, rgba{32,16,8}i, rg{32,16,8}i, const float c[3];
r{32,16,8}i, rgba{32,16,8}ui, rg{32,16,8}ui, Precise Qualifier [4.9] Structure Example [5.4.3] c.length() // will return the integer 3
Ensures that operations are executed in stated .length() for structures returns number of members
r{32,16,8}ui, rgba{16,8}_snorm, order with operator consistency. For example: Structure & Array Operations [5.7]
rg{16,8}_snorm, r{16,8}_snorm struct light {members; };
precise out vec4 Position = a * b + c * d; light lightVar = light(3.0, vec3(1.0, 2.0, 3.0)); Select structure fields or length() method of an
Interpolation Qualifiers [4.5] array using the period (.) operator. Other operators:
Qualify outputs from vertex shader and inputs Memory Qualifiers [4.10] Matrix Examples [5.6] . field or method selector
to fragment shader. Variables qualified as “image” can have one or Examples of access components of a matrix with
more memory qualifiers. == != equality
array subscripting syntax:
smooth perspective correct interpolation coherent reads and writes are coherent with mat4 m; // m is a matrix = assignment
flat no interpolation other shader invocations m[1] = vec4(2.0); // sets 2nd col. to all 2.0 [] indexing (arrays only)
volatile underlying values may be changed by
noperspective linear interpolation other sources m[0][0] = 1.0; // sets upper left element to 1.0 Array elements are accessed using the array
restrict won’t be accessed by other code m[2][3] = 2.0; // sets 4th element of 3rd col. to 2.0 subscript operator ( [ ] ), e.g.:
Parameter Qualifiers [4.6] diffuseColor += lightIntensity[3]*NdotL;
Input values copied in at function call time, readonly read only
output values copied out at function return. writeonly write only
none (default) same as in Specialization-Constant Qualifier [4.11] Statements and Structure Declare subroutine type variables with a specific
subroutine type in a subroutine uniform variable
in for parameters passed into function SPIR-V specialization constants are expressed Subroutines [6.1.2] declaration:
const for parameters that cannot be written to in GLSL as const with the layout qualifier Subroutine type variables are assigned to functions
out for parameters passed back out of of constant_id. Function calls to user-defined through the UniformSubroutinesuiv command in the subroutine uniform subroutineTypeName
function, but not initialized when passed in functions cannot be used to form constant OpenGL API. subroutineVarName;
expressions. [also see 4.3.3]
inout for parameters passed both into and out Declare types with the subroutine keyword: Iteration and Jumps [6.3-4]
of a function Function call by value-return
subroutine returnType subroutineTypeName(type0
Order of Qualification [4.12] arg0, Iteration for (;;) { break, continue }
Precision Qualifiers [4.7] Multiple qualifiers may appear in a declaration type1 arg1, ..., typen argn); while ( ) { break, continue }
Qualify individual variables: in any order, but must all appear before the do { break, continue } while ( );
{highp, mediump, lowp} variable-declaration; type. Only the layout qualifier may appear Associate functions with subroutine types of Selection if ( ) { }
Establish a default precision qualifier: more than once. A declaration may have matching declarations by defining the functions if ( ) { } else { }
at most one storage qualifier, at most one with the subroutine keyword and a list of switch ( ) { case integer: … break; …
precision {highp, mediump, lowp} auxiliary storage qualifier, and at most one default: … }
{int, float}; subroutine types the function matches:
interpolation qualifier. Entry void main()
Multiple memory qualifiers may be used. Any subroutine(subroutineTypeName0, ...,
subroutineTypeNameN)
Jump break, continue, return
rule violation will cause a compile-time error.
Built-In Variables [7] returnType functionName(type0 arg0,
(There is no ‘goto’)
Vertex Language type1 arg1, ..., typen argn){ ... } Exit return in main()
// function body discard // Fragment shader only
in int gl_VertexID; Geometry Language
in int gl_InstanceID; in gl_PerVertex {
Inputs

in int gl_BaseInstance vec4 gl_Position;


in int gl_BaseVertex float gl_PointSize; Built-In Constants [7.3] const int gl_MaxTessControlOutputComponents = 128;
in int gl_DrawID float gl_ClipDistance[]; The following are provided to all shaders. The const int gl_MaxTessControlTextureImageUnits = 16;
Inputs

out gl_PerVertex { float gl_CullDistance[]; actual values are implementation-dependent, but const int gl_MaxTessControlUniformComponents = 1024;
vec4 gl_Position; } gl_in[]; must be at least the value shown. const int gl_MaxTessControlTotalOutputComponents = 4096;
Outputs

float gl_PointSize; in int gl_PrimitiveIDIn; const ivec3 gl_MaxComputeWorkGroupCount = const int gl_MaxTessEvaluationInputComponents = 128;
float gl_ClipDistance[]; in int gl_InvocationID; {65535, 65535, 65535} ; const int gl_MaxTessEvaluationOutputComponents = 128;
float gl_CullDistance[]; out gl_PerVertex { const ivec3 gl_MaxComputeWorkGroupSize[] =
}; vec4 gl_Position;
const int gl_MaxTessEvaluationTextureImageUnits = 16;
{1024, 1024, 64}; const int gl_MaxTessEvaluationUniformComponents = 1024;
float gl_PointSize;
Tessellation Control Language float gl_ClipDistance[]; const int gl_MaxComputeUniformComponents = 1024; const int gl_MaxTessPatchComponents = 120;
const int gl_MaxComputeTextureImageUnits = 16;
Outputs

in gl_PerVertex { float gl_CullDistance[]; const int gl_MaxPatchVertices = 32;


vec4 gl_Position; }; const int gl_MaxComputeImageUniforms = 8; const int gl_MaxTessGenLevel = 64;
float gl_PointSize; out int gl_PrimitiveID; const int gl_MaxComputeAtomicCounters = 8; const int gl_MaxViewports = 16;
float gl_ClipDistance[]; out int gl_Layer; const int gl_MaxComputeAtomicCounterBuffers = 1;
float gl_CullDistance[]; const int gl_MaxVertexUniformVectors = 256;
Inputs

out int gl_ViewportIndex; const int gl_MaxVertexAttribs = 16;


} gl_in[gl_MaxPatchVertices]; const int gl_MaxFragmentUniformVectors = 256;
const int gl_MaxVertexUniformComponents = 1024; const int gl_MaxVaryingVectors = 15;
in int gl_PatchVerticesIn; Fragment Language const int gl_MaxVaryingComponents= 60; const int gl_MaxVertexAtomicCounters = 0;
in int gl_PrimitiveID; in vec4 gl_FragCoord; const int gl_MaxVertexOutputComponents = 64; const int gl_MaxTessControlAtomicCounters = 0;
in int gl_InvocationID; in bool gl_FrontFacing; const int gl_MaxGeometryInputComponents = 64;
out gl_PerVertex { in float gl_ClipDistance[]; const int gl_MaxTessEvaluationAtomicCounters = 0;
const int gl_MaxGeometryOutputComponents = 128; const int gl_MaxGeometryAtomicCounters = 0;
vec4 gl_Position; in float gl_CullDistance[];
float gl_PointSize; in vec2 gl_PointCoord; const int gl_MaxFragmentInputComponents = 128; const int gl_MaxFragmentAtomicCounters = 8;
const int gl_MaxVertexTextureImageUnits = 16;
Outputs

float gl_ClipDistance[]; in int gl_PrimitiveID; const int gl_MaxCombinedAtomicCounters = 8;


Inputs

float gl_CullDistance[]; in int gl_SampleID; const int gl_MaxCombinedTextureImageUnits = 80; const int gl_MaxAtomicCounterBindings = 1;
} gl_out[]; in vec2 gl_SamplePosition; const int gl_MaxTextureImageUnits = 16; const int gl_MaxVertexAtomicCounterBuffers = 0;
patch out float gl_TessLevelOuter[4]; in int gl_SampleMaskIn[]; const int gl_MaxImageUnits = 8;
in int gl_Layer; const int gl_MaxTessControlAtomicCounterBuffers = 0;
patch out float gl_TessLevelInner[2]; gl_MaxCombinedImageUnitsAndFragmentOutputs = 8;
in int gl_ViewportIndex; const int gl_MaxTessEvaluationAtomicCounterBuffers = 0;
const int gl_MaxImageSamples = 0; const int gl_MaxGeometryAtomicCounterBuffers = 0;
Tessellation Evaluation Language in bool gl_HelperInvocation;
const int gl_MaxVertexImageUniforms= 0; const int gl_MaxFragmentAtomicCounterBuffers = 1;
in gl_PerVertex {
Outputs

out float gl_FragDepth;


vec4 gl_Position; out int gl_SampleMask[];
const int gl_MaxTessControlImageUniforms = 0; const int gl_MaxCombinedAtomicCounterBuffers = 1;
float gl_PointSize; const int gl_MaxTessEvaluationImageUniforms = 0; const int gl_MaxAtomicCounterBufferSize = 32;
float gl_ClipDistance[]; const int gl_MaxGeometryImageUniforms = 0; const int gl_MinProgramTexelOffset = -8;
float gl_CullDistance[]; Compute Language const int gl_MaxFragmentImageUniforms = 8; const int gl_MaxProgramTexelOffset = 7;
Inputs

} gl_in[gl_MaxPatchVertices]; More information in diagram on page 6. const int gl_MaxCombinedImageUniforms = 8;


Work group dimensions const int gl_MaxTransformFeedbackBuffers = 4;
in int gl_PatchVerticesIn;
in uvec3 gl_NumWorkGroups;
const int gl_MaxFragmentUniformComponents = 1024; gl_MaxTransformFeedbackInterleavedComponents = 64;
in int gl_PrimitiveID; const int gl_MaxDrawBuffers = 8;
in vec3 gl_TessCoord; const uvec3 gl_WorkGroupSize; const int gl_MaxCullDistances = 8;
in uvec3 gl_LocalGroupSize; const int gl_MaxClipDistances = 8; const int gl_MaxCombinedClipAndCullDistances = 8;
patch in float gl_TessLevelOuter[4];
patch in float gl_TessLevelInner[2]; Work group and invocation IDs const int gl_MaxGeometryTextureImageUnits = 16; const int gl_MaxSamples = 4;
Inputs

out gl_PerVertex { in uvec3 gl_WorkGroupID; const int gl_MaxGeometryOutputVertices = 256; const int gl_MaxVertexImageUniforms = 0;
vec4 gl_Position; in uvec3 gl_LocalInvocationID; const int gl_MaxGeometryTotalOutputComponents = 1024; const int gl_MaxFragmentImageUniforms = 8;
Outputs

float gl_PointSize; Derived variables const int gl_MaxGeometryUniformComponents = 1024; const int gl_MaxComputeImageUniforms = 8;
float gl_ClipDistance[]; in uvec3 gl_GlobalInvocationID; const int gl_MaxGeometryVaryingComponents = 64;
float gl_CullDistance[]; in uint gl_LocalInvocationIndex; const int gl_MaxCombinedImageUniforms = 48;
}; const int gl_MaxTessControlInputComponents = 128; const int gl_MaxCombinedShaderOutputResources = 16;

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


OpenGL Shading Language 4.60.1 Reference Guide Page 11
Built-In Functions Common Functions (cont.) Type Abbreviations for Built-in Functions: In vector types, n is 2, 3, or 4.
Angle & Trig. Functions [8.1] Returns maximum value:
Functions will not result in a divide-by-zero 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.
error. If the divisor of a ratio is 0, then results Tfd max(Tfd x, Tfd y) Tiu max(Tiu x, Tiu y)
will be undefined. Component-wise operation. Within any one function, type sizes and dimensionality must correspond after implicit type
Tf max(Tf x, float y) Ti max(Ti x, int y) conversions. For example, float round(float) is supported, but float round(vec4) is not.
Parameters specified as angle are in units of
radians. Tf=float, vecn. Td max(Td x, double y) Tu max(Tu x, uint y)
Returns min(max(x, minVal), maxVal): Geometric Functions [8.5] Integer Functions (cont.)
Tf radians(Tf degrees) degrees to radians
Tfd clamp(Tfd x, Tfd minVal, Tfd maxVal) These functions operate on vectors as vectors, not
Tf degrees(Tf radians) radians to degrees Returns the reversal of the bits of value:
Tf clamp(Tf x, float minVal, float maxVal) component-wise. Tf=float, vecn. Td =double, dvecn.
Tfd= float, vecn, double, dvecn. Tiu bitfieldReverse(Tiu value)
Tf sin(Tf angle) sine Td clamp(Td x, double minVal, double maxVal) Inserts the bits least-significant bits of insert into base:
Tiu clamp(Tiu x, Tiu minVal, Tiu maxVal) float length(Tf x)
Tf cos(Tf angle) cosine length of vector Tiu bitfieldInsert(Tiu base, Tiu insert, int offset, int bits)
double length(Td x)
Ti clamp(Ti x, int minVal, int maxVal) Returns the number of bits set to 1:
Tf tan(Tf angle) tangent float distance(Tf p0, Tf p1)
Tu clamp(Tu x, uint minVal, uint maxVal) distance between points Ti bitCount(Tiu value)
Tf asin(Tf x) arc sine double distance(Td p0, Td p1)
Returns linear blend of x and y: Returns the bit number of the least significant bit:
Tf acos(Tf x) arc cosine float dot(Tf x, Tf y) Ti findLSB(Tiu value)
Tfd mix(Tfd x, Tfd y, Tfd a) Ti mix(Ti x, Ti y, Ti a) dot product
double dot(Td x, Td y) Returns the bit number of the most significant bit:
Tf atan(Tf y, Tf x) Tf mix(Tf x, Tf y, float a) Tu mix(Tu x, Tu y, Tu a)
arc tangent vec3 cross(vec3 x, vec3 y) Ti findMSB(Tiu value)
Tf atan(Tf y_over_x) cross product
Td mix(Td x, Td y, double a) dvec3 cross(dvec3 x, dvec3 y)
Tf sinh(Tf x) hyperbolic sine
Components returned come from x when a components Tfd normalize(Tfd x) normalize vector to length 1 Texture Lookup Functions [8.9]
Tf cosh(Tf x) hyperbolic cosine are true, from y when a components are false: Available to vertex, geometry, and fragment
Tfd faceforward(Tfd N, returns N if dot(Nref, I) < shaders. See tables on next page.
Tf tanh(Tf x) hyperbolic tangent Tfd mix(Tfd x, Tfd y, Tb a) Tb mix(Tb x, Tb y, Tb a)
Tfd I, Tfd Nref) 0, else -N
Tiu mix(Tiu x, Tiu y, Tb a)
Tf asinh(Tf x) hyperbolic sine Tfd reflect(Tfd I, Tfd N)
reflection direction Atomic-Counter Functions [8.10]
Returns 0.0 if x < edge, else 1.0: I - 2 * dot(N,I) * N Returns the value of an atomic counter.
Tf acosh(Tf x) hyperbolic cosine
Tfd step(Tfd edge, Tfd x) Tfd refract(Tfd I, Tfd N, Atomically increments c then returns its prior value:
Td step(double edge, Td x) refraction vector
Tf atanh(Tf x) hyperbolic tangent Tf step(float edge, Tf x) float eta)
uint atomicCounterIncrement(atomic_uint c)
Clamps and smoothes: Atomically decrements c then returns its prior value:
Exponential Functions [8.2] Tfd smoothstep(Tfd edge0, Tfd edge1, Tfd x) Matrix Functions [8.6]
N and M are 1, 2, 3, 4. uint atomicCounterDecrement(atomic_uint c)
Component-wise operation. Tf=float, vecn.
Td= double, dvecn. Tfd= Tf, Td Tf smoothstep(float edge0, float edge1, Tf x)
mat matrixCompMult(mat x, mat y) component-wise Atomically returns the counter for c:
Td smoothstep(double edge0, double edge1, Td x) uint atomicCounter(atomic_uint c)
Tf pow(Tf x, Tf y) xy dmat matrixCompMult(dmat x, dmat y) multiply
Returns true if x is NaN: matN outerProduct(vecN c, vecN r) outer product Atomic operations performed on c, where Op may be Add,
Tf exp(Tf x) ex Tb isnan(Tfd x) dmatN outerProduct(dvecN c, dvecN r) (where N != M) Subtract, Min, Max, And, Or, Xor:
Returns true if x is positive or negative infinity: matNxM outerProduct(vecM c, vecN r) uint atomicCounterOp(atomic_uint c, uint data)
Tf log(Tf x) ln outer product
dmatNxM outerProduct(dvecM c, dvecN r)
Tb isinf(Tfd x) Atomically swap values of c and data; returns its prior value:
Tf exp2(Tf x) 2x matN transpose(matN m) uint atomicCounterCompSwap(atomic_uint c, uint data)
Returns signed int or uint value of the encoding of a float: transpose
dmatN transpose(dmatN m)
Tf log2(Tf x) log2 Ti floatBitsToInt(Tf value) Atomically compare values of c and compare; performs
matNxM transpose(matMxN m) transpose
Tu floatBitsToUint(Tf value) dmatNxM transpose(dmatMxN m) (where N != M) atomic swap if equal:
Tfd sqrt(Tfd x) square root
uint atomicCounterCompSwap(atomic_uint c,
Returns float value of a signed int or uint encoding of a float: float determinant(matN m)
Tfd inversesqrt(Tfd x) inverse square root determinant uint compare, uint data)
double determinant(dmatN m)
Tf intBitsToFloat(Ti value) Tf uintBitsToFloat(Tu value)
matN inverse(matN m) Atomic Memory Functions [8.11]
inverse
Common Functions [8.3] Computes and returns a*b + c. Treated as a single operation dmatN inverse(dmatN m) Operates on individual integers in buffer-object
Component-wise operation. Tf=float, vecn. Tb=bool, when using precise: or shared-variable storage. OP is Add, Min, Max,
bvecn. Ti=int, ivecn. Tu=uint, uvecn. And, Or, Xor, Exchange, or CompSwap.
Tfd fma(Tfd a, Tfd b, Tfd c) Vector Relational Functions [8.7]
Td= double, dvecn. Tfd= Tf, Td. Tiu= Ti, Tu. Compare x and y component-wise. Sizes of the
Splits x into a floating-point significand in the range [0.5, 1.0) uint atomicOP(coherent inout uint mem, uint data)
Returns absolute value: input and return vectors for any particular call
and an integer exponent of 2: must match. Tvec=vecn, uvecn, ivecn. int atomicOP(coherent inout int mem, int data)
Tfd abs(Tfd x) Ti abs(Ti x) Tfd frexp(Tfd x, out Ti exp)
bvecn lessThan(Tvec x, Tvec y) <
Returns -1.0, 0.0, or 1.0: Builds a floating-point number from x and the corresponding Image Functions [8.12]
bvecn lessThanEqual(Tvec x, Tvec y) <= In the image functions below, IMAGE_PARAMS
Tfd sign(Tfd x) Ti sign(Ti x) integral exponent of 2 in exp:
bvecn greaterThan(Tvec x, Tvec y) > may be one of the following:
Returns nearest integer <= x: Tfd ldexp(Tfd x, in Ti exp) gimage1D image, int P
bvecn greaterThanEqual(Tvec x, Tvec y) >=
Tfd floor(Tfd x) gimage2D image, ivec2 P
bvecn equal(Tvec x, Tvec y) gimage3D image, ivec3 P
Returns nearest integer with absolute value <= absolute Floating-Point Pack/Unpack [8.4] ==
bvecn equal(bvecn x, bvecn y) gimage2DRect image, ivec2 P
value of x: These do not operate component-wise.
bvecn notEqual(Tvec x, Tvec y) gimageCube image, ivec3 P
Tfd trunc(Tfd x) Converts each component of v into 8- or 16-bit ints, packs != gimageBuffer image, int P
bvecn notEqual(bvecn x, bvecn y)
Returns nearest integer, implementation-dependent results into the returned 32-bit unsigned integer: gimage1DArray image, ivec2 P
rounding mode: bool any(bvecn x) true if any component of x is true gimage2DArray image, ivec3 P
uint packUnorm2x16(vec2 v) uint packUnorm4x8(vec4 v) bool all(bvecn x) true if all comps. of x are true gimageCubeArray image, ivec3 P
Tfd round(Tfd x)
uint packSnorm2x16(vec2 v) uint packSnorm4x8(vec4 v) gimage2DMS image, ivec2 P, int sample
Returns nearest integer, 0.5 rounds to nearest even integer: bvecn not(bvecn x) logical complement of x
Unpacks 32-bit p into two 16-bit uints, four 8-bit uints, or gimage2DMSArray image, ivec3 P, int sample
Tfd roundEven(Tfd x)
signed ints. Then converts each component to a normalized Returns the dimensions of the images or images:
Returns nearest integer >= x: float to generate a 2- or 4-component vector: Integer Functions [8.8]
vec2 unpackUnorm2x16(uint p) Component-wise operation. Tu=uint, uvecn. int imageSize(gimage{1D,Buffer} image)
Tfd ceil(Tfd x) Ti=int, ivecn. Tiu=int, ivecn, uint, uvecn. ivec2 imageSize(gimage{2D,Cube,Rect,1DArray,
vec2 unpackSnorm2x16(uint p)
Returns x - floor(x): 2DMS} image)
vec4 unpackUnorm4x8(uint p) Adds 32-bit uint x and y, returning the sum modulo 232: ivec3 imageSize(gimage{Cube,2D,2DMS}Array image)
Tfd fract(Tfd x) vec4 unpackSnorm4x8(uint p) Tu uaddCarry(Tu x, Tu y, out Tu carry) vec3 imageSize(gimage3D image)
Returns modulus: Packs components of v into a 64-bit value and returns a Subtracts y from x, returning the difference if non-negative,
Tfd mod(Tfd x, Tfd y) Returns the number of samples of the image or images
Td mod(Td x, double y) double-precision value: otherwise 232 plus the difference: bound to image:
Tf mod(Tf x, float y) double packDouble2x32(uvec2 v) Tu usubBorrow(Tu x, Tu y, out Tu borrow) int imageSamples(gimage2DMS image)
Returns separate integer and fractional parts: Multiplies 32-bit integers x and y, producing a 64-bit result: int imageSamples(gimage2DMSArray image)
Returns a 2-component vector representation of v:
Tfd modf(Tfd x, out Tfd i) uvec2 unpackDouble2x32(double v) void umulExtended(Tu x, Tu y, out Tu msb, out Tu lsb) Loads texel at the coordinate P from the image unit image:
Returns minimum value: void imulExtended(Ti x, Ti y, out Ti msb, out Ti lsb) gvec4 imageLoad(readonly IMAGE_PARAMS)
Returns a uint by converting the components of a two-
Tfd min(Tfd x, Tfd y) Tiu min(Tiu x, Tiu y) component floating-point vector: Extracts bits [offset, offset + bits - 1] from value, returns
Stores data into the texel at the coordinate P from
Tf min(Tf x, float y) Ti min(Ti x, int y) uint packHalf2x16(vec2 v) them in the least significant bits of the result:
the image specified by image:
Tiu bitfieldExtract(Tiu value, int offset, int bits)
Td min(Td x, double y) Tu min(Tu x, uint y) Returns a two-component floating-point vector: void imageStore(writeonly IMAGE_PARAMS, gvec4 data)
vec2 unpackHalf2x16(uint v) (Continue ) (Continued on next page)
(Continue )

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


Page 12 OpenGL Shading Language 4.60.1 Reference Guide
Built-In Functions (cont.) Image Functions (cont.) Interpolation fragment-processing functions Other Shader Functions [8.16-17]
Image Functions (cont.) Return value of interpolant sampled inside pixel and the See diagram on page 11 for more information.
Copies the value of data: primitive:
Adds the value of data to the contents of the selected texel: uint imageAtomicExchange(coherent IMAGE_PARAMS, Synchronizes across shader invocations:
Tf interpolateAtCentroid(Tf interpolant)
uint imageAtomicAdd(coherent IMAGE_PARAMS, uint data) uint data) void barrier()
int imageAtomicExchange(coherent IMAGE_PARAMS, Return value of interpolant at location of sample # sample:
int imageAtomicAdd(coherent IMAGE_PARAMS, int data) Controls ordering of memory transactions issued by a
int data) Tf interpolateAtSample(Tf interpolant, int sample)
Takes the minimum of the value of data and the contents single shader invocation:
int imageAtomicExchange(coherent IMAGE_PARAMS, Return value of interpolant sampled at fixed offset offset
of the selected texel: void memoryBarrier()
float data) from pixel center:
uint imageAtomicMin(coherent IMAGE_PARAMS, uint data) Controls ordering of memory transactions as viewed by
Compares the value of compare and contents of selected Tf interpolateAtOffset(Tf interpolant, vec2 offset)
int imageAtomicMin(coherent IMAGE_PARAMS, int data) texel. If equal, the new value is given by data; otherwise, other invocations in a compute work group:
Takes the maximum of the value data and the contents it is taken from the original value loaded from texel: Noise Functions [8.14] void groupMemoryBarrier()
of the selected texel: uint imageAtomicCompSwap(coherent IMAGE_PARAMS, Returns noise value. Available to fragment, geometry, Order reads and writes accessible to other invocations:
uint imageAtomicMax(coherent IMAGE_PARAMS, uint data) uint compare, uint data) and vertex shaders. n is 2, 3, or 4:
void memoryBarrierAtomicCounter()
int imageAtomicMax(coherent IMAGE_PARAMS, int data) int imageAtomicCompSwap(coherent IMAGE_PARAMS, float noise1(Tf x) vecn noisen(Tf x)
int compare, int data) void memoryBarrierShared()
Performs a bit-wise AND of the value of data and the void memoryBarrierBuffer()
contents of the selected texel: Fragment Processing Functions [8.13] Geometry Shader Functions [8.15] void memoryBarrierImage()
uint imageAtomicAnd(coherent IMAGE_PARAMS, uint data) Available only in fragment shaders. Only available in geometry shaders.
Tf=float, vecn. Emits values of output variables to current output
int imageAtomicAnd(coherent IMAGE_PARAMS, int data) Shader Invocation Group Functions
primitive stream stream:
Performs a bit-wise OR of the value of data and the Derivative fragment-processing functions
void EmitStreamVertex(int stream) [8.18]
contents of the selected texel: Tf dFdx(Tf p) derivative in x and y, either Available for multiple shader invocations grouped
uint imageAtomicOr(coherent IMAGE_PARAMS, uint data) Tf dFdy(Tf p) fine or coarse derivatives Completes current output primitive stream stream and into a single SIMD invocation group.
starts a new one:
int imageAtomicOr(coherent IMAGE_PARAMS, int data) Tf dFdxFine(Tf p) Returns true if value is true for (any active invocation, all
fine derivative in x and y per void EndStreamPrimitive(int stream)
Tf dFdyFine(Tf p) pixel-row/column derivative active invocations) in the group:
Performs a bit-wise exclusive OR of the value of data and Completes output primitive and starts a new one: bool allInvocationsEqual(bool value)
the contents of the selected texel: Tf dFdxCoarse(Tf p) coarse derivative in x and y per bool allInvocation(bool value)
void EndPrimitive()
uint imageAtomicXor(coherent IMAGE_PARAMS, uint data) Tf dFdyCoarse(Tf p) 2x2-pixel derivative
int imageAtomicXor(coherent IMAGE_PARAMS, int data) Tf fwidth(Tf p) Emits values of output variables to the current output Returns true if value is the same for all active
sum of absolute values of x and y primitive: invocations in the group:
(Continue ) Tf fwidthFine(Tf p) derivatives bool allInvocationsEqual(bool value)
Tf fwidthCoarse(Tf p) void EmitVertex()

Texture Functions [8.9] Texel Lookup Functions [8.9.2] Projective texture lookup with offset added before
Use texture coordinate P to do a lookup in the texture texture lookup.
Texture lookup both projectively as in
textureProj, and with explicit gradient as in
Available to vertex, geometry, and fragment
bound to sampler. For shadow forms, compare is textureGrad.
shaders. gvec4=vec4, ivec4, uvec4. gvec4 textureProjOffset(gsampler{1D,2D[Rect],3D} sampler,
gsampler* =sampler*, isampler*, usampler*.
used as Dref and the array layer comes from P.w.
For non-shadow forms, the array layer comes from vec{2,3,4} P, {int,ivec2,ivec3} offset [, float bias]) gvec4 textureProjGrad(gsampler{1D,2D[Rect],3D} sampler,
the last component of P. {vec2,vec3,vec4} P, {float,vec2,vec3} dPdx,
The P argument needs to have enough float textureProjOffset( {float,vec2,vec3} dPdy)
components to specify each dimension, array gvec4 texture( sampler{1D,2D[Rect]}Shadow sampler, vec4 P,
layer, or comparison for the selected sampler. gsampler{1D[Array],2D[Array,Rect],3D,Cube[Array]} sampler, float textureProjGrad(sampler{1D,2D[Rect]}Shadow sampler,
{int,ivec2} offset [, float bias]) vec4 P, {float,vec2} dPdx, {float,vec2} dPdy)
The dPdx and dPdy arguments need enough {float,vec2,vec3,vec4} P [, float bias])
components to specify the derivative for each
dimension of the sampler. float texture( Offset texture lookup with explicit LOD. Texture lookup projectively and with explicit gradient
sampler{1D[Array],2D[Array,Rect],Cube}Shadow sampler, as in textureProjGrad, as well as with offset as in
Texture Query Functions [8.9.1] {vec3,vec4} P [, float bias]) gvec4 textureLodOffset(
textureOffset.
textureSize functions return dimensions of lod float texture(gsamplerCubeArrayShadow sampler, vec4 P, gsampler{1D[Array],2D[Array],3D} sampler,
(if present) for the texture bound to sampler. float compare) {float,vec2,vec3} P, float lod, {int,ivec2,ivec3} offset) gvec4 textureProjGradOffset(
Components in return value are filled in with the gsampler{1D,2D[Rect],3D} sampler, vec{2,3,4} P,
Texture lookup with projection. float textureLodOffset( {float,vec2,vec3} dPdx, {float,vec2,vec3} dPdy,
width, height, depth of the texture. For array sampler{1D[Array],2D}Shadow sampler, vec3 P, float lod, {int,ivec2,ivec3} offset)
forms, the last component of the return value is gvec4 textureProj(gsampler{1D,2D[Rect],3D} sampler, {int,ivec2} offset)
the number of layers in the texture array. float textureProjGradOffset(
vec{2,3,4} P [, float bias]) sampler{1D,2D[Rect]Shadow} sampler, vec4 P,
{int,ivec2,ivec3} textureSize( float textureProj(sampler{1D,2D[Rect]}Shadow sampler, Projective texture lookup with explicit LOD. {float,vec2} dPdx, {float,vec2} dPdy, {ivec2,int,vec2} offset)
gsampler{1D[Array],2D[Rect,Array],Cube} sampler[, vec4 P [, float bias])
int lod]) gvec4 textureProjLod(gsampler{1D,2D,3D} sampler, Texture Gather Instructions [8.9.3]
{int,ivec2,ivec3} textureSize( Texture lookup as in texture but with explicit LOD. vec{2,3,4} P, float lod) These functions take components of a floating-point
gsampler{Buffer,2DMS[Array]}sampler) vector operand as a texture coordinate, determine
gvec4 textureLod( float textureProjLod(sampler{1D,2D}Shadow sampler,
{int,ivec2,ivec3} textureSize( gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler, vec4 P, float lod) a set of four texels to sample from the base level of
sampler{1D, 2D, 2DRect,Cube[Array]}Shadow sampler[, {float,vec2,vec3} P, float lod) detail of the specified texture image, and return one
int lod]) component from each texel in a four-component
ivec3 textureSize(samplerCubeArray sampler, int lod) float textureLod(sampler{1D[Array],2D}Shadow sampler, Offset projective texture lookup with explicit LOD.
vec3 P, float lod) result vector.
gvec4 textureProjLodOffset(gsampler{1D,2D,3D} sampler, gvec4 textureGather(
textureQueryLod functions return the mipmap Offset added before texture lookup. vec{2,3,4} P, float lod, {int, ivec2, ivec3} offset) gsampler{2D[Array,Rect],Cube[Array]} sampler,
array(s) that would be accessed in the x {vec2,vec3,vec4} P [, int comp])
component of the return value. Returns the gvec4 textureOffset( float textureProjLodOffset(sampler{1D,2D}Shadow sampler,
vec4 P, float lod, {int, ivec2} offset) vec4 textureGather(
computed level of detail relative to the base level gsampler{1D[Array],2D[Array,Rect],3D} sampler, sampler{2D[Array,Rect],Cube[Array]}Shadow sampler,
in the y component of the return value. {float,vec2,vec3} P, {int,ivec2,ivec3} offset [, float bias]) {vec2,vec3,vec4} P, float refZ)
vec2 textureQueryLod( float textureOffset( Texture lookup as in texture but with explicit gradients.
gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler, sampler{1D[Array],2D[Rect,Array]}Shadow sampler, Texture gather as in textureGather by offset as
{float,vec2,vec3} P) {vec3, vec4} P, {int,ivec2} offset [, float bias]) gvec4 textureGrad( described in textureOffset except minimum and
gsampler{1D[Array],2D[Rect,Array],3D,Cube[Array]} sampler, maximum offset values are given by
vec2 textureQueryLod(
sampler{1D[Array],2D[Array],Cube[Array]}Shadow sampler, Use integer texture coordinate P to lookup a single {float, vec2, vec3,vec4} P, {float, vec2, vec3} dPdx, {MIN, MAX}_PROGRAM_TEXTURE_GATHER_OFFSET.
{float,vec2,vec3} P) {float, vec2, vec3} dPdy)
texel from sampler.
float textureGrad( gvec4 textureGatherOffset(gsampler2D[Array,Rect] sampler,
textureQueryLevels functions return the number gvec4 texelFetch( {vec2,vec3} P, ivec2 offset [, int comp])
sampler{1D[Array],2D[Rect,Array], Cube}Shadow sampler,
of mipmap levels accessible in the texture gsampler{1D[Array],2D[Array,Rect],3D} sampler, {vec3,vec4} P, {float,vec2} dPdx, {float,vec2, vec3} dPdy) vec4 textureGatherOffset(
associated with sampler. {int,ivec2,ivec3} P[, {int,ivec2} lod]) sampler2D[Array,Rect]Shadow sampler,
gvec4 texelFetch(gsampler{Buffer, 2DMS[Array]} sampler, {vec2,vec3} P, float refZ, ivec2 offset)
int textureQueryLevels( Texture lookup with both explicit gradient and offset.
gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler) {int,ivec2,ivec3} P[, int sample])
gvec4 textureGradOffset( Texture gather as in textureGatherOffset except offsets
int textureQueryLevels( gsampler{1D[Array],2D[Rect,Array],3D} sampler, determines location of the four texels to sample.
sampler{1D[Array],2D[Array],Cube[Array]}Shadow sampler) Fetch single texel with offset added before texture lookup. {float,vec2,vec3} P, {float,vec2,vec3} dPdx,
gvec4 texelFetchOffset( {float,vec2,vec3} dPdy, {int,ivec2,ivec3} offset) gvec4 textureGatherOffsets(gsampler2D[Array,Rect] sampler,
textureSamples returns the number of samples gsampler{1D[Array],2D[Array],3D} sampler, {vec2,vec3} P, ivec2 offsets[4] [, int comp])
of the texture. float textureGradOffset(
{int,ivec2,ivec3} P, int lod, {int,ivec2,ivec3} offset) vec4 textureGatherOffsets(
sampler{1D[Array],2D[Rect,Array]}Shadow sampler,
int textureSamples(gsampler2DMS sampler) gvec4 texelFetchOffset( {vec3,vec4} P, {float,vec2} dPdx, {float,vec2}dPdy, sampler2D[Array,Rect]Shadow sampler,
gsampler2DRect sampler, ivec2 P, ivec2 offset) {int,ivec2} offset) {vec2,vec3} P, float refZ, ivec2 offsets[4])
int textureSamples(gsampler2DMSArray sampler)

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl


OpenGL 4.6 API Reference Guide Page 13
OpenGL API and OpenGL Shading Language Reference Card Index
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..
A DepthFunc 6 GetProgramInterfaceiv 2 PauseTransformFeedback 5
ActiveShaderProgram 2 DepthMask 6 GetProgramiv 2 PixelStore{i f} 2
ActiveTexture 2 DepthRange* 5 GetProgramPipeline* 2 PointParameter* 5
AttachShader 1 DetachShader 2 GetProgramResource* 2 PointSize 5
Android Platform 9 DisableVertexArrayAttrib 5 GetProgramStageiv 2 PolygonMode 5
B DisableVertexAttribArray 5 GetQuery* 1 PolygonOffset 5
BeginConditionalRender 5 DispatchCompute* 5 GetRenderbufferParameteriv 4 PolygonOffsetClamp 5
BeginQuery 1, 6 DrawArrays[Indirect] 5 GetSamplerParameter* 2 PopDebugGroup 6
BeginQueryIndexed 1 DrawArraysInstanced[BaseInstance] 5 GetShaderInfoLog 2 Preprocessor 9
BeginTransformFeedback 5 DrawBuffer(s) 6 GetShaderiv 2 PrimitiveRestartIndex 5
BindAttribLocation 5 DrawElements* 5 GetShaderPrecisionFormat 2 ProgramBinary 2
BindBuffer* 1 DrawRangeElements[BaseVertex] 5 GetShaderSource 2 ProgramParameteri 2
BindFragDataLocation* 5 DrawTransformFeedback* 5 GetString 6-7 ProgramUniform* 2
BindFramebuffer 4 E GetSubroutineIndex 2 ProvokingVertex 5
BindImageTexture(s) 4 EnableVertexArrayAttrib 5 GetSubroutineUniformLocation 2 PushDebugGroup 6
BindProgramPipeline 2 EnableVertexAttribArray 5 GetSynciv 1 Q-R
BindRenderbuffer 4 EndConditionalRender 5 GetTexImage 3 Qualifiers 9-10
BindSampler(s) 2 EndQuery 6 GetTex[Level]Parameter* 3 QueryCounter 1
BindTexture* 2 EndQuery[Indexed] 1 GetTextureImage 3 ReadBuffer 6
BindTransformFeedback 5 EndTransformFeedback 5 GetTextureLevelParameter{i f}v 3 ReadnPixels 6
BindVertex* 4 Errors 1 GetTextureParameter* 3 ReadPixels 6
BlendColor 6 GetTextureSubImage 3 ReleaseShaderCompiler 1
F
BlendEquation* 6 GetTransformFeedback* 7 RenderbufferStorage 4
Fences 1
BlendFunc* 6 GetTransformFeedbackVarying 5 RenderbufferStorageMultisample 4
FenceSync 1
Blit[Named]Framebuffer 6 GetUniform* 2 ResumeTransformFeedback 5
Finish 1
BufferStorage 1 GetVertexArray* 5
Flatshading 5 S
Buffer[Sub]Data 1 GetVertexAttrib* 5
Flush 1 SampleCoverage 6
C FlushMapped[Named]BufferRange 1 H-I SampleMaski 6
Check[Named]FramebufferStatus 4 FramebufferParameteri 4 Hint 6 SamplerParameter* 2
ClampColor 6 FramebufferRenderbuffer 4 InvalidateBufferData 1 Scissor 6
Clear 6 FramebufferTexture* 4 InvalidateBufferSubData 1 ShaderBinary 1
ClearBuffer[Sub]Data 1 FrontFace 5 InvalidateFramebuffer 6 ShaderSource 1
ClearBuffer* 6 InvalidateNamedFramebuffer* 6 ShaderStorageBlockBinding 2
G
ClearColor 6 InvalidateSubFramebuffer 6 Shading Language 9-12
GenBuffers 1
ClearDepth* 6 InvalidateTexImage 4 SpecializeShader 1
Generate[Texture]Mipmap 3
ClearNamedBuffer[Sub]Data 1 InvalidateTexSubImage 4 State and State Requests 6-7
GenFramebuffers 4
ClearNamedFramebuffer* 6 IsBuffer 1 StencilFunc* 6
GenProgramPipelines 2
ClearStencil 6 IsFramebuffer 4 StencilMask* 6
GenQueries 1
ClearTexImage 4 IsProgram[Pipeline] 2 StencilOp* 6
GenRenderbuffers 4
ClearTexSubImage 4 IsQuery 1 Synchronization 1
GenSamplers 2
ClientWaitSync 1 IsRenderbuffer 4 Synchronous Debug Output 6
GenTextures 2
ClipControl 5 IsSampler 2
GenTransformFeedbacks 5 T
ColorMask* 6 IsShader 1
GenVertexArrays 4 TexBuffer[Range] 3
Command Syntax 1 IsSync 1
GetActiveAtomicCounterBufferiv 2 TexImage*[Multisample] 3
CompileShader 1 IsTexture 2
GetActiveAttrib 5 TexParameter* 3
CompressedTex[Sub]Image* 3 IsTransformFeedback 5
GetActiveSubroutine* 2 TexStorage*[Multisample] 3-4
CompressedTextureSubImage* 3 IsVertexArray 4
GetActiveUniform* 2 TexSubImage* 3
CopyBufferSubData 1 GetAttachedShaders 2 L TextureBarrier 4
CopyImageSubData 6 GetAttribLocation 5 LineWidth 5 TextureBuffer[Range] 3
CopyNamedBufferSubData 1 GetBoolean* 6 LinkProgram 2 TextureParameter* 3
CopyTex[Sub]Image* 3 GetBufferParameteri[64]v 1 M TextureStorage*[Multisample] 4
CopyTextureSubImage* 3 GetBufferPointerv 1 Macros 9 TextureSubImage* 3
CreateBuffers 1 GetBufferSubData 1 MapBuffer[Range] 1 TextureView 3
CreateFramebuffers 4 GetCompressedTex* 3 MapNamedBuffer* 1 Timer Queries 1
CreateProgram 1 GetDebugMessageLog 6 MemoryBarrier 2 TransformFeedbackBufferBase 5
CreateProgramPipelines 2 GetDouble* 6 MemoryBarrierByRegion 2 TransformFeedbackBufferRange 5
CreateQueries 1 GetError 1 MinSampleShading 5 TransformFeedbackVarying(s) 5
CreateRenderbuffers 4 GetFloat* 6 MultiDrawArrays* 5 Types 9
CreateSamplers 2 GetFragData* 5 MultiDrawElements* 5 U
CreateShader 1 GetFramebuffer[Attachment]Parameter* 4 Multisampling 5 Uniform* 2
CreateShaderProgramv 2 GetGraphicsResetStatus 1 N UniformBlockBinding 2
CreateTextures 2 GetInteger[64]v 1 NamedBuffer[Sub]Data 1 UniformMatrix* 2
CreateTransformFeedbacks 5 GetInteger64i_v 6 NamedBufferStorage 1 UniformSubroutinesuiv 2
CreateVertexArrays 4 GetInteger64v 6 NamedFramebufferDrawBuffer(s) 6 Unmap[Named]Buffer 1
CullFace 5 GetIntegeri_v 6 NamedFramebufferParameteri 4 UseProgram[Stages] 2
D GetIntegerv 1 NamedFramebufferReadBuffer 6 V-W
DebugMessage* 6 GetIntegerv 6 NamedFramebufferRenderbuffer 4 ValidateProgram[Pipeline] 5
DeleteBuffers 1 GetInternalformativ* 7 NamedFramebufferTexture* 4 Variables, built-in 10
DeleteFramebuffers 4 GetMultisamplefv 5 NamedRenderbufferStorage* 4 VertexArrayAttrib*Format 4
DeleteProgram* 2 GetNamedBuffer* 1
O VertexArrayAttribBindin 5
DeleteProgramPipelines 2 GetNamedFramebuffer* 4
ObjectLabel 6 VertexArrayBindingDivisor 5
DeleteQueries 1 GetNamedRenderbufferParameteriv 4
ObjectPtrLabel 6 VertexArrayElementBuffer 4
DeleteRenderbuffers 4 GetnCompressedTexImage 3
OpenGL Pipeline 8 VertexArrayVertexBuffer(s) 4
DeleteSamplers 2 GetnTexImage 3
Operations and Constructors 10 VertexAttrib* 4-5
DeleteShader 1 GetnUniform{f d i ui}v 2
Operators and Expressions 9 VertexBindingDivisor 5
DeleteSync 1 GetObject[Ptr]Label 6
P Viewport* 5
DeleteTextures 2 GetPointerv 6
PatchParameterfv 5 WaitSync 1
DeleteTransformFeedbacks 5 GetProgramBinary 2
DeleteVertexArrays 4 GetProgramInfoLog 2 PatchParameteri 4

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.

©2017 Khronos Group - Rev. 0717 www.khronos.org/opengl

You might also like