Opengl 45 Reference Guide
User Manual:
Open the PDF directly: View PDF .
Page Count: 13
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL 4.5 API Reference Card Page 1
OpenGL® is the only cross-platform graphics API that enables
developers of software for PC, workstation, and supercomputing
hardware to create high-performance, visually-compelling graphics
software applications, in markets such as CAD, content creation,
energy, entertainment, game development, manufacturing,
medical, and virtual reality.
Specifications are available at www.opengl.org/registry
• See FunconName refers to funcons on this reference card.
• [n.n.n] and [Table n.n] refer to secons and tables in the OpenGL 4.5 core specicaon.
• [n.n.n] refers to secons in the OpenGL Shading Language 4.50 specicaon.
OpenGL Command Syntax [2.2]
GL commands are formed from a return type, a name, and oponally up to 4 characters
(or character pairs) from the Command Leers table (to the le), as shown by the prototype:
return-type Name{1234}{b s i i64 f d ub us ui ui64}{v} ([args ,] T arg1 , . . . , T argN [, args]);
The arguments enclosed in brackets ([args ,] and [, args]) may or may not be present.
The argument type T and the number N of arguments may be indicated by the command name
suxes. N is 1, 2, 3, or 4 if present. If “v” is present, an array of N items is passed by a pointer.
For brevity, the OpenGL documentaon and this reference may omit the standard prexes.
The actual names are of the forms: glFunconName(), GL_CONSTANT, GLtype
Command Execuon
[2.3]
OpenGL Errors [2.3.1]
enum GetError(void);
Graphics Reset Recovery [2.3.2]
enum GetGraphicsResetStatus(void);
Returns: NO_ERROR, GUILTY_CONTEXT_RESET,
{INNOCENT, UNKNOWN}_CONTEXT_RESET
GetIntegerv(
RESET_NOTIFICATION_STRATEGY);
Returns: NO_RESET_NOTIFICATION,
LOSE_CONTEXT_ON_RESET
Flush and Finish [2.3.3]
void Flush(void); void Finish(void);
Floang-Point Numbers [2.3.4]
16-Bit 1-bit sign, 5-bit exponent,
10-bit manssa
Unsigned 11-Bit no sign bit, 5-bit exponent,
6-bit manssa
Unsigned 10-Bit no sign bit, 5-bit exponent,
5-bit manssa
Command Leers [Tables 2.1, 2.2]
Where a leer denotes a type in a funcon
name, T within the prototype is the same type.
b - byte (8 bits) ub - ubyte (8 bits)
s - short (16 bits) us - ushort (16 bits)
i - int (32 bits) ui - uint (32 bits)
i64 - int64 (64 bits) ui64 - uint64 (64 bits)
f - oat (32 bits) d - double (64 bits)
Shaders and Programs
Shader Objects [7.1-2]
uint CreateShader(enum type);
type:
{COMPUTE, FRAGMENT}_SHADER,
{GEOMETRY, VERTEX}_SHADER,
TESS_{EVALUATION, CONTROL}_SHADER
void ShaderSource(uint shader, sizei count,
const char * const * string,
const int *length);
void CompileShader(uint shader);
void ReleaseShaderCompiler(void);
void DeleteShader(uint shader);
boolean IsShader(uint shader);
void ShaderBinary(sizei count,
const uint *shaders, enum binaryformat,
const void *binary, sizei length);
(Connued on next page)
Synchronizaon
Sync Objects and Fences [4.1]
void DeleteSync(sync sync);
sync FenceSync(enum condion, biield ags);
condion: SYNC_GPU_COMMANDS_COMPLETE
ags: must be 0
Timer Queries
[4.3]
Timer queries track the amount of me needed
to fully complete a set of GL commands.
void QueryCounter(uint id, TIMESTAMP);
void GetIntegerv(TIMESTAMP, int *data);
void GetInteger64v(TIMESTAMP, int64 *data);
Buer Objects [6]
void GenBuers(sizei n, uint *buers);
void CreateBuers(sizei n, uint *buers);
void
DeleteBuers
(sizei n, const uint *buers);
Create and Bind Buer Objects [6.1]
void BindBuer(enum target, uint buer);
target: [Table 6.1] {ARRAY, UNIFORM}_BUFFER,
{ATOMIC_COUNTER, QUERY}_BUFFER,
COPY_{READ, WRITE}_BUFFER,
{DISPATCH, DRAW}_INDIRECT_BUFFER,
{ELEMENT_ARRAY, TEXTURE}_BUFFER,
PIXEL_[UN]PACK_BUFFER,
SHADER_STORAGE_BUFFER,
TRANSFORM_FEEDBACK_BUFFER
void BindBuerRange(enum target,
uint index, uint buer, intptr oset,
sizeiptr size);
target: ATOMIC_COUNTER_BUFFER,
{SHADER_STORAGE, UNIFORM}_BUFFER,
TRANSFORM_FEEDBACK_BUFFER
void BindBuerBase(enum target,
uint index, uint buer);
target: See BindBuerRange
void BindBuersRange(enum target,
uint rst, sizei count, const uint *buers,
const intptr *osets, const sizeiptr *size);
target: See BindBuerRange
void BindBuersBase(enum target,
uint rst, sizei count,
const uint *buers
);
target: See BindBuerRange
Create/Modify Buer Object Data [6.2]
void BuerStorage(enum target,
sizeiptr size, const void *data,
biield ags);
target: See BindBuer
ags: Bitwise OR of MAP_{READ, WRITE}_BIT,
{DYNAMIC, CLIENT}_STORAGE_BIT,
MAP_{COHERENT, PERSISTENT}_BIT
void NamedBuerStorage(uint buer,
sizeiptr size, const void *data,
biield ags);
ags: See BuerStorage
void BuerData(enum target, sizeiptr size,
const void *data, enum usage);
target: See BindBuer
usage: DYNAMIC_{DRAW, READ, COPY},
{STATIC, STREAM}_{DRAW, READ, COPY}
void NamedBuerData(uint buer, sizeiptr
size, const void *data, enum usage);
void BuerSubData(enum target,
intptr oset, sizeiptr size,
const void *data);
target: See BindBuer
void NamedBuerSubData(uint buer,
intptr oset, sizeiptr size,
const void *data);
void ClearBuerSubData(enum target,
enum internalFormat, intptr oset,
sizeiptr size, enum format, enum type,
const void *data);
target: See BindBuer
internalformat: See TexBuer on pg. 3 of this card
format: RED, GREEN, BLUE, RG, RGB, RGBA, BGR,
BGRA, {RED, GREEN, BLUE, RG, RGB}_INTEGER,
{RGBA, BGR, BGRA} _INTEGER, STENCIL_INDEX,
DEPTH_{COMPONENT, STENCIL}
void ClearNamedBuerSubData(
uint buer, enum internalFormat,
intptr oset, sizeiptr size, enum format,
enum type, const void *data);
internalformat, format, type: See
ClearBuerSubData
void ClearBuerData(enum target,
enum internalformat, enum format,
enum type, const void *data);
target, internalformat, format: See
ClearBuerSubData
void ClearNamedBuerData(uint buer,
enum internalformat, enum format,
enum type, const void *data);
internalformat, format, type: See ClearBuerData
Map/Unmap Buer Data [6.3]
void *MapBuerRange(enum target,
intptr oset, sizeiptr length,
biield access);
target: See BindBuer
access: The Bitwise OR of MAP_X_BIT, where X may
be READ, WRITE, PERSISTENT, COHERENT,
INVALIDATE_{BUFFER, RANGE},
FLUSH_EXPLICIT, UNSYNCHRONIZED
void *MapNamedBuerRange(uint buer,
intptr oset, sizeiptr length,
biield access);
target: See BindBuer
access: See MapBuerRange
void *MapBuer(enum target, enum access);
access: See MapBuerRange
void *MapNamedBuer(uint buer,
enum access);
access: See MapBuerRange
void FlushMappedBuerRange(intptr oset,
sizeiptr length);
void FlushMappedNamedBuerRange(
uint buer, intptr oset, sizeiptr length);
boolean UnmapBuer(enum target);
target: See BindBuer
boolean UnmapNamedBuer(uint buer);
Invalidate Buer Data [6.5]
void InvalidateBuerSubData(uint buer,
intptr oset, sizeiptr length);
void InvalidateBuerData(uint buer);
Buer Object Queries [6, 6.7]
boolean IsBuer(uint buer);
void GetBuerSubData(enum target,
intptr oset, sizeiptr size, void *data);
target: See BindBuer
void GetNamedBuerSubData(uint buer,
intptr oset, sizeiptr size, void *data);
void GetBuerParameteri[64]v(
enum target, enum pname, int[64]*data);
target: See BindBuer
pname: [Table 6.2] BUFFER_SIZE, BUFFER_USAGE,
BUFFER_{ACCESS[_FLAGS]}, BUFFER_MAPPED,
BUFFER_MAP_{OFFSET, LENGTH},
BUFFER_{IMMUTABLE_STORAGE, ACCESS_FLAGS}
void GetNamedBuerParameteri[64]v(
uint buer, enum pname, int[64]*data);
void GetBuerPointerv(enum target,
enum pname, const void **params);
target: See BindBuer
pname: BUFFER_MAP_POINTER
void GetNamedBuerPointerv(uint buer,
enum pname, const void **params);
pname: BUFFER_MAP_POINTER
Copy Between Buers [6.6]
void CopyBuerSubData(enum readTarget,
enum writeTarget, intptr readOset,
intptr writeOset, sizeiptr size);
readTarget and writeTarget: See BindBuer
void CopyNamedBuerSubData(
uint readBuer, uint writeBuer,
intptr readOset, intptr writeOset,
sizeiptr size);
Asynchronous Queries
[4.2, 4.2.1]
void GenQueries(sizei n, uint *ids);
void CreateQueries(
enum target,
sizei n,
uint *ids);
target: See BeginQuery, plus TIMESTAMP
void DeleteQueries(sizei n, const uint *ids);
void BeginQuery(enum target, uint id);
target:
ANY_SAMPLES_PASSED[_CONSERVATIVE],
PRIMITIVES_GENERATED,
SAMPLES_PASSED, TIME_ELAPSED,
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
void BeginQueryIndexed(enum target,
uint index, uint id);
target: See BeginQuery
void EndQuery(enum target);
void EndQueryIndexed(enum target,
uint index);
boolean IsQuery(uint id);
void GetQueryiv(enum target, enum pname,
int *params);
target: See BeginQuery, plus TIMESTAMP
pname: CURRENT_QUERY, QUERY_COUNTER_BITS
void GetQueryIndexediv(enum target,
uint index, enum pname, int *params);
target: See BeginQuery, plus TIMESTAMP
pname: CURRENT_QUERY, QUERY_COUNTER_BITS
void GetQueryObjecv(uint id, enum pname,
int *params);
void GetQueryObjectuiv(uint id,
enum pname, uint *params);
void GetQueryObjec64v(uint id,
enum pname, int64 *params);
void GetQueryObjectui64v(uint id,
enum pname, uint64 *params);
pname: QUERY_TARGET,
QUERY_RESULT[_NO_WAIT, _AVAILABLE]
Waing for Sync Objects [4.1.1]
enum ClientWaitSync(sync sync,
biield ags, uint64 meout_ns);
ags: SYNC_FLUSH_COMMANDS_BIT, or zero
void WaitSync(sync sync, biield ags,
uint64 meout);
meout: TIMEOUT_IGNORED
Sync Object Queries [4.1.3]
void GetSynciv(sync sync, enum pname,
sizei bufSize, sizei *length, int *values);
pname: OBJECT_TYPE, SYNC_{STATUS, CONDITION, FLAGS}
boolean IsSync(sync sync);
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 2 OpenGL 4.5 API Reference Card
Shaders and Programs (cont.)
Program Objects [7.3]
uint CreateProgram(void);
void AachShader(uint program, uint shader);
void DetachShader(uint program,
uint shader);
void LinkProgram(uint program);
void UseProgram(uint program);
uint CreateShaderProgramv(enum type,
sizei count, const char * const * strings);
void ProgramParameteri(uint program,
enum pname, int value);
pname: PROGRAM_SEPARABLE,
PROGRAM_BINARY_RETRIEVABLE_HINT
value: TRUE, FALSE
void DeleteProgram(uint program);
boolean IsProgram(uint program);
Program Interfaces [7.3.1]
void GetProgramInterfaceiv(uint program,
enum programInterface, enum pname,
int *params);
programInterface:
ATOMIC_COUNTER_BUFFER, BUFFER_VARIABLE,
UNIFORM[_BLOCK], PROGRAM_{INPUT, OUTPUT},
SHADER_STORAGE_BLOCK,
{GEOMETRY, VERTEX}_SUBROUTINE,
TESS_{CONTROL, EVALUATION}_SUBROUTINE,
{FRAGMENT, COMPUTE}_SUBROUTINE,
TESS_CONTROL_SUBROUTINE_UNIFORM,
TESS_EVALUATION_SUBROUTINE_UNIFORM,
{GEOMETRY, VERTEX}_SUBROUTINE_UNIFORM,
{FRAGMENT, COMPUTE}_SUBROUTINE_UNIFORM,
TRANSFORM_FEEDBACK_{BUFFER, VARYING}
pname: ACTIVE_RESOURCES, MAX_NAME_LENGTH,
MAX_NUM_ACTIVE_VARIABLES,
MAX_NUM_COMPATIBLE_SUBROUTINES
uint GetProgramResourceIndex(
uint program, enum programInterface,
const char *name);
void GetProgramResourceName(
uint program, enum programInterface,
uint index, sizei bufSize, sizei *length,
char *name);
void GetProgramResourceiv(uint program,
enum programInterface, uint index,
sizei propCount, const enum *props,
sizei bufSize, sizei *length, int *params);
*props: [See Table 7.2]
int GetProgramResourceLocaon(
uint program, enum programInterface,
const char *name);
int GetProgramResourceLocaonIndex(
uint program, enum programInterface,
const char *name);
Program Pipeline Objects [7.4]
void GenProgramPipelines(sizei n,
uint *pipelines);
void DeleteProgramPipelines(sizei n,
const uint *pipelines);
boolean IsProgramPipeline(uint pipeline);
void BindProgramPipeline(uint pipeline);
void CreateProgramPipelines(sizei n,
uint *pipelines);
void UseProgramStages(uint pipeline,
biield stages, uint program);
stages: ALL_SHADER_BITS or the bitwise OR of
TESS_{CONTROL, EVALUATION}_SHADER_BIT,
{VERTEX, GEOMETRY, FRAGMENT}_SHADER_BIT,
COMPUTE_SHADER_BIT
void AcveShaderProgram(uint pipeline,
uint program);
Program Binaries [7.5]
void GetProgramBinary(uint program,
sizei bufSize, sizei *length,
enum *binaryFormat, void *binary);
void ProgramBinary(uint program,
enum binaryFormat, const void *binary,
sizei length);
Uniform Variables [7.6]
int GetUniformLocaon(uint program,
const char *name);
void GetAcveUniformName(uint program,
uint uniformIndex, sizei bufSize,
sizei *length, char *uniformName);
void GetUniformIndices(uint program,
sizei uniformCount,
const char * const *uniformNames,
uint *uniformIndices);
void GetAcveUniform(uint program,
uint index, sizei bufSize, sizei *length,
int *size, enum *type, char *name);
*type returns: DOUBLE_{VECn, MATn, MATmxn},
DOUBLE, FLOAT_{VECn, MATn, MATmxn}, FLOAT,
INT, INT_VECn, UNSIGNED_INT[_VECn], BOOL,
BOOL_VECn, or any value in [Table 7.3]
void GetAcveUniformsiv(uint program,
sizei uniformCount,
const uint *uniformIndices, enum pname,
int *params);
pname: [Table 7.6]
UNIFORM_{NAME_LENGTH, TYPE, OFFSET},
UNIFORM_{SIZE, BLOCK_INDEX, UNIFORM},
UNIFORM_{ARRAY, MATRIX}_STRIDE,
UNIFORM_IS_ROW_MAJOR,
UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX
uint GetUniformBlockIndex(uint program,
const char *uniformBlockName);
void GetAcveUniformBlockName(
uint program, uint uniformBlockIndex,
sizei bufSize, sizei length,
char *uniformBlockName);
void GetAcveUniformBlockiv(
uint program, uint uniformBlockIndex,
enum pname, int *params);
pname: UNIFORM_BLOCK_{BINDING, DATA_SIZE},
UNIFORM_BLOCK_NAME_LENGTH,
UNIFORM_BLOCK_ACTIVE_UNIFORMS[_INDICES],
UNIFORM_BLOCK_REFERENCED_BY_X_SHADER,
where X may be one of VERTEX, FRAGMENT,
COMPUTE, GEOMETRY, TESS_CONTROL, or
TESS_EVALUATION [Table 7.7]
void GetAcveAtomicCounterBueriv(
uint program, uint buerIndex,
enum pname, int *params);
pname: See GetAcveUniformBlockiv, however
replace the prex UNIFORM_BLOCK_ with
ATOMIC_COUNTER_BUFFER_
Load Uniform Vars. in Default Uniform Block
void Uniform{1234}{i f d ui}(int locaon,
T value);
void Uniform{1234}{i f d ui}v(int locaon,
sizei count, const T *value);
void UniformMatrix{234}{f d}v(
int locaon, sizei count, boolean transpose,
const oat *value);
void
UniformMatrix{2x3,3x2,2x4,4x2,3x4, 4x3}
{fd}v( int locaon, sizei count,
boolean transpose, const oat *value);
void ProgramUniform{1234}{i f d}(
uint program, int locaon, T value);
void ProgramUniform{1234}{i f d}v(
uint program, int locaon, sizei count,
const T *value);
void ProgramUniform{1234}uiv(
uint program, int locaon, sizei count,
const T *value);
void ProgramUniform{1234}ui(
uint program, int locaon, T value);
void ProgramUniformMatrix{234}{f d}v(
uint program, int locaon, sizei count,
boolean transpose, const T *value);
void ProgramUniformMatrixf{2x3,3x2,2x4,
4x2, 3x4, 4x3}{f d}v(
uint program, int locaon, sizei count,
boolean transpose, const T *value);
Uniform Buer Object Bindings
void UniformBlockBinding(uint program,
uint uniformBlockIndex,
uint uniformBlockBinding);
Shader Buer Variables [7.8]
void ShaderStorageBlockBinding(
uint program, uint storageBlockIndex,
uint storageBlockBinding);
Subroune Uniform Variables [7.9]
Parameter shadertype for the funcons in this
secon may be {COMPUTE, VERTEX}_SHADER,
TESS_{CONTROL, EVALUATION}_SHADER, or
{FRAGMENT, GEOMETRY}_SHADER
int GetSubrouneUniformLocaon(
uint program, enum shadertype,
const char *name);
uint GetSubrouneIndex(uint program,
enum shadertype, const char *name);
void GetAcveSubrouneName(
uint program, enum shadertype,
uint index, sizei bufsize, sizei *length,
char *name);
void GetAcveSubrouneUniformName(
uint program, enum shadertype,
uint index, sizei bufsize, sizei *length,
char *name);
void GetAcveSubrouneUniformiv(
uint program, enum shadertype,
uint index, enum pname, int *values);
pname: [NUM_]COMPATIBLE_SUBROUTINES
void UniformSubrounesuiv(
enum shadertype, sizei count,
const uint *indices);
Shader Memory Access [7.12.2]
See diagram on page 6 for more informaon.
void MemoryBarrier(biield barriers);
barriers: ALL_BARRIER_BITS or the OR of
X_BARRIER_BIT where X may be: QUERY_BUFFER,
VERTEX_ATTRIB_ARRAY, ELEMENT_ARRAY,
UNIFORM, TEXTURE_FETCH, BUFFER_UPDATE,
SHADER_IMAGE_ACCESS, COMMAND,
PIXEL_BUFFER, TEXTURE_UPDATE, FRAMEBUFFER,
TRANSFORM_FEEDBACK, ATOMIC_COUNTER,
SHADER_STORAGE, CLIENT_MAPPED_BUFFER,
void MemoryBarrierByRegion(biield
barriers);
barriers: ALL_BARRIER_BITS or the OR of
X_BARRIER_BIT where X may be:
ATOMIC_COUNTER, FRAMEBUFFER,
SHADER_IMAGE_ACCESS, SHADER_STORAGE,
TEXTURE_FETCH, UNIFORM
Shader and Program Queries [7.13]
void GetShaderiv(uint shader, enum pname,
int *params);
pname: SHADER_TYPE, INFO_LOG_LENGTH,
{DELETE, COMPILE}_STATUS, COMPUTE_SHADER,
SHADER_SOURCE_LENGTH
void GetProgramiv(uint program,
enum pname, int *params);
pname: ACTIVE_ATOMIC_COUNTER_BUFFERS,
ACTIVE_ATTRIBUTES,
ACTIVE_ATTRIBUTE_MAX_LENGTH,
ACTIVE_UNIFORMS, ACTIVE_UNIFORM_BLOCKS,
ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH,
ACTIVE_UNIFORM_MAX_LENGTH,
ATTACHED_SHADERS, VALIDATE_STATUS,
COMPUTE_WORK_GROUP_SIZE, DELETE_STATUS,
GEOMETRY_{INPUT, OUTPUT}_TYPE,
GEOMETRY_SHADER_INVOCATIONS,
GEOMETRY_VERTICES_OUT, INFO_LOG_LENGTH,
LINK_STATUS, PROGRAM_SEPARABLE,
PROGRAM_BINARY_RETRIEVABLE_HINT,
TESS_CONTROL_OUTPUT_VERTICES,
TESS_GEN_{MODE, SPACING},
TESS_GEN_{VERTEX_ORDER, POINT_MODE},
TRANSFORM_FEEDBACK_BUFFER_MODE,
TRANSFORM_FEEDBACK_VARYINGS,
TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH
void GetProgramPipelineiv(uint pipeline,
enum pname, int *params);
pname: ACTIVE_PROGRAM, VALIDATE_STATUS,
{VERTEX, FRAGMENT, GEOMETRY}_SHADER,
TESS_{CONTROL, EVALUATION}_SHADER,
INFO_LOG_LENGTH, COMPUTE_SHADER
void GetAachedShaders(uint program,
sizei maxCount, sizei *count,
uint *shaders);
void GetShaderInfoLog(uint shader,
sizei bufSize, sizei *length, char *infoLog);
void GetProgramInfoLog(uint program,
sizei bufSize, sizei *length, char *infoLog);
void GetProgramPipelineInfoLog(
uint pipeline, sizei bufSize,
sizei *length, char *infoLog);
void GetShaderSource(uint shader,
sizei bufSize, sizei *length, char *source);
void GetShaderPrecisionFormat(
enum shadertype, enum precisiontype,
int *range, int *precision);
shadertype: {VERTEX, FRAGMENT}_SHADER
precisiontype: {LOW, MEDIUM, HIGH}_{FLOAT, INT}
void GetUniform{f d i ui}v(uint program,
int locaon, T *params);
void GetnUniform{f d i ui}v(uint program,
int locaon, sizei bufSize, T *params);
void GetUniformSubrouneuiv(
enum shadertype, int locaon,
uint *params);
void GetProgramStageiv(uint program,
enum shadertype, enum pname,
int *values);
pname: ACTIVE_SUBROUTINES,
ACTIVE_SUBROUTINE_X where X may be
UNIFORMS, MAX_LENGTH, UNIFORM_LOCATIONS,
UNIFORM_MAX_LENGTH
Textures and Samplers [8]
void AcveTexture(enum texture);
texture: TEXTUREi (where i is
[0, max(MAX_TEXTURE_COORDS,
MAX_COMBINED_TEXTURE_IMAGE_UNITS)-1])
Texture Objects [8.1]
void GenTextures(sizei n, uint *textures);
void BindTexture(enum target, uint texture);
target: TEXTURE_{1D, 2D}[_ARRAY],
TEXTURE_{3D, RECTANGLE, BUFFER},
TEXTURE_CUBE_MAP[_ARRAY],
TEXTURE_2D_MULTISAMPLE[_ARRAY]
void BindTextures(uint rst, sizei count,
const uint *textures);
target: See BindTexture
void BindTextureUnit(uint unit, uint texture);
void CreateTextures(enum target, sizei n,
uint *textures);
target: See BindTexture
void DeleteTextures(sizei n,
const uint *textures);
boolean IsTexture(uint texture);
Sampler Objects [8.2]
void GenSamplers(sizei count, uint *samplers);
void CreateSamplers(sizei n, uint *samplers);
void BindSampler(uint unit, uint sampler);
void BindSamplers(uint rst, sizei count,
const uint *samplers);
void SamplerParameter{i f}(uint sampler,
enum pname, T param);
pname: TEXTURE_X where X may be WRAP_{S, T, R},
{MIN, MAG}_FILTER, {MIN, MAX}_LOD,
BORDER_COLOR, LOD_BIAS,
COMPARE_{MODE, FUNC}
[Table 23.18]
void SamplerParameter{i f}v(uint sampler,
enum pname, const T *param);
pname: See SamplerParameter{if}
void SamplerParameterI{i ui}v(uint sampler,
enum pname, const T *params);
pname: See SamplerParameter{if}
void DeleteSamplers(sizei count,
const uint *samplers);
boolean IsSampler(uint sampler);
Sampler Queries [8.3]
void GetSamplerParameter{i f}v(
uint sampler, enum pname, T *params);
pname: See SamplerParameter{if}
void GetSamplerParameterI{i ui}v(
uint sampler, enum pname, T *params);
pname:
See SamplerParameter{if}
Pixel Storage Modes [8.4.1]
void PixelStore{i f}(enum pname, T param);
pname:
[Tables 8.1, 18.1]
[UN]PACK_X where X may
be SWAP_BYTES, LSB_FIRST, ROW_LENGTH,
SKIP_{IMAGES, PIXELS, ROWS}, ALIGNMENT,
IMAGE_HEIGHT, COMPRESSED_BLOCK_WIDTH,
COMPRESSED_BLOCK_{HEIGHT, DEPTH, SIZE}
(Connued on next page)
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL 4.5 API Reference Card Page 3
Textures and Samplers (cont.)
Texture Image Spec. [8.5]
void TexImage3D(enum target, int level,
int internalformat, sizei width, sizei height,
sizei depth, int border, enum format,
enum type, const void *data);
target: [PROXY_]TEXTURE_CUBE_MAP_ARRAY,
[PROXY_]TEXTURE_2D_ARRAY, [PROXY_]TEXTURE_3D
internalformat: STENCIL_INDEX, RED,
DEPTH_{COMPONENT, STENCIL}, RG, RGB, RGBA,
COMPRESSED_{RED, RG, RGB, RGBA, SRGB,
SRGB_ALPHA), a sized internal format from
[Tables 8.12 - 8.13], or a COMPRESSED_ format
from [Table 8.14]
format: DEPTH_{COMPONENT, STENCIL}, RED,
GREEN, BLUE, RG, RGB, RGBA, BGR, BGRA,
{BGRA, RED, GREEN, BLUE}_INTEGER,
{RG, RGB, RGBA, BGR}_INTEGER,
STENCIL_INDEX, [Table 8.3]
type: [UNSIGNED_]{BYTE, SHORT, INT},
[HALF_]FLOAT, or a value from [Table 8.2]
void TexImage2D(enum target, int level,
int internalformat, sizei width,
sizei height, int border, enum format,
enum type, const void *data);
target: [PROXY_]TEXTURE_{2D, RECTANGLE},
[PROXY_]TEXTURE_{1D_ARRAY, CUBE_MAP},
TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z},
TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z}
internalformat, format, type: See TexImage3D
void TexImage1D(enum target, int level,
int internalformat, sizei width, int border,
enum format, enum type, const void *data);
target: TEXTURE_1D, PROXY_TEXTURE_1D
type, internalformat, format: See TexImage3D
Alternate Texture Image Spec. [8.6]
void CopyTexImage2D(enum target,
int level, enum internalformat, int x,
int y, sizei width, sizei height, int border);
target: TEXTURE_{2D, RECTANGLE, 1D_ARRAY},
TEXTURE_CUBE_MAP_{POSITIVE, NEGATIVE}_{X, Y, Z}
internalformat: See TexImage3D
void CopyTexImage1D(enum target,
int level, enum internalformat, int x,
int y, sizei width, int border);
target: TEXTURE_1D
internalformat: See TexImage3D
void TexSubImage3D(enum target, int level,
int xoset, int yoset, int zoset,
sizei width, sizei height, sizei depth,
enum format, enum type,
const void *data);
target: TEXTURE_3D, TEXTURE_2D_ARRAY,
TEXTURE_CUBE_MAP_ARRAY
format, type: See TexImage3D
void TexSubImage2D(enum target,
int level, int xoset, int yoset, sizei width,
sizei height, enum format, enum type,
const void *data);
target: See CopyTexImage2D
format, type: See TexImage3D
void TexSubImage1D(enum target, int level,
int xoset, sizei width, enum format,
enum type, const void *data);
target, format, type: See CopyTexImage1D
void CopyTexSubImage3D(enum target,
int level, int xoset, int yoset, int zoset,
int x, int y, sizei width, sizei height);
target: See TexSubImage3D
void CopyTexSubImage2D(enum target,
int level, int xoset, int yoset, int x,
int y, sizei width, sizei height);
target: See TexImage2D
void CopyTexSubImage1D(enum target,
int level, int xoset, int x, int y, sizei width);
target: See TexSubImage1D
void TextureSubImage3D(uint texture, int level,
int xoset, int yoset, int zoset,
sizei width, sizei height, sizei depth,
enum format, enum type,
const void *pixels);
format, type: See TexImage3D
void TextureSubImage2D(uint texture, int level,
int xoset, int yoset, sizei width,
sizei height, enum format, enum type,
const void *pixels);
format, type: See TexImage3D
void TextureSubImage1D(uint texture, int level,
int xoset, sizei width, enum format,
enum type, const void *pixels);
format, type: See TexImage3D
void CopyTextureSubImage3D(uint texture,
int level, int xoset, int yoset, int zoset,
int x, int y, sizei width, sizei height);
void CopyTextureSubImage2D(uint texture,
int level, int xoset, int yoset, int x,
int y, sizei width, sizei height);
void CopyTextureSubImage1D(uint texture,
int level, int xoset, int x, int y, sizei width);
Compressed Texture Images [8.7]
void CompressedTexImage3D(enum target,
int level, enum internalformat, sizei width,
sizei height, sizei depth, int border,
sizei imageSize, const void *data);
target: See TexImage3D
internalformat: A COMPRESSED_
format from [Table 8.14]
void CompressedTexImage2D(enum target,
int level, enum internalformat,
sizei width, sizei height, int border,
sizei imageSize, const void *data);
target: See TexImage2D
internalformat: May be one of the COMPRESSED_
formats from [Table 8.14]
void CompressedTexImage1D(enum target,
int level, enum internalformat,
sizei width, int border, sizei imageSize,
const void *data);
target: TEXTURE_1D, PROXY_TEXTURE_1D
internalformat: See TexImage1D, oming
compressed rectangular texture formats
void CompressedTexSubImage3D(
enum target, int level, int xoset,
int yoset, int zoset, sizei width,
sizei height, sizei depth, enum format,
sizei imageSize, const void *data);
target: See TexSubImage3D
format: See internalformat for
CompressedTexImage3D
void CompressedTexSubImage2D(
enum target, int level, int xoset,
int yoset, sizei width, sizei height,
enum format, sizei imageSize,
cont void *data);
target: See TexSubImage2D
format: See internalformat for
CompressedTexImage2D
void CompressedTexSubImage1D(
enum target, int level, int xoset,
sizei width, enum format, sizei imageSize,
const void *data);
target: See TexSubImage1D
format: See internalformat for
CompressedTexImage1D
void CompressedTextureSubImage3D(
uint texture, int level, int xoset,
int yoset, int zoset, sizei width,
sizei height, sizei depth, enum format,
sizei imageSize, const void *data);
format: See internalformat for
CompressedTexImage3D
void CompressedTextureSubImage2D(
uint texture, int level, int xoset,
int yoset, sizei width, sizei height,
enum format, sizei imageSize,
cont void *data);
format: See internalformat for
CompressedTexImage2D
void CompressedTextureSubImage1D(
uint texture, int level, int xoset,
sizei width, enum format, sizei imageSize,
const void *data);
format: See internalformat for
CompressedTexImage1D
Mulsample Textures [8.8]
void TexImage3DMulsample(enum target,
sizei samples, int internalformat,
sizei width, sizei height, sizei depth,
boolean xedsamplelocaons);
target: [PROXY_]TEXTURE_2D_MULTISAMPLE_ARRAY
internalformat: RED, RG, RGB, RGBA, RGBA{32, 32UI},
DEPTH_COMPONENT[16, 24, 32, 32F],
DEPTH{24, 32F}_STENCIL8, STENCIL_INDEX{1, 4, 8, 16}
void TexImage2DMulsample(enum target,
sizei samples, int internalformat, sizei width,
sizei height, boolean xedsamplelocaons);
target: [PROXY_]TEXTURE_2D_MULTISAMPLE
internalformat: See TexImage3DMulsample
Buer Textures [8.9]
void TexBuerRange(enum target,
enum internalFormat, uint buer,
intptr oset, sizeiptr size);
void TextureBuerRange(uint texture,
enum internalFormat, uint buer,
intptr oset, sizeiptr size);
internalformat: See TexBuer
void TexBuer(enum target,
enum internalformat, uint buer);
target: TEXTURE_BUFFER
internalformat: [Table 8.16] R8, R8{I, UI}, R16,
R16{F, I, UI}, R32{F, I, UI}, RG8, RG8{I, UI}, RG16,
RG16{F, I, UI}, RG32{F, I, UI}, RGB32F, RGB32{I, UI},
RGBA8, RGBA8{I, UI}, RGBA16, RGBA16{F, I, UI},
RGBA32{F, I, UI}
void TextureBuer(uint texture,
enum internalformat, uint buer);
internalformat: See TexBuer
Texture Parameters [8.10]
void TexParameter{i f}(enum target,
enum pname, T param);
target: See BindTexture
void TexParameter{i f}v(enum target,
enum pname, const T *params);
target: See BindTexture
void TexParameterI{i ui}v(enum target,
enum pname, const T *params);
target: See BindTexture
pname: DEPTH_STENCIL_TEXTURE_MODE or
TEXTURE_X where X may be one of
WRAP_{S, T, R}, BORDER_COLOR,
{MIN, MAG}_FILTER, LOD_BIAS,{MIN, MAX}_LOD,
{BASE, MAX}_LEVEL, SWIZZLE_{R, G, B, A, RGBA},
COMPARE_{MODE, FUNC} [Table 8.17]
void TextureParameter{i f}(uint texture,
enum pname, T param);
pname: See BindTexture
void TextureParameter{i f}v(uint texture,
enum pname, const T *params);
pname: See BindTexture
void TextureParameterI{i ui}v(uint texture,
enum pname, const T *params);
pname: TEXTURE_3D, TEXTURE_{1D, 2D}[_ARRAY],
TEXTURE_CUBE_MAP[_ARRAY],
TEXTURE_RECTANGLE,
TEXTURE_2D_MULTISAMPLE[_ARRAY]
Texture Queries [8.11]
void GetTexParameter{if}v(enum target,
enum pname, T * params);
target: See BindTexture
pname: See GetTexParameterI{i ui}v
void GetTexParameterI{i ui}v(enum target,
enum pname, T * params);
target: See BindTexture
pname: IMAGE_FORMAT_COMPATIBILITY_TYPE,
TEXTURE_IMMUTABLE_{FORMAT, LEVELS},
TEXTURE_VIEW_MIN_{LEVEL, LAYER},
TEXTURE_VIEW_NUM_{LEVELS, LAYERS},
DEPTH_STENCIL_TEXTURE_MODE, or TEXTURE_X
where X may be one of WRAP_{S, T, R},
BORDER_COLOR, TARGET, {MIN, MAG}_FILTER,
LOD_BIAS,{MIN, MAX}_LOD, {BASE, MAX}_LEVEL,
SWIZZLE_{R, G, B, A, RGBA},
COMPARE_{MODE, FUNC} [Table 8.17]
void GetTextureParameter{if}v(uint texture,
enum pname, T *data);
pname: See GetTexParameterI{i ui}v
void GetTextureParameterI{i ui}v(uint texture,
enum pname, T *data);
pname: See GetTexParameterI{i ui}v
void GetTexLevelParameter{i f}v(enum target,
int level, enum pname, T *params);
target: [PROXY_]TEXTURE_{1D, 2D, 3D},
TEXTURE_BUFFER, PROXY_TEXTURE_CUBE_MAP,
[PROXY_]TEXTURE_{1D, 2D,CUBE_MAP}_ARRAY,
[PROXY_]TEXTURE_RECTANGLE,
TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z},
TEXTURE_CUBE_MAP_POSITIVE_{X, Y
, Z},
[PROXY_]TEXTURE_2D_MULTISAMPLE[_ARRAY]
pname: TEXTURE _*, where * may be WIDTH,
HEIGHT, DEPTH, FIXED_SAMPLE_LOCATIONS,
INTERNAL_FORMAT, SHARED_SIZE, COMPRESSED,
COMPRESSED_IMAGE_SIZE, SAMPLES,
BUFFER_{OFFSET, SIZE}, or X_{SIZE, TYPE}
where X can be RED, GREEN, BLUE, ALPHA, DEPTH
void GetTextureLevelParameter{i f}v(
uint texture, int level, enum pname,
T *params);
pname: See GetTexLevelParameter{i f}v
void GetTexImage(enum target, int level,
enum format, enum type, void *pixels);
target: TEXTURE_{1, 2}D[_ARRAY],
TEXTURE_{3D, RECTANGLE, CUBE_MAP_ARRAY},
TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z},
TEXTURE_CUBE_MAP_POSITIVE_{X, Y
, Z}
format: See TexImage3D
type: [UNSIGNED_]BYTE, SHORT, INT,
[HALF_]FLOAT, or a value from [Table 8.2]
void GetTextureImage(uint texture, int level,
enum format, enum type, sizei bufSize,
void *pixels);
level: LOD level
format, type: See GetTexImage
void GetnTexImage(enum tex, int level,
enum format, enum type, sizei bufSize,
void *pixels);
tex: TEXTURE_{1D, 2D, 3D}[_ARRAY], TEXTURE_3D,
TEXTURE_{CUBE_MAP_ARRAY, RECTANGLE},
TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z},
TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z}
level, format, type: See GetTextureImage
void GetTextureSubImage(uint texture,
int level, int xoset, int yoset, int zoset,
sizei width, sizei height, sizei depth,
enum format, enum type, sizei bufSize,
void *pixels);
level, format, type: See GetTextureImage
void GetCompressedTexImage(enum target,
int level, void *pixels);
target: See GetTextureImage
void
GetCompressedTextureImage(uint texture,
int level, sizei bufSize, void *pixels);
level: See GetTextureImage
void GetnCompressedTexImage(enum target,
int level, sizei bufsize, void *pixels);
target: See GetCompressedTexImage
level: LOD level
void GetCompressedTextureSubImage(
uint texture, int level, int xoset, int yoset,
int zoset, sizei width, sizei height,
sizei depth, sizei bufSize, void *pixels);
level: LOD level
Cube Map Texture Select [8.13.1]
Enable/Disable/IsEnabled(
TEXTURE_CUBE_MAP_SEAMLESS);
Manual Mipmap Generaon [8.14.4]
void GenerateMipmap(enum target);
target: TEXTURE_{1D, 2D, 3D},
TEXTURE_{1D, 2D}_ARRAY,
TEXTURE_CUBE_MAP[_ARRAY]
void GenerateTextureMipmap(uint texture);
Texture Views [8.18]
void TextureView(uint texture, enum target,
uint origtexture, enum internalformat,
uint minlevel, uint numlevels, uint minlayer,
uint numlayers);
target: TEXTURE_{1D, 2D,CUBE_MAP}[_ARRAY],
TEXTURE_3D, TEXTURE_RECTANGLE,
TEXTURE_2D_MULTISAMPLE[_ARRAY]
internalformat:
R8, R8{UI, I}, R8_SNORM, R11F_G11F_B10F,
R16{F, UI, I}, R16[_SNORM],
R32{F, UI, I}, SRGB8[UI, I],
RG8{F, UI, I}, RG8[_SNORM],
RG16{F, UI, I}, RG16[_SNORM], RG32{F, UI, I},
RGB8[_SNORM], RGB9_E5, RGB10_A2[UI],
RGBA8{UI, I}, RGBA8[_SNORM],
RGB16{F, UI, I}, RGB16[_SNORM], RGB32{F, UI, I},
RGBA16{F, UI, I}, RGBA16[_SNORM],
RGBA32{F, UI, I}, SRGB8_ALPHA8;
COMPRESSED_X where X may be
[SIGNED]_RED_RGTC1, [SIGNED]_RG_RGTC2,
{RGBA, SRGB_ALPHA}_BPTC_UNORM,
RGB_BPTC_[UN]SIGNED_FLOAT
Immutable-Format Tex. Images [8.19]
void TexStorage1D(enum target, sizei levels,
enum internalformat, sizei width);
target: TEXTURE_1D
internalformat: any of the sized internal color, depth,
and stencil formats in [Tables 8.18-20]
(Connued on next page)
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 4 OpenGL 4.5 API Reference Card
Framebuer Objects
Binding and Managing [9.2]
void BindFramebuer(enum target,
uint framebuer);
target: [DRAW_, READ_]FRAMEBUFFER
void CreateFramebuers(sizei n,
uint *framebuers);
void GenFramebuers(sizei n,
uint *framebuers);
void DeleteFramebuers(sizei n,
const uint *framebuers);
boolean IsFramebuer(uint framebuer);
Framebuer Object Parameters [9.2.1]
void FramebuerParameteri(
enum target, enum pname, int param);
target: [DRAW_, READ_]FRAMEBUFFER
pname: FRAMEBUFFER_DEFAULT_X where X may
be WIDTH, HEIGHT, FIXED_SAMPLE_LOCATIONS,
SAMPLES, LAYERS
void NamedFramebuerParameteri(
uint framebuer, enum pname, int param);
pname: See FramebuerParameteri
Framebuer Object Queries [9.2.3]
void GetFramebuerParameteriv(
enum target, enum pname, int *params);
target: See FramebuerParameteri
pname: See FramebuerParameteri plus
DOUBLEBUFFER, SAMPLES, SAMPLE_BUFFERS,
IMPLEMENTATION_COLOR_READ_FORMAT,
IMPLEMENTATION_COLOR_READ_TYPE, STEREO
void GetNamedFramebuerParameteriv(
uint framebuer, enum pname, int
*params);
pname: See GetFramebuerParameteri
void GetFramebuerAachmentParameteriv(
enum target, enum aachment,
enum pname, int *params);
target: [DRAW_, READ_]FRAMEBUFFER
aachment: DEPTH, FRONT_{LEFT, RIGHT}, STENCIL,
BACK_{LEFT, RIGHT}, COLOR_ATTACHMENTi,
{DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT
pname: FRAMEBUFFER_ATTACHMENT_ X where X
may be OBJECT_{TYPE, NAME}, COMPONENT_TYPE,
{RED, GREEN, BLUE, ALPHA, DEPTH, STENCIL}_SIZE,
COLOR_ENCODING, TEXTURE_{LAYER, LEVEL},
LAYERED, TEXTURE_CUBE_MAP_FACE
void GetNamedFramebuerAachment-
Parameteriv(uint framebuer,
enum aachment, enum pname,
int *params);
aachment, pname: See GetFramebuerParameteriv
Renderbuer Objects [9.2.4]
void BindRenderbuer(enum target,
uint renderbuer);
target: RENDERBUFFER
void {Create, Gen}Renderbuers(sizei n,
uint *renderbuers);
void DeleteRenderbuers(sizei n,
const uint *renderbuers);
boolean IsRenderbuer(uint renderbuer);
void RenderbuerStorageMulsample(
enum target, sizei samples,
enum internalformat, sizei width,
sizei height);
target: RENDERBUFFER
internalformat: See TexImage3DMulsample
void
NamedRenderbuerStorageMulsample(
uint renderbuer, sizei samples,
enum internalformat, sizei width,
sizei height);
internalformat: See TexImage3DMulsample
void RenderbuerStorage(enum target,
enum internalformat, sizei width,
sizei height);
target: RENDERBUFFER
internalformat: See TexImage3DMulsample
void NamedRenderbuerStorage(
uint renderbuer, enum internalformat,
sizei width, sizei height);
internalformat: See TexImage3DMulsample
Renderbuer Object Queries [9.2.6]
void GetRenderbuerParameteriv(
enum target, enum pname, int *params);
target: RENDERBUFFER
pname: [Table 23.27]
RENDERBUFFER_X where X may be WIDTH,
HEIGHT, INTERNAL_FORMAT, SAMPLES,
{RED, GREEN, BLUE, ALPHA, DEPTH, STENCIL}_SIZE
void GetNamedRenderbuerParameteriv(
uint renderbuer, enum pname,
int *params);
pname: See GetRenderbuerParameteriv
Aaching Renderbuer Images [9.2.7]
void FramebuerRenderbuer(
enum target, enum aachment,
enum renderbuertarget,
uint renderbuer);
target: [DRAW_, READ_]FRAMEBUFFER
aachment: [Table 9.1]
{DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT,
COLOR_ATTACHMENTi where i is
[0, MAX_COLOR_ATTACHMENTS - 1]
renderbuertarget: RENDERBUFFER if renderbuer is
non-zero, else undened
void NamedFramebuerRenderbuer(
uint framebuer, enum aachment,
enum renderbuertarget,
uint renderbuer);
aachment, renderbuertarget: See
FramebuerRenderbuer
Aaching Texture Images [9.2.8]
void FramebuerTexture(enum target,
enum aachment, uint texture, int level);
target: [DRAW_, READ_]FRAMEBUFFER
aachment: See FramebuerRenderbuer
void NamedFramebuerTexture(
uint framebuer, enum aachment,
uint texture, int level);
aachment: See FramebuerRenderbuer
void FramebuerTexture1D(enum target,
enum aachment, enum textarget,
uint texture, int level);
textarget: TEXTURE_1D
target, aachment: See FramebuerRenderbuer
void FramebuerTexture2D(enum target,
enum aachment, enum textarget,
uint texture, int level);
textarget: TEXTURE_CUBE_MAP_POSITIVE_{X, Y, Z},
TEXTURE_CUBE_MAP_NEGATIVE_{X, Y, Z},
TEXTURE_{2D, RECTANGLE, 2D_MULTISAMPLE}
(unspecied if texture is 0)
target, aachment: See FramebuerRenderbuer
void FramebuerTexture3D(enum target,
enum aachment, enum textarget,
uint texture, int level, int layer);
textarget: TEXTURE_3D (unspecied if texture is 0)
target, aachment: See FramebuerRenderbuer
void FramebuerTextureLayer(enum target,
enum aachment, uint texture,
int level, int layer);
target, aachment: See FramebuerRenderbuer
void NamedFramebuerTextureLayer(
uint framebuer, enum aachment,
uint texture, int level, int layer);
aachment: See FramebuerRenderbuer
Feedback Loops [9.3.1]
void TextureBarrier(void);
Framebuer Completeness [9.4.2]
enum CheckFramebuerStatus(enum target);
target: [DRAW_, READ_]FRAMEBUFFER
returns: FRAMEBUFFER_COMPLETE or a constant
indicang the violang value
enum CheckNamedFramebuerStatus(
uint framebuer, enum target);
target: See CheckFramebuerStatus
Verces
Separate Patches [10.1.15]
void PatchParameteri(enum pname, int value);
pname: PATCH_VERTICES
Current Vertex Aribute Values [10.2]
Use the commands VertexArib*for aributes
of type oat, VertexAribI* for int or uint, or
VertexAribL* for double.
void VertexArib{1234}{s f d}(uint index,
T values);
void VertexArib{123}{s f d}v(uint index,
const T *values);
void VertexArib4{b s i f d ub us ui}v(
uint index, const T *values);
void VertexArib4Nub(uint index, ubyte x,
ubyte y, ubyte z, ubyte w);
void VertexArib4N{b s i ub us ui}v(
uint index, const T *values);
void VertexAribI{1234}{i ui}(uint index,
T values);
void VertexAribI{1234}{i ui}v(uint index,
const T *values);
void VertexAribI4{b s ub us}v(uint index,
const T *values);
void VertexAribL{1234}d(uint index,
const T values);
void VertexAribL{1234}dv(uint index,
const T *values);
void VertexAribP{1234}ui(uint index,
enum type, boolean normalized, uint value);
void VertexAribP{1234}uiv(uint index,
enum type, boolean normalized,
const uint *value);
type: [UNSIGNED_]INT_2_10_10_10_REV, or
UNSIGNED_INT_10F_11F_11F_REV (except for
VertexAribP4uiv)
Vertex Arrays
Vertex Array Objects [10.3.1]
All states related to denion of data used by
vertex processor is in a vertex array object.
void GenVertexArrays(sizei n, uint *arrays);
void DeleteVertexArrays(sizei n,
const uint *arrays);
void BindVertexArray(uint array);
void CreateVertexArrays(sizei n, uint *arrays);
boolean IsVertexArray(uint array);
void VertexArrayElementBuer(uint vaobj,
uint buer);
Generic Vertex Aribute Arrays [10.3.2]
void VertexAribFormat(uint aribindex,
int size, enum type, boolean normalized,
unit relaveoset);
type: [UNSIGNED_]BYTE, [UNSIGNED_]SHORT,
[UNSIGNED_]INT, [HALF_]FLOAT, DOUBLE, FIXED,
[UNSIGNED_]INT_2_10_10_10_REV,
UNSIGNED_INT_10F_11F_11F_REV
void VertexAribIFormat(uint aribindex,
int size, enum type, unit relaveoset);
type: [UNSIGNED_]BYTE, [UNSIGNED_]SHORT,
[UNSIGNED_]INT
void VertexAribLFormat(uint aribindex,
int size, enum type, unit relaveoset);
type: DOUBLE
void VertexArrayAribFormat(uint vaobj,
uint aribindex, int size, enum type,
boolean normalized, uint relaveoset);
type: See VertexAribFormat
void VertexArrayAribIFormat(uint vaobj,
uint aribindex, int size, enum type,
uint relaveoset);
type: See VertexAribIFormat
void VertexArrayAribLFormat(uint vaobj,
uint aribindex, int size, enum type,
uint relaveoset);
type: See VertexAribLFormat
void BindVertexBuer(uint bindingindex,
uint buer, intptr oset, sizei stride);
void VertexArrayVertexBuer(uint vaobj,
uint bindingindex, uint buer, intptr oset,
sizei stride);
void BindVertexBuers(uint rst,
sizei count, const uint *buers,
const intptr *osets, const sizei *strides);
void VertexArrayVertexBuers(uint vaobj,
uint rst, sizei count, const uint *buers,
const intptr *osets, const sizei *strides);
void VertexAribBinding(uint aribindex,
uint bindingindex);
(Connued on next page)
Textures and Samplers (cont.)
void TexStorage2D(enum target, sizei levels,
enum internalformat, sizei width,
sizei height);
target: TEXTURE_{RECTANGLE, CUBE_MAP},
TEXTURE_{1D_ARRAY, 2D}
internalformat: See TexStorage1D
void TexStorage3D(enum target, sizei levels,
enum internalformat, sizei width,
sizei height, sizei depth);
target: TEXTURE_3D,
TEXTURE_{CUBE_MAP, 2D}[_ARRAY]
internalformat: See TexStorage1D
void TextureStorage1D(uint texture, sizei levels,
enum internalformat, sizei width);
internalformat: See TexStorage1D
void TextureStorage2D(uint texture,
sizei levels, enum internalformat,
sizei width, sizei height);
internalformat: See TexStorage1D
void TextureStorage3D(uint texture,
sizei levels, enum internalformat,
sizei width, sizei height, sizei depth);
internalformat: See TexStorage1D
void TexStorage2DMulsample(
enum target, sizei samples,
enum internalformat, sizei width,
sizei height, boolean xedsamplelocaons);
target: TEXTURE_2D_MULTISAMPLE
void TexStorage3DMulsample(
enum target, sizei samples,
enum internalformat, sizei width,
sizei height, sizei depth,
boolean xedsamplelocaons);
target: TEXTURE_2D_MULTISAMPLE_ARRAY
void TextureStorage2DMulsample(
uint texture, sizei samples,
enum internalformat, sizei width,
sizei height, boolean xedsamplelocaons);
void TextureStorage3DMulsample(
uint texture, sizei samples,
enum internalformat, sizei width,
sizei height, sizei depth,
boolean xedsamplelocaons);
Invalidate Texture Image Data [8.20]
void InvalidateTexSubImage(uint texture,
int level, int xoset, int yoset, int zoset,
sizei width, sizei height, sizei depth);
void InvalidateTexImage(uint texture, int level);
Clear Texture Image Data [8.21]
void ClearTexSubImage(uint texture,
int level, int xoset, int yoset, int zoset,
sizei width, sizei height, sizei depth,
enum format, enum type, const void *data);
format, type: See TexImage3D, pg 2 this card
void ClearTexImage(uint texture,
int level, enum format, enum type,
const void *data);
format, type: See TexImage3D, pg 2 this card
Texture Image Loads/Stores [8.26]
void BindImageTexture(uint index,
uint texture, int level, boolean layered,
int layer, enum access, enum format);
access: READ_ONLY, WRITE_ONLY, READ_WRITE
format: RGBA{32,16}F, RG{32,16}F, R11F_G11F_B10F,
R{32,16}F, RGBA{32,16,8}UI, RGB10_A2UI,
RG{32,16,8}UI, R{32,16,8}UI, RGBA{32,16,8}I,
RG{32,16,8}I, R{32,16,8}I, RGBA{16,8}, RGB10_A2,
RG{16,8}, R{16,8}, RGBA{16,8}_SNORM,
RG{16,8}_SNORM, R{16,8}_SNORM [Table 8.26]
void BindImageTextures(uint rst,
sizei count, const uint *textures);
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL 4.5 API Reference Card Page 5
Vertex Post-Processing [13]
Transform Feedback [13.2]
void GenTransformFeedbacks(sizei n,
uint *ids);
void DeleteTransformFeedbacks(sizei
n
,
const uint *
ids
);
boolean IsTransformFeedback(uint id);
void BindTransformFeedback(
enum target, uint id);
target: TRANSFORM_FEEDBACK
void CreateTransformFeedbacks(
sizei n, uint *ids);
void BeginTransformFeedback(
enum primiveMode);
primiveMode: TRIANGLES, LINES, POINTS
void EndTransformFeedback(void);
void PauseTransformFeedback(void);
void ResumeTransformFeedback(void);
void TransformFeedbackBuerRange(
uint x, uint index, uint buer, intptr oset,
sizeiptr size);
void TransformFeedbackBuerBase(
uint x, uint index, uint buer);
Transform Feedback Drawing [13.2.3]
void DrawTransformFeedback(
enum mode, uint id);
mode: See Drawing Commands [10.4] above
void DrawTransformFeedbackInstanced(
enum mode, uint id, sizei instancecount);
void DrawTransformFeedbackStream(
enum mode, uint id, uint stream);
void
DrawTransformFeedbackStreamInstanced(
enum mode, uint id, uint stream,
sizei instancecount);
Flatshading [13.4]
void ProvokingVertex(enum provokeMode);
provokeMode: {FIRST, LAST}_VERTEX_CONVENTION
Primive Clipping [13.5]
Enable/Disable/IsEnabled(target);
target: DEPTH_CLAMP, CLIP_DISTANCEi where
i = [0..MAX_CLIP_DISTANCES - 1]
void ClipControl(enum origin, enum depth);
origin: LOWER_LEFT or UPPER_LEFT
depth: NEGATIVE_ONE_TO_ONE or ZERO_TO_ONE
Controlling Viewport [13.6.1]
void DepthRangeArrayv(uint rst,
sizei count, const double *v);
void DepthRangeIndexed(uint index,
double n, double f);
void DepthRange(double n, double f);
void DepthRangef(oat n, oat f);
void ViewportArrayv(uint rst, sizei count,
const oat *v);
void ViewportIndexedf(uint index, oat x,
oat y, oat w, oat h);
void ViewportIndexedfv(uint index,
const oat *v);
void Viewport(int x, int y, sizei w, sizei h);
Rasterizaon [13.4, 14]
Enable/Disable/IsEnabled(target);
target: RASTERIZER_DISCARD
Mulsampling [14.3.1]
Use to analias points, and lines.
Enable/Disable/IsEnabled(target);
target: MULTISAMPLE, SAMPLE_SHADING
void GetMulsamplefv(enum pname,
uint index, oat *val);
pname: SAMPLE_POSITION
void MinSampleShading(oat value);
Points [14.4]
void PointSize(oat size);
void PointParameter{i f}(enum pname,
T param);
pname, param: See PointParameter{if}v
void PointParameter{i f}v(enum pname,
const T *params);
pname: POINT_FADE_THRESHOLD_SIZE,
POINT_SPRITE_COORD_ORIGIN
params: The fade threshold if pname is
POINT_FADE_THRESHOLD_SIZE;
{LOWER, UPPER}_LEFT if pname is
POINT_SPRITE_COORD_ORIGIN
Enable/Disable/IsEnabled(target);
target: PROGRAM_POINT_SIZE
Line Segments [14.5]
Enable/Disable/IsEnabled(target);
target: LINE_SMOOTH
void LineWidth(oat width);
Polygons [14.6, 14.6.1]
Enable/Disable/IsEnabled(target);
target: POLYGON_SMOOTH, CULL_FACE
void FrontFace(enum dir);
dir: CCW, CW
void CullFace(enum mode);
mode: FRONT, BACK, FRONT_AND_BACK
Polygon Rast. & Depth Oset [14.6.4-5]
void PolygonMode(enum face, enum mode);
face: FRONT_AND_BACK
mode: POINT, LINE, FILL
void PolygonOset(oat factor, oat units);
Enable/Disable/IsEnabled(target);
target: POLYGON_OFFSET_{POINT, LINE, FILL}
Vertex Aributes [11.1.1]
Vertex shaders operate on array of
4-component items numbered from slot 0 to
MAX_VERTEX_ATTRIBS - 1.
void BindAribLocaon(uint program,
uint index, const char *name);
void GetAcveArib(uint program,
uint index, sizei bufSize, sizei *length,
int *size, enum *type, char *name);
int GetAribLocaon(uint program,
const char *name);
Transform Feedback Variables [11.1.2]
void TransformFeedbackVaryings(
uint program, sizei count,
const char * const *varyings,
enum buerMode);
buerMode:
INTERLEAVED_ATTRIBS, SEPARATE_ATTRIBS
void GetTransformFeedbackVarying(
uint program, uint index, sizei bufSize,
sizei *length, sizei *size, enum *type,
char *name);
*type returns NONE, FLOAT , FLOAT_VECn,
DOUBLE , DOUBLE_VECn, INT, UNSIGNED_INT,
INT_VECn, UNSIGNED_INT_VECn,
MATnxm, FLOAT_MATnxm, DOUBLE_MATnxm,
FLOAT_MATn, DOUBLE_MATn
Shader Execuon [11.1.3]
void ValidateProgram(uint program);
void ValidateProgramPipeline(uint pipeline);
Tessellaon Prim. Generaon [11.2.2]
void PatchParameterfv(enum pname,
const oat *values);
pname: PATCH_DEFAULT_INNER_LEVEL,
PATCH_DEFAULT_OUTER_LEVEL
Vertex Arrays (cont.)
void VertexArrayAribBinding(uint vaobj,
uint aribindex, uint bindingindex);
void VertexAribPointer(uint index, int size,
enum type, boolean normalized,
sizei stride, const void *pointer);
type: See VertexAribFormat
void VertexAribIPointer(uint index,
int size, enum type, sizei stride,
const void *pointer);
type: See VertexAribIFormat
index: [0, MAX_VERTEX_ATTRIBS - 1]
void VertexAribLPointer(uint index, int size,
enum type, sizei stride, const void*pointer);
type: DOUBLE
void EnableVertexAribArray(uint index);
void EnableVertexArrayArib(uint vaobj,
uint index);
void DisableVertexAribArray(uint index);
void DisableVertexArrayArib(uint vaobj,
uint index);
Vertex Aribute Divisors [10.3.4]
void VertexBindingDivisor(uint bindingindex,
uint divisor);
void VertexArrayBindingDivisor(uint vaobj,
uint bindingindex, uint divisor);
void VertexAribDivisor(uint index,
uint divisor);
Primive Restart [10.3.6]
Enable/Disable/IsEnabled(target);
target: PRIMITIVE_RESTART[_FIXED_INDEX]
void PrimiveRestartIndex(uint index);
Drawing Commands [10.4]
For all the funcons in this secon:
mode: POINTS, PATCHES,
LINE_STRIP, LINE_LOOP,
TRIANGLE_STRIP, TRIANGLE_FAN,
LINES, LINES_ADJACENCY,
TRIANGLES, TRIANGLES_ADJACENCY,
LINE_STRIP_ADJACENCY,
TRIANGLE_STRIP_ADJACENCY
type: UNSIGNED_{BYTE, SHORT, INT}
void DrawArrays(enum mode, int rst,
sizei count);
void DrawArraysInstancedBaseInstance(
enum mode, int rst, sizei count,
sizei instancecount, uint baseinstance);
void DrawArraysInstanced(enum mode,
int rst, sizei count, sizei instancecount);
void DrawArraysIndirect(enum mode,
const void *indirect);
void MulDrawArrays(enum mode,
const int *rst, const sizei *count,
sizei drawcount);
void MulDrawArraysIndirect(enum mode,
const void *indirect, sizei drawcount,
sizei stride);
void DrawElements(enum mode, sizei count,
enum type, const void *indices);
void DrawElementsInstancedBaseInstance(
enum mode, sizei count, enum type,
const void *indices, sizei instancecount,
uint baseinstance);
void DrawElementsInstanced(enum mode,
sizei count, enum type, const void *indices,
sizei instancecount);
void MulDrawElements(enum mode,
const sizei *count, enum type,
const void * const *indices,
sizei drawcount);
void DrawRangeElements(enum mode,
uint start, uint end, sizei count,
enum type, const void *indices);
void DrawElementsBaseVertex(enum mode,
sizei count, enum type, const void *indices,
int basevertex);
void DrawRangeElementsBaseVertex(
enum mode, uint start, uint end,
sizei count, enum type, const void *indices,
int basevertex);
void DrawElementsInstancedBaseVertex(
enum mode, sizei count, enum type,
const void *indices, sizei instancecount,
int basevertex);
void DrawElementsInstancedBase-
VertexBaseInstance(enum mode,
sizei count, enum type,
const void *indices, sizei instancecount,
int basevertex, uint baseinstance);
void DrawElementsIndirect(enum mode,
enum type, const void *indirect);
void MulDrawElementsIndirect(
enum mode, enum type,
const void *indirect, sizei drawcount,
sizei stride);
void MulDrawElementsBaseVertex(
enum mode, const sizei *count,
enum type, const void *const *indices,
sizei drawcount, const int *basevertex);
Vertex Array Queries [10.5]
void GetVertexArrayiv(uint vaobj,
enum pname, int *param);
pname: ELEMENT_ARRAY_BUFFER_BINDING
void GetVertexArrayIndexdiv(uint vaobj,
uint index, enum pname, int *param);
pname: VERTEX_ATTRIB_RELATIVE_OFFSET or
VERTEX_ATTRIB_ARRAY_X where X is one of
ENABLED, SIZE, STRIDE, TYPE, NORMALIZED,
INTEGER, LONG, DIVISOR
void GetVertexArrayIndexd64iv(uint vaobj,
uint index, enum pname, int64 *param);
pname: VERTEX_BINDING_OFFSET
void GetVertexArib{d f i}v(uint index,
enum pname, T *params);
pname: See GetVertexArrayIndexediv plus
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING,
VERTEX_ATTRIB_BINDING,
CURRENT_VERTEX_ATTRIB
void GetVertexAribI{i ui}v(uint index,
enum pname, T *params);
pname: See GetVertexArib{d f i}v
void GetVertexAribLdv(uint index,
enum pname, double *params);
pname: See GetVertexArib{d f i}v
void GetVertexAribPointerv(uint index,
enum pname, const void **pointer);
pname: VERTEX_ATTRIB_ARRAY_POINTER
Condional Rendering [10.9]
void BeginCondionalRender(uint id,
enum mode);
mode: QUERY _[NO_]WAIT[_INVERTED],
QUERY_BY_REGION_[NO_]WAIT[_INVERTED]
void EndCondionalRender(void);
Fragment Shaders
[15.2]
void BindFragDataLocaonIndexed(
uint program, uint colorNumber,
uint index, const char *name);
void BindFragDataLocaon(uint program,
uint colorNumber, const char *name);
int GetFragDataLocaon(uint program,
const char *name);
int GetFragDataIndex(uint program,
const char *name);
Compute Shaders
[
19
]
void DispatchCompute(uint num_groups_x,
uint num_groups_y, uint num_groups_z);
void DispatchComputeIndirect(
intptr indirect);
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 6 OpenGL 4.5 API Reference Card
Per-Fragment Operaons
Scissor Test [17.3.2]
Enable/Disable/IsEnabled(SCISSOR_TEST);
Enablei/Disablei/IsEnabledi(SCISSOR_TEST,
uint index);
void ScissorArrayv(uint rst, sizei count,
const int *v);
void ScissorIndexed(uint index, int le,
int boom, sizei width, sizei height);
void ScissorIndexedv(uint index, int *v);
void Scissor(int le, int boom, sizei width,
sizei height);
Mulsample Fragment Ops. [17.3.3]
Enable/Disable/IsEnabled(target);
target: SAMPLE_ALPHA_TO_{COVERAGE, ONE},
SAMPLE_COVERAGE, SAMPLE_MASK
void SampleCoverage(oat value,
boolean invert);
void SampleMaski(uint maskNumber,
biield mask);
Stencil Test [17.3.5]
Enable/Disable/IsEnabled(STENCIL_TEST);
void StencilFunc(enum func, int ref,
uint mask);
func: NEVER, ALWAYS, LESS, GREATER, EQUAL,
LEQUAL, GEQUAL, NOTEQUAL
void StencilFuncSeparate(enum face,
enum func, int ref, uint mask);
func: See StencilFunc
void StencilOp(enum sfail, enum dpfail,
enum dppass);
void StencilOpSeparate(enum face,
enum sfail, enum dpfail, enum dppass);
face: FRONT, BACK, FRONT_AND_BACK
sfail, dpfail, dppass: KEEP, ZERO, REPLACE, INCR,
DECR, INVERT, INCR_WRAP, DECR_WRAP
Depth Buer Test [17.3.6]
Enable/Disable/IsEnabled(DEPTH_TEST);
void DepthFunc(enum func);
func: See StencilFunc
Occlusion Queries [17.3.7]
BeginQuery(enum target, uint id);
EndQuery(enum target);
target: SAMPLES_PASSED, ANY_SAMPLES_PASSED,
ANY_SAMPLES_PASSED_CONSERVATIVE
Blending [17.3.8]
Enable/Disable/IsEnabled(BLEND);
Enablei/Disablei/IsEnabledi(BLEND,
uint index);
void BlendEquaon(enum mode);
void BlendEquaonSeparate(enum modeRGB,
enum modeAlpha);
modeRGB, modeAlpha: MIN, MAX ,
FUNC_{ADD, SUBTRACT, REVERSE_SUBTRACT}
void BlendEquaoni(uint buf, enum mode);
void BlendEquaonSeparatei(uint buf,
enum modeRGB, enum modeAlpha);
modeRGB, modeAlpha:
See BlendEquaonSeparate
void BlendFunc(enum src, enum dst);
src, dst: See BlendFuncSeparate
void BlendFuncSeparate(enum srcRGB,
enum dstRGB, enum srcAlpha,
enum dstAlpha);
srcRGB, dstRGB, srcAlpha, dstAlpha:
ZERO, ONE, SRC_ALPHA_SATURATE,
{SRC, SRC1, DST, CONSTANT}_{COLOR, ALPHA},
ONE_MINUS_{SRC, SRC1}_{COLOR, ALPHA},
ONE_MINUS_{DST, CONSTANT}_{COLOR, ALPHA}
void BlendFunci(uint buf, enum src, enum dst);
src, dst: See BlendFuncSeparate
void BlendFuncSeparatei(uint buf,
enum srcRGB, enum dstRGB,
enum srcAlpha, enum dstAlpha);
dstRGB, dstAlpha, srcRGB, srcAlpha:
See BlendFuncSeparate
void BlendColor(oat red, oat green, oat blue,
oat alpha);
Dithering [17.3.10]
Enable/Disable/IsEnabled(DITHER);
Logical Operaon [17.3.11]
Enable/Disable/IsEnabled(COLOR_LOGIC_OP);
void LogicOp(enum op);
op: CLEAR, AND, AND_REVERSE, COPY, AND_INVERTED,
NOOP, XOR, OR, NOR, EQUIV, INVERT, OR_REVERSE,
COPY_INVERTED, OR_INVERTED, NAND, SET
Debug Output [20]
Enable/Disable/IsEnabled(DEBUG_OUTPUT);
Debug Message Callback [20.2]
void DebugMessageCallback(
DEBUGPROC callback,
const void *userParam);
callback: has the following prototype:
void callback(enum source, enum type,
uint id, enum severity, sizei length,
const char *message,
const void*userParam);
source: DEBUG_SOURCE_X where X may be API,
SHADER_COMPILER, WINDOW_SYSTEM,
THIRD_PARTY, APPLICATION, OTHER
type: DEBUG_TYPE_X where X may be ERROR,
MARKER, OTHER, DEPRECATED_BEHAVIOR,
UNDEFINED_BEHAVIOR, PERFORMANCE,
PORTABILITY, {PUSH, POP}_GROUP
severity: DEBUG_SEVERITY_{HIGH, MEDIUM},
DEBUG_SEVERITY_{LOW, NOTIFICATION}
Controlling Debug Messages [20.4]
void DebugMessageControl(enum source,
enum type, enum severity, sizei count,
const uint *ids, boolean enabled);
source, type, severity: See DebuckMessageCallback
(above), plus DONT_CARE
Externally Generated Messages [20.5]
void DebugMessageInsert(enum source,
enum type, uint id, enum severity,
int length, const char *buf);
source:
DEBUG_SOURCE_{APPLICATION, THIRD_PARTY}
type, severity: See DebugMessageCallback
Debug Groups [20.6]
void PushDebugGroup(enum source,
uint id, sizei length, const char *message);
source: See DebugMessageInsert
void PopDebugGroup(void);
Debug Labels [20.7]
void ObjectLabel(enum idener, uint name,
sizei length, const char *label);
idener: BUFFER, FRAMEBUFFER, RENDERBUFFER,
PROGRAM_PIPELINE, PROGRAM,
QUERY, SAMPLER, SHADER, TEXTURE,
TRANSFORM_FEEDBACK, VERTEX_ARRAY
void ObjectPtrLabel(void* ptr, sizei length,
const char *label);
Synchronous Debug Output [20.8]
Enable/Disable/IsEnabled(
DEBUG_OUTPUT_SYNCHRONOUS);
Debug Output Queries [20.9]
uint GetDebugMessageLog(uint count,
sizei bufSize, enum *sources, enum *types,
uint *ids, enum *severies, sizei *lengths,
char *messageLog);
void GetObjectLabel(enum idener,
uint name, sizei bufSize, sizei *length,
char *label);
void GetObjectPtrLabel(void* ptr, sizei bufSize,
sizei *length, char *label);
Hints
[
21.5
]
void Hint(enum target, enum hint);
target: FRAGMENT_SHADER_DERIVATIVE_HINT,
TEXTURE_COMPRESSION_HINT,
{LINE, POLYGON}_SMOOTH_HINT
hint: FASTEST, NICEST, DONT_CARE
State and State Requests
A complete list of symbolic constants for states is
shown in the tables in [23].
Simple Queries [22.1]
void GetBooleanv(enum pname, boolean *data);
void GetIntegerv(enum pname, int *data);
void GetInteger64v(enum pname, int64 *data);
void GetFloatv(enum pname, oat *data);
void GetDoublev(enum pname, double *data);
void GetDoublei_v(enum target, uint index,
double *data);
void GetBooleani_v(enum target, uint index,
boolean *data);
void GetIntegeri_v(enum target, uint index,
int *data);
void GetFloa_v(enum target, uint index,
oat *data);
void GetInteger64i_v(enum target, uint index,
int64 *data);
boolean IsEnabled(enum cap);
boolean IsEnabledi(enum target, uint index);
String Queries [22.2]
void GetPointerv(enum pname, void **params);
ubyte *GetString(enum name);
name: RENDERER, VENDOR, VERSION,
SHADING_LANGUAGE_VERSION
(Connued on next page)
Whole Framebuer
Selecng Buers for Wring [17.4.1]
void DrawBuer(enum buf);
buf:
[Tables 1
7.4-5] NONE,
{FRONT, BACK}_{LEFT, RIGHT}, FRONT, BACK, LEFT,
RIGHT, FRONT_AND_BACK,
COLOR_ATTACHMENTi (i = [0,
MAX_COLOR_ATTACHMENTS - 1 ])
void NamedFramebuerDrawBuer(
uint framebuer, enum buf);
buf: See DrawBuer
void DrawBuers(sizei n, const enum *bufs);
*bufs: [Tables 17.5-6] {FRONT, BACK}_{LEFT, RIGHT},
NONE, COLOR_ATTACHMENTi (i = [0,
MAX_COLOR_ATTACHMENTS - 1 ])
void NamedFramebuerDrawBuers(
uint framebuer, sizei n,
const enum
*bufs);
*bufs: See DrawBuers
Fine Control of Buer Updates [17.4.2]
void ColorMask(boolean r, boolean g,
boolean b, boolean a);
void ColorMaski(uint buf, boolean r,
boolean g, boolean b, boolean a);
void DepthMask(boolean mask);
void StencilMask(uint mask);
void StencilMaskSeparate(enum face,
uint mask);
face: FRONT, BACK, FRONT_AND_BACK
Clearing the Buers [17.4.3]
void Clear(biield buf);
buf: 0 or the OR of
{COLOR, DEPTH, STENCIL}_BUFFER_BIT
void ClearColor(oat r, oat g, oat b, oat a);
void ClearDepth(double d);
void ClearDepthf(oat d);
void ClearStencil(int s);
void ClearBuer{i f ui}v(enum buer,
int drawbuer, const T *value);
buer: COLOR, DEPTH, STENCIL
void ClearNamedFramebuer{i f ui}v(
uint framebuer, enum buer,
int drawbuer, const T *value);
buer: See ClearBuer{i f ui}v
void ClearBuer(enum buer,
int drawbuer, oat depth, int stencil);
buer: DEPTH_STENCIL
void ClearNamedFramebuer(
uint framebuer, enum buer,
int drawbuer, oat depth, int stencil);
buer: See ClearBueri
Invalidang Framebuers [17.4.4]
void InvalidateSubFramebuer(
enum target, sizei numAachments,
const enum *aachments, int x, int y,
sizei width, sizei height);
target: [DRAW_ , READ_]FRAMEBUFFER
aachments: COLOR_ATTACHMENTi, DEPTH, COLOR,
{DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT,
{FRONT, BACK}_{LEFT, RIGHT}, STENCIL
void InvalidateNamedFramebuerSubData(
uint framebuer, sizei numAachments,
const enum *aachments, int x, int y,
sizei width, sizei height);
aachments: See InvalidateSubFramebuer
void InvalidateFramebuer(
enumtarget, sizei numAachments,
const enum *aachments);
target, *aachments: See InvalidateSubFramebuer
void InvalidateNamedFramebuerData(
uint framebuer, sizei numAachments,
const enum *aachments);
*aachments: See InvalidateSubFramebuer
Reading and Copying Pixels
Reading Pixels [18.2]
void ReadBuer(enum src);
src: NONE, {FRONT, BACK}_{LEFT, RIGHT},
FRONT, BACK, LEFT, RIGHT,
FRONT_AND_BACK, COLOR_ATTACHMENTi
(i = [0, MAX_COLOR_ATTACHMENTS - 1 ])
void NamedFramebuerReadBuer(
uint framebuer, enum src);
src: See ReadBuer
void ReadPixels(int x, int y, sizei width,
sizei height, enum format, enum type,
void *data);
format: STENCIL_INDEX, RED, GREEN, BLUE,
RG, RGB, RGBA, BGR, DEPTH_{COMPONENT,
STENCIL}, {RED, GREEN, BLUE, RG, RGB}_
INTEGER, {RGBA, BGR, BGRA}_INTEGER,
BGRA [Table 8.3]
type: [HALF_]FLOAT, [UNSIGNED_]BYTE,
[UNSIGNED_]SHORT, [UNSIGNED_]INT,
FLOAT_32_UNSIGNED_INT_24_8_REV,
UNSIGNED_{BYTE, SHORT, INT}_*
values in [Table 8.2]
void ReadnPixels(int x, int y, sizei width,
sizei height, enum format, enum type,
sizei bufSize, void *data);
format, type: See ReadPixels
Final Conversion [18.2.8]
void ClampColor(enum target, enum clamp);
target: CLAMP_READ_COLOR
clamp: TRUE, FALSE, FIXED_ONLY
Copying Pixels [18.3]
void BlitFramebuer(int srcX0, int srcY0,
int srcX1, int srcY1, int dstX0, int dstY0,
int dstX1, int dstY1, biield mask,
enum lter);
mask: Bitwise 0 of the bitwise OR of
{COLOR, DEPTH, STENCIL}_BUFFER_BIT
lter: LINEAR, NEAREST
void BlitNamedFramebuer(
uint readFramebuer,
uint drawFramebuer, int srcX0,
int srcY0, int srcX1, int srcY1, int dstX0,
int dstY0, int dstX1, int dstY1,
biield mask, enum lter);
mask, lter: See BlitFramebuer
void CopyImageSubData(uint srcName,
enum srcTarget, int srcLevel, int srcX,
int srcY, int srcZ, uint dstName,
enum dstTarget, int dstLevel, int dstX,
int dstY, int dstZ, sizei srcWidth,
sizei srcHeight, sizei srcDepth);
srcTarget, dstTarget: See target for BindTexture in
secon [8.1] on this card, plus
GL_RENDERTARGET
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL 4.5 API Reference Card Page 7
OpenGL Texture Views and Texture Object State
T
Texture state set with TextureView()
enum internalformat // base internal format
enum target // texture target
uint minlevel // rst level of mipmap
uint numlevels // number of mipmap levels
uint minlayer // rst layer of array texture
uint numlayers // number of layers in array
Texture View Parameters (immutable)
<target>
TEXTURE_INTERNAL_FORMAT TEXTURE_SHARED_SIZE
TEXTURE_VIEW_{MIN,NUM}_LEVEL TEXTURE_VIEW_{MIN,NUM}_LAYER
TEXTURE_IMMUTABLE_LEVELS IMAGE_FORMAT_COMPATIBILITY_TYPE
TEXTURE_{RED,GREEN,BLUE,ALPHA,DEPTH}_TYPE
TEXTURE_{RED,GREEN,BLUE,ALPHA,DEPTH,STENCIL}_SIZE
Texture Parameters (immutable)
TEXTURE_WIDTH TEXTURE_HEIGHT
TEXTURE_DEPTH TEXTURE_FIXED_SAMPLE_LOCATIONS
TEXTURE_COMPRESSED TEXTURE_COMPRESSED_IMAGE_SIZE
TEXTURE_IMMUTABLE_FORMAT TEXTURE_SAMPLES
Texture Parameters (mutable)
TEXTURE_SWIZZLE_{R,G,B,A} TEXTURE_MAX_LEVEL
TEXTURE_BASE_LEVEL DEPTH_STENCIL_TEXTURE_MODE
Sampler Parameters (mutable)
TEXTURE_BORDER_COLOR
TEXTURE_COMPARE_{FUNC,MODE}
TEXTURE_LOD_BIAS
TEXTURE_{MAX,MIN}_LOD
TEXTURE_{MAG,MIN}_FILTER
TEXTURE_WRAP_{S,T,R}
OpenGL Compute Programming Model and Compute Memory Hierarchy
Use the barrier funcon to synchronize invocaons in a work group:
void barrier();
Use the memoryBarrier* or groupMemoryBarrier funcons to order
reads/writes accessible to other invocaons:
void memoryBarrier();
void memoryBarrierAtomicCounter();
void memoryBarrierBuffer();
void memoryBarrierImage();
void memoryBarrierShared(); // Only for compute shaders
void groupMemoryBarrier(); // Only for compute shaders
Use the compute shader built-in variables to speciy work groups and invocaons:
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)
gl_WorkGroupSize = (4,2,0)
gl_WorkGroupID = (2,0,0)
gl_LocalInvocationID = (1,0,0)
gl_GlobalInvocationID = (9,3,0)
gl_NumWorkGroups = (4,2,0)
States (cont.)
ubyte *GetStringi(enum name, uint index);
name: EXTENSIONS, SHADING_LANGUAGE_VERSION
index:
[0, NUM_EXTENSIONS - 1] (if name is EXTENSIONS);
[0, NUM_SHADING_LANGUAGE_VERSIONS-1]
(if name is SHADING_LANGUAGE_VERSION)
Internal Format Queries [22.3]
void GetInternalformav(enum target,
enum internalformat, enum pname,
sizei bufSize, int *params);
target, pname, internalformat:
See GetInternalforma64v
void GetInternalforma64v(enum target,
enum internalformat, enum pname,
sizei bufSize, int64 *params);
target:
[Table 22.2]
TEXTURE_{1D, 2D, 3D, CUBE_MAP}[_ARRAY],
TEXTURE_2D_MULTISAMPLE[_ARRAY],
TEXTURE_{BUFFER, RECTANGLE}, RENDERBUFFER
internalformat: any value
pname:
CLEAR_{BUFFER, TEXTURE},
COLOR_ENCODING,
COLOR_{COMPONENTS, RENDERABLE},
COMPUTE_TEXTURE,
DEPTH_{COMPONENTS, RENDERABLE},
FILTER, FRAMEBUFFER_BLEND,
FRAMEBUFFER_RENDERABLE[_LAYERED],
{FRAGMENT, GEOMETRY}_TEXTURE,
GET_TEXTURE_IMAGE_FORMAT,
GET_TEXTURE_IMAGE_TYPE,
IMAGE_COMPATIBILITY_CLASS,
IMAGE_PIXEL_{FORMAT, TYPE},
IMAGE_FORMAT_COMPATIBILITY_TYPE
,
IMAGE_TEXEL_SIZE
,
INTERNALFORMAT_{PREFERRED, SUPPORTED},
INTERNALFORMAT_{RED, GREEN, BLUE}_SIZE,
INTERNALFORMAT_{DEPTH, STENCIL}_SIZE,
INTERNALFORMAT_{ALPHA, SHARED}_SIZE,
INTERNALFORMAT_{RED, GREEN}_TYPE,
INTERNALFORMAT_{BLUE, ALPHA}_TYPE,
INTERNALFORMAT_{DEPTH, STENCIL}_TYPE,
[MANUAL_GENERATE_]MIPMAP,
MAX_COMBINED_DIMENSIONS,
MAX_{WIDTH, HEIGHT, DEPTH, LAYERS},
NUM_SAMPLE_COUNTS,
READ_PIXELS[_FORMAT, _TYPE],
SAMPLES, SHADER_IMAGE_ATOMIC,
SHADER_IMAGE_{LOAD, STORE},
SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST,
SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE,
SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST,
SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE,
SRGB_{READ, WRITE},
STENCIL_{COMPONENTS, RENDERABLE},
TESS_{CONTROL, EVALUATION}_TEXTURE,
TEXTURE_COMPRESSED[_BLOCK_SIZE],
TEXTURE_COMPRESSED_BLOCK_{HEIGHT
, WIDTH}
TEXTURE_GATHER[_SHADOW],
TEXTURE_IMAGE_FORMAT,
TEXTURE_IMAGE_TYPE,
TEXTURE_{SHADOW, VIEW},
VERTEX_TEXTURE,
VIEW_COMPATIBILITY_CLASS
TransformFeedback Queries [22.4]
void GetTransformFeedbackiv(uint x,
enum pname, int *param);
pname: TRANSFORM_FEEDBACK_{PAUSED, ACTIVE}
void GetTransformFeedbacki_v(uint x,
enum pname, uint index, int *param);
pname: TRANSFORM_FEEDBACK_BUFFER_BINDING
void GetTransformFeedbacki64_v(uint x,
enum pname, uint index, int64 *param);
pname: TRANSFORM_FEEDBACK_BUFFER_START,
TRANSFORM_FEEDBACK_BUFFER_SIZE
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 8 OpenGL 4.5 API Reference Card
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 8 OpenGL 4.5 API Reference Card
OpenGL Pipeline
A typical program that uses OpenGL
begins with calls to open a window into
the framebuer 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 illustraon
show the OpenGL pipeline and indicate
data ow.
Blue blocks indicate various buers
that feed or get fed by the OpenGL
pipeline.
Green blocks indicate xed funcon
stages.
Yellow blocks indicate programmable
stages.
Texture binding
Buer binding
T
B
Vertex & Tessellaon Details
Each vertex is processed either by a vertex shader
or xed-funcon vertex processing (compability
only) to generate a transformed vertex, then
assembled into primives. Tessellaon (if enabled)
operates on patch primives, consisng of a xed-
size collecon of verces, each with per-vertex
aributes and associated per-patch aributes.
Tessellaon control shaders (if enabled) transform
an input patch and compute per-vertex and per-
patch aributes for a new output patch.
A xed-funcon primive generator
subdivides the patch according to
tessellaon levels computed in the
tessellaon control shaders or specied
as xed values in the API (TCS disabled).
The tessellaon evaluaon shader
computes the posion and aributes of
each vertex produced by the tessellator.
Orange blocks indicate features of the Core
specicaon.
Purple blocks indicate features of the
Compability specicaon.
Green blocks indicate features new or
signicantly changed with OpenGL 4.x.
Geometry & Follow-on Details
Geometry shaders (if enabled) consume
individual primives built in previous primive
assembly stages. For each input primive,
the geometry shader can output zero or more
verces, with each vertex directed at a specic
vertex stream. The verces emied to each
stream are assembled into primives according
to the geometry shader’s output primive type.
Transform feedback (if acve) writes selected
vertex aributes of the primives of all vertex
streams into buer objects aached to one or
more binding points.
Primives on vertex stream zero are then
processed by xed-funcon stages, where they
are clipped and prepared for rasterizaon.
Orange blocks indicate features of the Core
specicaon.
Purple blocks indicate features of the
Compability specicaon.
Green blocks indicate features new or
signicantly changed with OpenGL 4.x.
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL Shading Language 4.50 Reference Card Page 9
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
Types
[4.1]
Transparent Types
void no funcon return value
bool Boolean
int, uint signed/unsigned integers
oat single-precision oang-point
scalar
double double-precision oang scalar
vec2, vec3, vec4 oang point vector
dvec2, dvec3, dvec4 double precision oang-point
vectors
bvec2, bvec3, bvec4 Boolean vectors
ivec2, ivec3, ivec4
uvec2, uvec3, uvec4
signed and unsigned integer
vectors
mat2, mat3, mat4 2x2, 3x3, 4x4 oat matrix
mat2x2, mat2x3,
mat2x4
2-column oat matrix of
2, 3, or 4 rows
mat3x2, mat3x3,
mat3x4
3-column oat matrix of
2, 3, or 4 rows
mat4x2, mat4x3,
mat4x4
4-column oat matrix of
2, 3, or 4 rows
dmat2, dmat3,
dmat4
2x2, 3x3, 4x4 double-precision
oat matrix
dmat2x2, dmat2x3,
dmat2x4
2-col. double-precision oat
matrix of 2, 3, 4 rows
dmat3x2, dmat3x3,
dmat3x4
3-col. double-precision oat
matrix of 2, 3, 4 rows
dmat4x2, dmat4x3,
dmat4x4
4-column double-precision oat
matrix of 2, 3, 4 rows
Floang-Point Opaque Types
sampler{1D,2D,3D}
image{1D,2D,3D}
1D, 2D, or 3D texture
samplerCube
imageCube
cube mapped texture
sampler2DRect
image2DRect
rectangular texture
sampler{1D,2D}Array
image{1D,2D}Array
1D or 2D array texture
samplerBuer
imageBuer
buer texture
sampler2DMS
image2DMS
2D mul-sample texture
sampler2DMSArray
image2DMSArray
2D mul-sample array
texture
samplerCubeArray
imageCubeArray
cube map array texture
sampler1DShadow
sampler2DShadow
1D or 2D depth texture
with comparison
sampler2DRectShadow rectangular tex. / compare
sampler1DArrayShadow
sampler2DArrayShadow
1D or 2D array depth
texture with comparison
samplerCubeShadow
cube map depth texture
with comparison
samplerCubeArrayShadow
cube map array depth
texture with comparison
Signed Integer Opaque Types
isampler[1,2,3]D integer 1D, 2D, or 3D texture
iimage[1,2,3]D integer 1D, 2D, or 3D image
isamplerCube integer cube mapped texture
iimageCube integer cube mapped image
isampler2DRect
int.
2D rectangular texture
Connue
Signed Integer Opaque Types (cont’d)
iimage2DRect
int.
2D rectangular image
isampler[1,2]DArray integer 1D, 2D array texture
iimage[1,2]DArray integer 1D, 2D array image
isamplerBuer integer buer texture
iimageBuer integer buer image
isampler2DMS
int. 2D mul-sample texture
iimage2DMS
int. 2D mul-sample image
isampler2DMSArray
int. 2D mul-sample array tex.
iimage2DMSArray
int. 2D mul-sample array image
isamplerCubeArray
int.
cube map array texture
iimageCubeArray
int.
cube map array image
Unsigned Integer Opaque Types
atomic_uint
uint atomic counter
usampler[1,2,3]D
uint 1D, 2D, or 3D texture
uimage[1,2,3]D
uint 1D, 2D, or 3D image
usamplerCube
uint cube mapped texture
uimageCube
uint cube mapped image
usampler2DRect
uint rectangular texture
uimage2DRect
uint rectangular image
usampler[1,2]DArray
1D or 2D array texture
uimage[1,2]DArray
1D or 2D array image
usamplerBuer
uint buer texture
uimageBuer
uint buer image
usampler2DMS
uint 2D mul-sample texture
uimage2DMS
uint 2D mul-sample image
usampler2DMSArray
uint 2D mul-sample array tex.
Connue
Unsigned Integer Opaque Types (cont’d)
uimage2DMSArray
uint 2D mul-sample array image
usamplerCubeArray
uint cube map array texture
uimageCubeArray
uint cube map array image
Implicit Conversions
int -> uint uvec2 -> dvec2
int, uint -> oat uvec3 -> dvec3
int, uint, oat
-> double uvec4 -> dvec4
ivec2 -> uvec2 vec2 -> dvec2
ivec3 -> uvec3 vec3 -> dvec3
ivec4 -> uvec4 vec4 -> dvec4
ivec2 -> vec2 mat2 -> dmat2
ivec3 -> vec3 mat3 -> dmat3
ivec4 -> vec4 mat4 -> dmat4
uvec2 -> vec2 mat2x3 -> dmat2x3
uvec3 -> vec3 mat2x4 -> dmat2x4
uvec4 -> vec4 mat3x2 -> dmat3x2
ivec2 -> dvec2 mat3x4 -> dmat3x4
ivec3 -> dvec3 mat4x2 -> dmat4x2
ivec4 -> dvec4 mat4x3 -> dmat4x4
Aggregaon of Basic Types
Arrays oat[3] foo; oat foo[3]; int a [3][2];
// Structures, blocks, and structure members
// can be arrays. Arrays of arrays supported.
Structures struct type-name {
members
} struct-name[];
// oponal variable declaraon
Blocks in/out/uniform block-name {
// interface matching by block name
oponally-qualied members
} instance-name[];
// oponal instance name, oponally an array
Qualiers
Storage Qualiers [4.3]
Declaraons may have one storage qualier.
none
(default) local read/write memory,
or input parameter
const
read-only variable
in
linkage into shader from previous stage
out
linkage out of a shader to next stage
uniform
linkage between a shader, OpenGL,
and the applicaon
buer
accessible by shaders and OpenGL API
shared
compute shader only, shared among work
items in a local work group
Auxiliary Storage Qualiers
Use to qualify some input and output variables:
centroid
centroid-based interpolaon
sampler
per-sample interpolaon
patch
per-tessellaon-patch aributes
Interface Blocks [4.3.9]
in, out, uniform, and buer variable
declaraons can be grouped. For example:
uniform Transform {
// allowed restatement qualier:
mat4 ModelViewMatrix;
uniform mat3 NormalMatrix;
};
Layout Qualiers [4.4]
The following table summarizes the use of layout qualiers applied to non-opaque types and the kinds of declaraons they may be applied to.
Op = Opaque types only, FC = gl_FragCoord only, FD = gl_FragDepth only.
Layout Qualier
Qualif.
Only Indiv.
Va r. Block Block
Mem.
Allowed Interfaces
shared, packed, std{140, 430}
X X
uniform/buer
{row, column}_major
X X X
binding =
Op
X
oset =
X
align =
X X
locaon =
Xuniform/buer and
subroune variables
locaon =
X X X all in/out, except for
compute
component =
X X
index =
Xfragment out and
subroune funcons
triangles, quads, isolines
X
tessellaon evaluaon
in
equal_spacing,
fraconal_even_spacing,
fraconal_odd_spacing
X
cw, ccw
X
point_mode
X
points
Xgeometry in/out
[ points ], lines, triangles,
{triangles, lines}_adjacency
Xgeometry in
invocaons =
Xgeometry in
Layout Qualier
Qualif.
Only Indiv.
Va r. Block Block
Mem.
Allowed Interfaces
origin_upper_le
pixel_center_integer
FC fragment in
early_fragment_tests
X
local_size_{x, y, z} =Xcompute in
x_{buer, stride} =
X X X X vertex, tessellaon, and
geometry out
x_oset =
X X X
verces =
Xtessellaon control out
[ points ], line_strip,
triangle_strip
X
geometry out
max_verces =
X
stream =
X X X X
depth_{any, greater,
less, unchanged}
FD
fragment out
Opaque Uniform Layout Qualiers [4.4.6]
Used to bind opaque uniform variables to specic buers or units.
binding = integer-constant-expression
Atomic Counter Layout Qualiers
binding = integer-constant-expression
oset = integer-constant-expression
(Connued on next page)
The OpenGL® Shading Language is used to create
shaders for each of the programmable processors
contained in the OpenGL processing pipeline. The
OpenGL Shading Language is actually several closely
related languages. Currently, these processors are the
vertex, tessellaon control, tessellaon evaluaon,
geometry, fragment, and compute shaders.
[n.n.n] and [Table n.n] refer to secons and tables in
the OpenGL Shading Language 4.50 specicaon at
www.opengl.org/registry
Operators and Expressions
[5.1]
The following operators are numbered in order
of precedence. Relaonal and equality operators
evaluate to Boolean. Also See lessThan(), equal().
1. ( )
parenthecal grouping
2.
[ ]
( )
.
++ --
array subscript
funcon call, constructor, structure
eld, selector, swizzle
posix increment and decrement
3. ++ --
+ - ~ !
prex increment and decrement
unary
4 . * / %
mulplicave
5. + -
addive
6. << >>
bit-wise shi
7. < > <= >=
relaonal
8. == !=
equality
9. &
bit-wise and
10. ^
bit-wise exclusive or
11. |
bit-wise inclusive or
12. &&
logical and
13. ^^
logical exclusive or
14. | |
logical inclusive or
15. ? :
selects an enre operand
16.
= += -=
*= /=
%= <<= >>=
&= ^= |=
assignment
arithmec assignments
17. ,
sequence
Vector & Scalar Components [5.5]
In addion to array numeric subscript syntax,
names of vector and scalar components are
denoted by a single leer. Components can be
swizzled and replicated. Scalars have only an x, r,
or s component.
{x, y, z, w} Points or normals
{r, g, b, a} Colors
{s, t, p, q} Texture coordinates
Preprocessor
[3.3]
Preprocessor Operators
#version 450
#version 450 prole
Required when using version 4.50.
prole is core, compability, or es (for
ES versions 1.00, 3.00, or 3.10).
#extension
extension_name :
behavior
#extension all : behavior
• behavior: require, enable, warn,
disable
• extension_name: extension
supported by compiler, or “all”
Preprocessor Direcves
##dene #elif #else #endif #error #extension
#if #ifdef #ifndef #line #pragma #undef #version
Predened Macros
__LINE__ __FILE__
Decimal integer constants.
__FILE__
says
which source string is being processed.
__VERSION__
Decimal integer, e.g.: 450
GL_core_prole
Dened as 1
GL_es_prole
1 if the ES prole is supported
GL_compability_prole
Dened as 1 if the implementaon
supports the compability prole.
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 10 OpenGL Shading Language 4.50 Reference Card
Operaons and Constructors
Vector & Matrix [5.4.2]
.length() for matrices returns number of columns
.length() for vectors returns number of components
mat2(vec2, vec2); // 1 col./arg.
mat2x3(vec2, oat, vec2, oat); // col. 2
dmat2(dvec2, dvec2); // 1 col./arg.
dmat3(dvec3, dvec3, dvec3); // 1 col./arg.
Structure Example [5.4.3]
.length() for structures returns number of members
struct light {members; };
light lightVar = light(3.0, vec3(1.0, 2.0, 3.0));
Matrix Examples [5.6]
Examples of access components of a matrix with
array subscripng syntax:
mat4 m; // m is a matrix
m[1] = vec4(2.0);
// sets 2nd col. to all 2.0
m[0][0] = 1.0;
// sets upper le element to 1.0
m[2][3] = 2.0;
// sets 4th element of 3rd col. to 2.0
Examples of operaons on matrices and vectors:
m = f * m;
// scalar * matrix component-wise
v = f * v;
// scalar * vector component-wise
v = v * v;
// vector * vector component-wise
m = m +/- m;
// matrix +/- matrix comp.-wise
m = m * m;
// linear algebraic mulply
f = dot(v, v);
// vector dot product
v = cross(v, v);
// vector cross product
Array Example [5.4.4]
const oat c[3];
c.length() // will return the integer 3
Structure & Array Operaons [5.7]
Select structure elds or length() method of an
array using the period (.) operator. Other operators:
.eld or method selector
== != equality
=assignment
[ ] indexing (arrays only)
Array elements are accessed using the array
subscript operator ( [ ] ), e.g.:
diuseColor += lightIntensity[3]*NdotL;
Statements and Structure
Subrounes [6.1.2]
Subroune type variables are assigned to funcons
through the UniformSubrounesuiv command in the
OpenGL API.
Declare types with the subroune keyword:
subroune returnType subrouneTypeName(type0
arg0,
type1 arg1, ..., typen argn);
Associate funcons with subroune types of
matching declaraons by dening the funcons
with the subroune keyword and a list of
subroune types the funcon matches:
subroune(subrouneTypeName0,
...,
subrouneTypeNameN)
returnType
funconName(type0 arg0,
type1 arg1, ..., type
n
arg
n
)
{
... }
// funcon body
Declare subroune type variables with a specic
subroune type in a subroune uniform variable
declaraon:
subroune
uniform subrouneTypeName
subrouneVarName;
Iteraon and Jumps [6.3-4]
Funcon
call by value-return
Iteraon for (;;) { break, connue }
while ( ) { break, connue }
do { break, connue } while ( );
Selecon if ( ) { }
if ( ) { } else { }
switch ( ) { case integer: … break; …
default: … }
Entry void main()
Jump break, connue, return
(There is no ‘goto’)
Exit return in main()
discard
// Fragment shader only
Qualiers (connued)
Format Layout Qualiers
One qualier may be used with variables
declared as “image” to specify the image format.
binding = integer-constant-expression,
rgba{32,16}f, rg{32,16}f, r{32,16}f,
rgba{16,8}, r11f_g11f_b10f, rgb10_a2{ui},
rg{16,8}, r{16,8}, rgba{32,16,8}i, rg{32,16,8}
i, r{32,16,8}i, rgba{32,16,8}ui, rg{32,16,8}ui,
r{32,16,8}ui, rgba{16,8}_snorm,
rg{16,8}_snorm, r{16,8}_snorm
Interpolaon Qualiers [4.5]
Qualify outputs from vertex shader and inputs
to fragment shader.
smooth perspecve correct interpolaon
at no interpolaon
noperspecve linear interpolaon
Parameter Qualiers [4.6]
Input values copied in at funcon call me,
output values copied out at funcon return.
none (default) same as in
in for funcon parameters passed into
funcon
const for funcon parameters that cannot be
wrien to
out for funcon parameters passed back out of
funcon, but not inialized when passed in
inout for funcon parameters passed both into
and out of a funcon
Precision Qualiers [4.7]
Qualify individual variables:
{highp, mediump, lowp} variable-declaraon;
Establish a default precision qualier:
precision {highp, mediump, lowp} {int, oat};
Invariant Qualiers Examples [4.8]
These are for vertex, tessellaon, geometry,
and fragment languages.
#pragma STDGL
invariant(all)
force all output variables
to be invariant
invariant gl_Posion; qualify a previously
declared variable
invariant centroid out
vec3 Color;
qualify as part of a
variable declaraon
Precise Qualier [4.9]
Ensures that operaons are executed in stated
order with operator consistency. For example,
a fused mulply-add cannot be used in the
following; it requires two idencal mulplies,
followed by an add.
precise out vec4 Posion = a * b + c * d;
Memory Qualiers [4.10]
Variables qualied as “image” can have one or
more memory qualiers.
coherent reads and writes are coherent with
other shader invocaons
volale underlying values may be changed by
other sources
restrict won’t be accessed by other code
readonly read only
writeonly write only
Order of Qualicaon [4.11]
When mulple qualiers are present in a
declaraon they may appear in any order, but
must all appear before the type.
The layout qualier is the only qualier that can
appear more than once. Further, a declaraon
can have at most one storage qualier, at most
one auxiliary storage qualier, and at most one
interpolaon qualier.
Mulple memory qualiers can be used. Any
rule violaon will cause a compile-me error.
Built-In Constants [7.3]
The following are provided to all shaders. The
actual values are implementaon-dependent, but
must be at least the value shown.
const ivec3 gl_MaxComputeWorkGroupCount =
{65535, 65535, 65535} ;
const ivec3 gl_MaxComputeWorkGroupSize[] =
{1024, 1024, 64};
const int gl_MaxComputeUniformComponents = 1024;
const int gl_MaxComputeTextureImageUnits = 16;
const int gl_MaxComputeImageUniforms = 8;
const int gl_MaxComputeAtomicCounters = 8;
const int gl_MaxComputeAtomicCounterBuers = 1;
const int gl_MaxVertexAribs = 16;
const int gl_MaxVertexUniformComponents = 1024;
const int gl_MaxVaryingComponents= 60;
const int gl_MaxVertexOutputComponents = 64;
const int gl_MaxGeometryInputComponents = 64;
const int gl_MaxGeometryOutputComponents = 128;
const int gl_MaxFragmentInputComponents = 128;
const int gl_MaxVertexTextureImageUnits = 16;
const int gl_MaxCombinedTextureImageUnits = 80;
const int gl_MaxTextureImageUnits = 16;
const int gl_MaxImageUnits = 8;
gl_MaxCombinedImageUnitsAndFragmentOutputs = 8;
const int gl_MaxImageSamples = 0;
const int gl_MaxVertexImageUniforms= 0;
const int gl_MaxTessControlImageUniforms = 0;
const int gl_MaxTessEvaluaonImageUniforms = 0;
const int gl_MaxGeometryImageUniforms = 0;
const int gl_MaxFragmentImageUniforms = 8;
const int gl_MaxCombinedImageUniforms = 8;
const int gl_MaxFragmentUniformComponents = 1024;
const int gl_MaxDrawBuers = 8;
const int gl_MaxClipDistances = 8;
const int gl_MaxGeometryTextureImageUnits = 16;
const int gl_MaxGeometryOutputVerces = 256;
const int gl_MaxGeometryTotalOutputComponents = 1024;
const int gl_MaxGeometryUniformComponents = 1024;
const int gl_MaxGeometryVaryingComponents = 64;
const int gl_MaxTessControlInputComponents = 128;
const int gl_MaxTessControlOutputComponents = 128;
const int gl_MaxTessControlTextureImageUnits = 16;
const int gl_MaxTessControlUniformComponents = 1024;
const int gl_MaxTessControlTotalOutputComponents = 4096;
const int gl_MaxTessEvaluaonInputComponents = 128;
const int gl_MaxTessEvaluaonOutputComponents = 128;
const int gl_MaxTessEvaluaonTextureImageUnits = 16;
const int gl_MaxTessEvaluaonUniformComponents = 1024;
const int gl_MaxTessPatchComponents = 120;
const int gl_MaxPatchVerces = 32;
const int gl_MaxTessGenLevel = 64;
const int gl_MaxViewports = 16;
const int gl_MaxVertexUniformVectors = 256;
const int gl_MaxFragmentUniformVectors = 256;
const int gl_MaxVaryingVectors = 15;
const int gl_MaxVertexAtomicCounters = 0;
const int gl_MaxTessControlAtomicCounters = 0;
const int gl_MaxTessEvaluaonAtomicCounters = 0;
const int gl_MaxGeometryAtomicCounters = 0;
const int gl_MaxFragmentAtomicCounters = 8;
const int gl_MaxCombinedAtomicCounters = 8;
const int gl_MaxAtomicCounterBindings = 1;
const int gl_MaxVertexAtomicCounterBuers = 0;
const int gl_MaxTessControlAtomicCounterBuers = 0;
const int gl_MaxTessEvaluaonAtomicCounterBuers = 0;
const int gl_MaxGeometryAtomicCounterBuers = 0;
const int gl_MaxFragmentAtomicCounterBuers = 1;
const int gl_MaxCombinedAtomicCounterBuers = 1;
const int gl_MaxAtomicCounterBuerSize = 32;
const int gl_MinProgramTexelOset = -8;
const int gl_MaxProgramTexelOset = 7;
const int gl_MaxTransformFeedbackBuers = 4;
gl_MaxTransformFeedbackInterleavedComponents = 64;
const int gl_MaxCullDistances = 8;
const int gl_MaxCombinedClipAndCullDistances = 8;
const int gl_MaxSamples = 4;
const int gl_MaxVertexImageUniforms = 0;
const int gl_MaxFragmentImageUniforms = 8;
const int gl_MaxComputeImageUniforms = 8;
const int gl_MaxCombinedImageUniforms = 48;
const int gl_MaxCombinedShaderOutputResources = 16;
Built-In Variables [7]
Vertex Language
Inputs
in int gl_VertexID;
in int gl_InstanceID;
Outputs
out gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
};
Tessellaon Control Language
Inputs
in gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_in[gl_MaxPatchVerces];
in
int
gl_PatchVercesIn;
in
int
gl_PrimiveID;
in
int
gl_InvocaonID;
Outputs
out gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_out[];
patch
out
oat
gl_TessLevelOuter[4];
patch
out
oat
gl_TessLevelInner[2];
Tessellaon Evaluaon Language
Inputs
in gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_in[gl_MaxPatchVerces];
in int gl_PatchVercesIn;
in int gl_PrimiveID;
in vec3
gl_TessCoord;
patch in
oat gl_TessLevelOuter[4];
patch in
oat
gl_TessLevelInner[2];
Outputs
out gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
};
Geometry Language
Inputs
in gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_in[];
in int gl_PrimiveIDIn;
in int gl_InvocaonID;
Outputs
out gl_PerVertex {
vec4 gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
};
out
int
gl_PrimiveID;
out
int
gl_Layer;
out
int gl_ViewportIndex;
Fragment Language
Inputs
in
vec4
gl_FragCoord;
in
bool
gl_FrontFacing;
in
oat
gl_ClipDistance[];
in
oat
gl_CullDistance[];
in
vec2
gl_PointCoord;
in
int
gl_PrimiveID;
in
int
gl_SampleID;
in
vec2
gl_SamplePosion;
in
int
gl_SampleMaskIn[];
in
int
gl_Layer;
in
int
gl_ViewportIndex;
in
bool
gl_HelperInvocaon;
Outputs
out
oat
gl_FragDepth;
out
int
gl_SampleMask[];
Compute Language
More informaon in diagram on page 6.
Inputs
Work group dimensions
in uvec3 gl_NumWorkGroups;
const uvec3 gl_WorkGroupSize;
in uvec3 gl_LocalGroupSize;
Work group and invocaon IDs
in uvec3 gl_WorkGroupID;
in uvec3 gl_LocalInvocaonID;
Derived variables
in uvec3 gl_GlobalInvocaonID;
in uint gl_LocalInvocaonIndex;
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL Shading Language 4.50 Reference Card Page 11
Built-In Funcons
Angle & Trig. Funcons [8.1]
Funcons will not result in a divide-by-zero
error. If the
divisor of a rao is 0, then results
will be undened. Component-wise operaon.
Parameters specied as angle are in units of
radians.
Tf=oat, vecn.
Tf radians(Tf degrees) degrees to radians
Tf degrees(Tf radians) radians to degrees
Tf sin(Tf angle) sine
Tf cos(Tf angle) cosine
Tf tan(Tf angle) tangent
Tf asin(Tf x) arc sine
Tf acos(Tf x) arc cosine
Tf atan(Tf y, Tf x)
Tf atan(Tf y_over_x) arc tangent
Tf sinh(Tf x) hyperbolic sine
Tf cosh(Tf x) hyperbolic cosine
Tf tanh(Tf x) hyperbolic tangent
Tf asinh(Tf x) hyperbolic sine
Tf acosh(Tf x) hyperbolic cosine
Tf atanh(Tf x) hyperbolic tangent
Exponenal Funcons [8.2]
Component-wise operaon.
Tf=oat, vecn.
Td= double, dvecn. Tfd= Tf, Td
Tf pow(Tf x, Tf y)xy
Tf exp(Tf x) ex
Tf log(Tf x) ln
Tf exp2(Tf x) 2x
Tf log2(Tf x) log2
Tfd sqrt(Tfd x) square root
Tfd inversesqrt(Tfd x) inverse square root
Common Funcons [8.3]
Component-wise operaon. Tf=oat, vecn. Tb=bool,
bvecn. Ti=int, ivecn. Tu=uint, uvecn.
Td= double, dvecn. Tfd= Tf, Td. Tiu= Ti, Tu.
Returns absolute value:
Tfd abs(Tfd x)Ti abs(Ti x)
Returns -1.0, 0.0, or 1.0:
Tfd sign(Tfd x)Ti sign(Ti x)
Returns nearest integer <= x:
Tfd oor(Tfd x)
Returns nearest integer with absolute value <= absolute
value of x:
Tfd trunc(Tfd x)
Returns nearest integer, implementaon-dependent
rounding mode:
Tfd round(Tfd x)
Returns nearest integer, 0.5 rounds to nearest even integer:
Tfd roundEven(Tfd x)
Returns nearest integer >= x:
Tfd ceil(Tfd x)
Returns x - oor(x):
Tfd fract(Tfd x)
Returns modulus:
Tfd mod(Tfd x, Tfd y)
Tf mod(Tf x, oat y) Td mod(Td x, double y)
Returns separate integer and fraconal parts:
Tfd modf(Tfd x, out Tfd i)
Returns minimum value:
Tfd min(Tfd x, Tfd y)
Tf min(Tf x, oat y)
Td min(Td x, double y)
Tiu min(Tiu x, Tiu y)
Ti min(Ti x, int y)
Tu min(Tu x, uint y)
(Connue )
Common Funcons (cont.)
Returns maximum value:
Tfd max(Tfd x, Tfd y)
Tf max(Tf x, oat y)
Td max(Td x, double y)
Tiu max(Tiu x, Tiu y)
Ti max(Ti x, int y)
Tu max(Tu x, uint y)
Returns min(max(x, minVal), maxVal):
Tfd clamp(Tfd x, Tfd minVal, Tfd maxVal)
Tf clamp(Tf x, oat minVal, oat maxVal)
Td clamp(Td x, double minVal, double maxVal)
Tiu clamp(Tiu x, Tiu minVal, Tiu maxVal)
Ti clamp(Ti x, int minVal, int maxVal)
Tu clamp(Tu x, uint minVal, uint maxVal)
Returns linear blend of x and y:
Tfd mix(Tfd x, Tfd y, Tfd a)
Tf mix(Tf x, Tf y, oat a)
Td mix(Td x, Td y, double a)
Ti mix(Ti x, Ti y, Ti a)
Tu mix(Tu x, Tu y, Tu a)
Components returned come from x when a components
are true, from y when a components are false:
Tfd mix(Tfd x, Tfd y, Tb a) Tb mix(Tb x, Tb y, Tb a)
Tiu mix(Tiu x, Tiu y, Tb a)
Returns 0.0 if x < edge, else 1.0:
Tfd step(Tfd edge, Tfd x)
Tf step(oat edge, Tf x) Td step(double edge, Td x)
Clamps and smoothes:
Tfd smoothstep(Tfd edge0, Tfd edge1, Tfd x)
Tf smoothstep(oat edge0, oat edge1, Tf x)
Td smoothstep(double edge0, double edge1, Td x)
Returns true if x is NaN:
Tb isnan(Tfd x)
Returns true if x is posive or negave innity:
Tb isinf(Tfd x)
Returns signed int or uint value of the encoding of a oat:
Ti oatBitsToInt(Tf value)
Tu oatBitsToUint(Tf value)
Returns oat value of a signed int or uint encoding of a oat:
Tf intBitsToFloat(Ti value) Tf uintBitsToFloat(Tu value)
Computes and returns a*b + c. Treated as a single operaon
when using precise:
Tfd fma(Tfd a, Tfd b, Tfd c)
Splits x into a oang-point signicand in the range [0.5, 1.0)
and an integer exponent of 2:
Tfd frexp(Tfd x, out Ti exp)
Builds a oang-point number from x and the corresponding
integral exponent of 2 in exp:
Tfd ldexp(Tfd x, in Ti exp)
Floang-Point Pack/Unpack [8.4]
These do not operate component-wise.
Converts each component of v into 8- or 16-bit ints, packs
results into the returned 32-bit unsigned integer:
uint packUnorm2x16(vec2 v)
uint packSnorm2x16(vec2 v)
uint packUnorm4x8(vec4 v)
uint packSnorm4x8(vec4 v)
Unpacks 32-bit p into two 16-bit uints, four 8-bit uints, or
signed ints. Then converts each component to a normalized
oat to generate a 2- or 4-component vector:
vec2 unpackUnorm2x16(uint p)
vec2 unpackSnorm2x16(uint p)
vec4 unpackUnorm4x8(uint p)
vec4 unpackSnorm4x8(uint p)
Packs components of v into a 64-bit value and returns a
double-precision value:
double packDouble2x32(uvec2 v)
Returns a 2-component vector representaon of v:
uvec2 unpackDouble2x32(double v)
Returns a uint by converng the components of a two-
component oang-point vector:
uint packHalf2x16(vec2 v)
Returns a two-component oang-point vector:
vec2 unpackHalf2x16(uint v)
Geometric Funcons [8.5]
These funcons operate on vectors as vectors, not
component-wise.
Tf=oat, vecn. Td =double, dvecn.
Tfd= oat, vecn, double, dvecn.
oat length(Tf x)
double length(Td x)length of vector
oat distance(Tf p0, Tf p1)
double distance(Td p0, Td p1)
distance between points
oat dot(Tf x, Tf y)
double dot(Td x, Td y)dot product
vec3 cross(vec3 x, vec3 y)
dvec3 cross(dvec3 x, dvec3 y)
cross product
Tfd normalize(Tfd x)normalize vector to length 1
Tfd faceforward(Tfd N,
Tfd I, Tfd Nref)
returns N if dot(Nref, I) <
0, else -N
Tfd reect(Tfd I, Tfd N)reecon direcon
I - 2 * dot(N,I) * N
Tfd refract(Tfd I, Tfd N,
oat eta)refracon vector
Matrix Funcons [8.6]
N and M are 1, 2, 3, 4.
mat matrixCompMult(mat x, mat y)
dmat matrixCompMult(dmat x, dmat y)
component-wise
mulply
matN outerProduct(vecN c, vecN r)
dmatN outerProduct(dvecN c, dvecN r)
outer product
(where N != M)
matNxM outerProduct(vecM c, vecN r)
dmatNxM outerProduct(dvecM c, dvecN r)
outer product
matN transpose(matN m)
dmatN transpose(dmatN m)transpose
matNxM transpose(matMxN m)
dmatNxM transpose(dmatMxN m)
transpose
(where N != M)
oat determinant(matN m)
double determinant(dmatN m)determinant
matN inverse(matN m)
dmatN inverse(dmatN m)inverse
Vector Relaonal Funcons [8.7]
Compare x and y component-wise. Sizes of the
input and return vectors for any parcular call
must match. Tvec=vec
n
, uvec
n
, ivec
n
.
bvecn lessThan(Tvec x, Tvec y)<
bvecn lessThanEqual(Tvec x, Tvec y)<=
bvecn greaterThan(Tvec x, Tvec y) >
bvecn
greaterThanEqual(
Tvec
x,
Tvec
y)
>=
bvecn equal(Tvec x, Tvec y)
bvecn equal(bvecn x, bvecn y)==
bvecn notEqual(Tvec x, Tvec y)
bvecn notEqual(bvecn x, bvecn y)!=
bool any(bvecn x)true if any component of x is true
bool all(bvecn x) true if all comps. of x are true
bvecn not(bvecn x) logical complement of x
Integer Funcons [8.8]
Component-wise operaon.
Tu=uint, uvecn.
Ti=int, ivecn. Tiu=
int, ivecn, uint, uvecn.
Adds 32-bit uint x and y, returning the sum modulo 2
32
:
Tu uaddCarry(Tu x, Tu y, out Tu carry)
Subtracts y from x, returning the dierence if non-negave,
otherwise 2
32
plus the dierence:
Tu usubBorrow(Tu x, Tu y, out Tu borrow)
(Connue )
Integer Funcons (cont.)
Mulplies 32-bit integers x and y, producing a 64-bit result:
void umulExtended(Tu x, Tu y, out Tu msb, out Tu lsb)
void imulExtended(Ti x, Ti y, out Ti msb, out Ti lsb)
Extracts bits [oset, oset + bits - 1] from value, returns
them in the least signicant bits of the result:
Tiu biieldExtract(Tiu value, int oset, int bits)
Returns the reversal of the bits of value:
Tiu
biieldReverse(
Tiu
value)
Inserts the bits least-signicant bits of insert into base:
Tiu biieldInsert(Tiu base, Tiu insert,
int oset, int bits)
Returns the number of bits set to 1:
Ti
bitCount(
Tiu
value)
Returns the bit number of the least signicant bit:
Ti
ndLSB(
Tiu
value)
Returns the bit number of the most signicant bit:
Ti ndMSB(Tiu value)
Texture Lookup Funcons [8.9]
Available to vertex, geometry, and fragment
shaders. See tables on next page.
Atomic-Counter Funcons [8.10]
Returns the value of an atomic counter.
Atomically increments c then returns its prior value:
uint atomicCounterIncrement(atomic_uint c)
Atomically decrements c then returns its prior value:
uint atomicCounterDecrement(atomic_uint c)
Atomically returns the counter for c:
uint atomicCounter(atomic_uint c)
Atomic Memory Funcons [8.11]
Operates on individual integers in buer-object
or shared-variable storage. OP is Add, Min, Max,
And, Or, Xor, Exchange, or CompSwap.
uint atomicOP(coherent inout uint mem, uint data)
int atomicOP(coherent inout int mem, int data)
Image Funcons [8.12]
In the image funcons below, IMAGE_PARAMS
may be one of the following:
gimage1D image, int P
gimage2D image, ivec2 P
gimage3D image, ivec3 P
gimage2DRect image, ivec2 P
gimageCube image, ivec3 P
gimageBuer image, int P
gimage1DArray image, ivec2 P
gimage2DArray image, ivec3 P
gimageCubeArray image, ivec3 P
gimage2DMS image, ivec2 P, int sample
gimage2DMSArray image, ivec3 P, int sample
Returns the dimensions of the images or images:
int imageSize(gimage{1D,Buer} image)
ivec2 imageSize(gimage{2D,Cube,Rect,1DArray,
2DMS} image)
ivec3 imageSize(gimage{Cube,2D,2DMS}Array image)
vec3 imageSize(gimage3D image)
Returns the number of samples of the image or images
bound to image:
int imageSamples(gimage2DMS image)
int imageSamples(gimage2DMSArray image)
Loads texel at the coordinate P from the image unit image:
gvec4 imageLoad(readonly IMAGE_PARAMS)
Stores data into the texel at the coordinate P from
the image specied by image:
void imageStore(writeonly IMAGE_PARAMS, gvec4 data)
(Connued on next page)
Type Abbreviaons for Built-in Funcons: In vector types, n is 2, 3, or 4.
Tf=oat, vecn. Td =double, dvecn. Tfd= oat, vecn, double, dvecn. Tb= bool, bvecn.
Tu=uint, uvecn. Ti=int, ivecn. Tiu=
int, ivec
n
, uint, uvec
n
. Tvec=vec
n
, uvec
n
, ivec
n
.
Within any one funcon, type sizes and dimensionality must correspond aer implicit type
conversions. For example, oat round(oat) is supported, but oat round(vec4) is not.
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 12 OpenGL Shading Language 4.50 Reference Card
Texture Funcons [8.9]
Available to vertex, geometry, and fragment
shaders. gvec4=vec4, ivec4, uvec4.
gsampler* =sampler*, isampler*, usampler*.
The P argument needs to have enough
components to specify each dimension, array
layer, or comparison for the selected sampler.
The dPdx and dPdy arguments need enough
components to specify the derivave for each
dimension of the sampler.
Texture Query Funcons [8.9.1]
textureSize funcons return dimensions of lod
(if present) for the texture bound to sampler.
Components in return value are lled in with the
width, height, depth of the texture. For array
forms, the last component of the return value is
the number of layers in the texture array.
{int,ivec2,ivec3} textureSize(
gsampler{1D[Array],2D[Rect,Array],Cube} sampler[,
int lod])
{int,ivec2,ivec3} textureSize(
gsampler{Buer,2DMS[Array]}sampler)
{int,ivec2,ivec3} textureSize(
sampler{1D, 2D, 2DRect,Cube[Array]}Shadow sampler[,
int lod])
ivec3 textureSize(samplerCubeArray sampler, int lod)
textureQueryLod funcons return the mipmap
array(s) that would be accessed in the x
component of the return value. Returns the
computed level of detail relave to the base level
in the y component of the return value.
vec2 textureQueryLod(
gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler,
{oat,vec2,vec3} P)
vec2 textureQueryLod(
sampler{1D[Array],2D[Array],Cube[Array]}Shadow sampler
,
{oat,vec2,vec3} P)
textureQueryLevels funcons return the number
of mipmap levels accessible in the texture
associated with sampler.
int textureQueryLevels(
gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler)
int textureQueryLevels(
sampler{1D[Array],2D[Array],Cube[Array]}Shadow sampler
)
textureSamples returns the number of samples
of the texture.
int textureSamples(gsampler2DMS sampler)
int textureSamples(gsampler2DMSArray sampler)
Texel Lookup Funcons [8.9.2]
Use texture coordinate P to do a lookup in the texture
bound to sampler.
For shadow forms, compare is
used as D
ref
and the array layer comes from P. w.
For non-shadow forms, the array layer comes from
the last component of P.
gvec4 texture(
gsampler{1D[Array],2D[Array,Rect],3D,Cube[Array]} sampler,
{oat,vec2,vec3,vec4} P [, oat bias])
oat texture(
sampler{1D[Array],2D[Array,Rect],Cube}Shadow sampler,
{vec3,vec4} P [, oat bias])
oat texture(gsamplerCubeArrayShadow sampler, vec4 P,
oat compare)
Texture lookup with projecon.
gvec4 textureProj(gsampler{1D,2D[Rect],3D} sampler,
vec{2,3,4} P [, oat bias])
oat textureProj(sampler{1D,2D[Rect]}Shadow sampler,
vec4 P [, oat bias])
Texture lookup as in texture but with explicit LOD.
gvec4 textureLod(
gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler,
{oat,vec2,vec3} P, oat lod)
oat textureLod(sampler{1D[Array],2D}Shadow sampler,
vec3 P, oat lod)
Oset added before texture lookup.
gvec4 textureOset(
gsampler{1D[Array],2D[Array,Rect],3D} sampler,
{oat,vec2,vec3} P, {int,ivec2,ivec3} oset [, oat bias])
oat textureOset(
sampler{1D[Array],2D[Rect,Array]}Shadow sampler,
{vec3, vec4} P, {int,ivec2} oset [, oat bias])
Use integer texture coordinate P to lookup a single
texel from sampler.
gvec4 texelFetch(
gsampler{1D[Array],2D[Array,Rect],3D} sampler,
{int,ivec2,ivec3} P[, {int,ivec2} lod])
gvec4 texelFetch(gsampler{Buer, 2DMS[Array]} sampler,
{int,ivec2,ivec3} P[, int sample])
Fetch single texel with oset added before texture lookup.
gvec4 texelFetchOset(
gsampler{1D[Array],2D[Array],3D} sampler,
{int,ivec2,ivec3} P, int lod, {int,ivec2,ivec3} oset)
gvec4 texelFetchOset(
gsampler2DRect sampler, ivec2 P, ivec2 oset)
Projecve texture lookup
with oset added before
texture lookup.
gvec4 textureProjOset(gsampler{1D,2D[Rect],3D} sampler,
vec{2,3,4} P, {int,ivec2,ivec3} oset [, oat bias])
oat textureProjOset(
sampler{1D,2D[Rect]}Shadow sampler, vec4 P,
{int,ivec2} oset [, oat bias])
Oset texture lookup with explicit LOD.
gvec4 textureLodOset(
gsampler{1D[Array],2D[Array],3D} sampler,
{oat,vec2,vec3} P, oat lod, {int,ivec2,ivec3} oset)
oat textureLodOset(
sampler{1D[Array],2D}Shadow sampler, vec3 P, oat lod,
{int,ivec2} oset)
Projecve texture lookup with explicit LOD.
gvec4 textureProjLod(gsampler{1D,2D,3D} sampler,
vec{2,3,4} P, oat lod)
oat textureProjLod(sampler{1D,2D}Shadow sampler,
vec4 P, oat lod)
Oset projecve texture lookup with explicit LOD.
gvec4 textureProjLodOset(gsampler{1D,2D,3D} sampler,
vec{2,3,4} P, oat lod, {int, ivec2, ivec3} oset)
oat textureProjLodOset(sampler{1D,2D}Shadow sampler,
vec4 P, oat lod, {int, ivec2} oset)
Texture lookup as in texture but with explicit gradients.
gvec4 textureGrad(
gsampler{1D[Array],2D[Rect,Array],3D,Cube[Array]} sampler,
{oat, vec2, vec3,vec4} P, {oat, vec2, vec3} dPdx,
{oat, vec2, vec3} dPdy)
oat textureGrad(
sampler{1D[Array],2D[Rect,Array], Cube}Shadow sampler,
{vec3,vec4} P, {oat,vec2} dPdx, {oat,vec2, vec3} dPdy)
Texture lookup with both explicit gradient and oset.
gvec4 textureGradOset(
gsampler{1D[Array],2D[Rect,Array],3D} sampler,
{oat,vec2,vec3} P, {oat,vec2,vec3} dPdx,
{oat,vec2,vec3} dPdy, {int,ivec2,ivec3} oset)
oat textureGradOset(
sampler{1D[Array],2D[Rect,Array]}Shadow sampler,
{vec3,vec4} P, {oat,vec2} dPdx, {oat,vec2}dPdy,
{int,ivec2} oset)
Texture lookup both projecvely as in
textureProj, and with explicit gradient as in
textureGrad.
gvec4 textureProjGrad(gsampler{1D,2D[Rect],3D} sampler,
{vec2,vec3,vec4} P, {oat,vec2,vec3} dPdx,
{oat,vec2,vec3} dPdy)
oat textureProjGrad(sampler{1D,2D[Rect]}Shadow sampler,
vec4 P, {oat,vec2} dPdx, {oat,vec2} dPdy)
Texture lookup projecvely and with explicit gradient
as in textureProjGrad, as well as with oset as in
textureOset.
gvec4 textureProjGradOset(
gsampler{1D,2D[Rect],3D} sampler, vec{2,3,4} P,
{oat,vec2,vec3} dPdx, {oat,vec2,vec3} dPdy,
{int,ivec2,ivec3} oset)
oat textureProjGradOset(
sampler{1D,2D[Rect]Shadow} sampler, vec4 P,
{oat,vec2} dPdx, {oat,vec2} dPdy, {ivec2,int,vec2} oset)
Texture Gather Instrucons [8.9.3]
These funcons take components of a oang-point
vector operand as a texture coordinate, determine
a set of four texels to sample from the base level of
detail of the specied texture image, and return one
component from each texel in a four-component
result vector.
gvec4
textureGather(
gsampler{2D[Array,Rect],Cube[Array]} sampler,
{vec2,vec3,vec4} P [, int comp])
vec4 textureGather(
sampler{2D[Array,Rect],Cube[Array]}Shadow sampler,
{vec2,vec3,vec4} P, oat refZ)
Texture gather as in textureGather by oset as
described in textureOset except minimum and
maximum oset values are given by
{MIN, MAX}_PROGRAM_TEXTURE_GATHER_OFFSET.
gvec4 textureGatherOset(gsampler2D[Array,Rect] sampler,
{vec2,vec3} P, ivec2 oset [, int comp])
vec4 textureGatherOset(
sampler2D[Array,Rect]Shadow sampler,
{vec2,vec3} P, oat refZ, ivec2 oset)
Texture gather as in textureGatherOset except osets
determines locaon of the four texels to sample.
gvec4 textureGatherOsets(gsampler2D[Array,Rect] sampler,
{vec2,vec3} P, ivec2 osets[4] [, int comp])
vec4 textureGatherOsets(
sampler2D[Array,Rect]Shadow sampler,
{vec2,vec3} P, oat refZ, ivec2 osets[4])
Built-In Funcons (cont.)
Image Funcons (cont.)
Adds the value of data to the contents of the selected texel:
uint
imageAtomicAdd(
coherent
IMAGE_PARAMS,
uint
data)
int imageAtomicAdd(
coherent
IMAGE_PARAMS, int data)
Takes the minimum of the value of data and the contents
of the selected texel:
uint imageAtomicMin(
coherent
IMAGE_PARAMS,
uint
data)
int imageAtomicMin(
coherent
IMAGE_PARAMS, int data)
Takes the maximum of the value data and the contents
of the selected texel:
uint
imageAtomicMax(
coherent
IMAGE_PARAMS,
uint
data)
int imageAtomicMax(
coherent
IMAGE_PARAMS, int data)
Performs a bit-wise AND of the value of data and the
contents of the selected texel:
uint imageAtomicAnd(
coherent
IMAGE_PARAMS,
uint
data)
int imageAtomicAnd(
coherent
IMAGE_PARAMS, int data)
Performs a bit-wise OR of the value of data and the
contents of the selected texel:
uint
imageAtomicOr(
coherent
IMAGE_PARAMS,
uint
data)
int imageAtomicOr(
coherent
IMAGE_PARAMS, int data)
Performs a bit-wise exclusive OR of the value of data and
the contents of the selected texel:
uint
imageAtomicXor(
coherent
IMAGE_PARAMS,
uint
data)
int imageAtomicXor(
coherent
IMAGE_PARAMS, int data)
(Connue )
Image Funcons (cont.)
Copies the value of data:
uint imageAtomicExchange(coherent IMAGE_PARAMS,
uint data)
int imageAtomicExchange(coherent IMAGE_PARAMS,
int data)
int imageAtomicExchange(coherent IMAGE_PARAMS,
oat data)
Compares the value of compare and contents of selected
texel. If equal, the new value is given by data; otherwise,
it is taken from the original value loaded from texel:
uint
imageAtomicCompSwap(coherent IMAGE_PARAMS,
uint
compare,
uint
data)
int imageAtomicCompSwap(coherent IMAGE_PARAMS,
int compare, int data)
Fragment Processing Funcons [8.13]
Available only in fragment shaders.
Tf=oat, vecn.
Derivave fragment-processing funcons
Tf dFdx(Tf p)
Tf dFdy(Tf p)
derivave in x and y, either
ne or coarse derivaves
Tf dFdxFine(Tf p)
Tf dFdyFine(Tf p)
ne derivave in x and y per
pixel-row/column derivave
Tf dFdxCoarse(Tf p)
Tf dFdyCoarse(Tf p)
coarse derivave in x and y per
2x2-pixel derivave
Tf fwidth(Tf p)
Tf fwidthFine(Tf p)
Tf fwidthCoarse(Tf p)
sum of absolute values of x and y
derivaves
Interpolaon fragment-processing funcons
Return value of
interpolant
sampled inside pixel and the
primive:
Tf interpolateAtCentroid(Tf interpolant)
Return value of
interpolant
at locaon of sample #
sample
:
Tf interpolateAtSample(Tf interpolant, int sample)
Return value of
interpolant
sampled at xed oset
oset
from pixel center:
Tf interpolateAtOset(Tf interpolant, vec2 oset)
Noise Funcons [8.14]
Returns noise value. Available to fragment, geometry,
and vertex shaders.
n is 2, 3, or 4:
oat noise1(Tf x)vecn noisen(Tf x)
Geometry Shader Funcons [8.15]
Only available in geometry shaders.
Emits values of output variables to current output
primive stream stream
:
void EmitStreamVertex(int stream)
Completes current output primive stream stream and
starts a new one
:
void EndStreamPrimive(int stream)
(Connue )
Geometry Shader Funcons (cont’d)
Emits values of output variables to the current output
primive
:
void EmitVertex()
Completes output primive and starts a new one
:
void EndPrimive()
Other Shader Funcons [8.16-17]
See diagram on page 11 for more informaon.
Synchronizes across shader invocaons
:
void barrier()
Controls ordering of memory transacons issued by a
single shader invocaon
:
void memoryBarrier()
Controls ordering of memory transacons as viewed by
other invocaons in a compute work group:
void groupMemoryBarrier()
Order reads and writes accessible to other invocaons:
void memoryBarrierAtomicCounter()
void memoryBarrierShared()
void memoryBarrierBuer()
void memoryBarrierImage()
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL 4.5 API Reference Card Page 13
OpenGL is a registered trademark of Silicon Graphics Internaonal, used under license by Khronos Group.
The Khronos Group is an industry consorum creang open standards for the authoring and acceleraon
of parallel compung, graphics and dynamic media on a wide variety of plaorms and devices.
See www.khronos.org to learn more about the Khronos Group.
See www.opengl.org to learn more about OpenGL.
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.
Reference card producon by Miller & Mattson www.millermason.com www.opengl.org/registry
Page 13
A
AcveShaderProgram 2
AcveTexture 2
Angle Funcons 11
Asynchronous Queries 1
Atomic Funcons 11
AachShader 2
B
BeginCondionalRender 5
BeginQuery[Indexed] 1
BeginTransformFeedback 5
BindAribLocaon 5
BindBuer* 1
BindBuer[s]{Base, Range} 1
BindFragDataLocaon[Indexed] 5
BindFramebuer 4
BindImageTexture[s] 4
BindProgramPipeline 2
BindRenderbuer 4
Bind{Sampler, Texture}[s] 2
BindTexture[s] 2
BindTextureUnit 2
BindTransformFeedback 5
BindVertexArray 4
BindVertexBuer[s] 4
BlendColor 6
BlendEquaon[Separate]* 6
BlendFunc[Separate]* 6
Blit[Named]Framebuer 6
Buer[Sub]Data 1
BuerStorage 1
BuerTextures 3
C
Callback 6
Check[Named]FramebuerStatus 4
ClampColor 6
Clear 6
Clear[Named]Buer[Sub]Data 1
ClearBuer* 6
ClearColor 6
ClearDepth* 6
ClearStencil 6
ClearTex[Sub]Image 4
ClientWaitSync 1
Clip Control 5
ColorMask* 6
Command Leers 1
Common Funcons 11
CompileShader 1
CompressedTex[Sub]Image* 3
CompressedTextureSubImage* 3
Compute Language Variables 10
Compute Programming Diagram 7
Compute Shaders 5
Constants 10
Conversions 6
Copy[Named]BuerSubData 1
CopyImageSubData 6
CopyTex[Sub]Image* 3
CopyTextureSubImage* 3
CreateBuers 1
CreateFrameBuers 4
CreateProgram[Pipelines] 2
CreateQueries* 1
CreateRenderBuers 4
CreateSamplers* 2
CreateShader 1
CreateShaderProgramv 2
Createtextures* 2
CreateTransformFeedbacks 5
CreateVertexArrays 4
CullFace 5
D
DebugMessage* 6
DeleteBuers 1
DeleteFramebuers 4
DeleteProgram[Pipelines] 2
DeleteQueries 1
DeleteRenderbuers 4
DeleteSamplers 2
DeleteShader 1
DeleteSync 1
DeleteTextures 2
DeleteTransformFeedbacks 5
DeleteVertexArrays 4
DepthFunc 6
DepthMask 6
DepthRange* 5
Derivave Funcons 12
DetachShader 2
DisableVertexArrayArib 5
DisableVertexAribArray 5
DispatchCompute* 5
Dithering 6
DrawArrays* 5
DrawBuer[s] 6
Draw[Range]Elements* 5
DrawTransformFeedback* 5
E
EnableVertexArrayArib 5
EnableVertexAribArray 5
EndCondionalRender 5
EndQuery[Indexed] 1
EndQuery 6
EndTransformFeedback 5
Errors 1
Exponenal Funcons 11
F
Feedback Loops 4
FenceSync 1
Finish 1
Flatshading 5
Floang-Point Pack/Unpack Func. 11
Flush 1
FlushMapped* 1
Fragment Language Variables 10
Fragment Processing Funcons 12
Fragment Shaders 5
Framebuer Objects 4
FramebuerParameteri 4
FramebuerRenderbuer 4
FramebuerTexture* 4
FrontFace 5
G
GenBuers 1
Generate[Texture]Mipmap 3
GenFramebuers 4
GenProgramPipelines 2
GenQueries 1
GenRenderbuers 4
GenSamplers 2
GenTextures 2
GenTransformFeedbacks 4
GenVertexArrays 4
Geometric Funcons 11
Geometry & Follow-on Diagram 8
Geometry Shader Funcons 12
GetAcveAtomicCounterBuer* 2
GetAcveArib 5
GetAcveSubroune* 2
GetAcveUniform* 2
GetAachedShaders 2
GetAribLocaon 5
GetBoolean* 6
GetBuerParameter* 1
GetBuer{Pointerv, SubData} 1
Get[n]CompressedTexImage 3
GetCompressedTexSubImage 3
GetCompressedTextureImage 3
GetDebugMessageLog 6
GetDouble* 6
GetError 1
GetFloat* 6
GetFragData* 5
GetFramebuer* 4
GetGraphicsResetStatus 1
GetInteger* 7
GetInteger64* 7
GetInternalformat* 7
GetMulsamplefv 5
GetNamedBuer[Indexed] 1
GetNamedFramebuer 4
GetNamedRenderbuer 4
GetObject[Ptr]Label 6
GetPointerv 6-7
GetProgram* 2
GetQuery* 1
GetRenderbuerParameteriv 4
GetSamplerParameter* 2
GetShader* 2
GetString* 6
GetSubroune* 2
GetSynciv 1
Get[n]TexImage 3
GetTex[Level]Parameter* 3
GetTexture* 3
GetTransformFeedback 7
GetTransformFeedbackVarying 5
Get[n]Uniform 2
GetUniform* 2
GetVertex{Array, Arib}* 5
GL Command Syntax 1
H
Hint 6
I
Image Funcons 11
Integer Funcons 11
Interpolaon Funcons 12
Interpolaon Qualiers 10
InvalidateBuer* 1
Invalidate[Sub]Framebuer 6
InvalidateNamedFramebuer 6
InvalidateTex[Sub]Image 4
Invariant Qualiers 10
IsBuer 1
IsFramebuer 4
IsProgram[Pipeline] 5
IsQuery 1
IsRenderbuer 4
IsSampler 2
IsShader 1
IsSync 1
IsTexture 2
IsTransformFeedback 5
IsVertexArray 4
Iteraon and Jumps 10
L
Layout Qualiers 9
LineWidth 5
LinkProgram 2
LogicOp 6
M
Macros 9
Map[Named]Buer* 1
Matrix Operaons 10
Matrix Funcons 11
MemoryBarrier 2
MemoryBarrier 12
Memory Qualiers 10
MinSampleShading 5
MulDraw{Arrays, Elements}* 5
Mulsample Fragment Ops 6
Mulsample Textures 3
Mulsampling 5
N
NamedBuer 1
NamedFramebuerDraw 6
NamedFramebuer 4
NamedFramebuerReadBuer 6
NamedRenderbuerStorage 4
Noise Funcons 12
O
Object[Ptr]Label 5
Occlusion Queries 6
Operators 9
P
Pack/Unpack Funcons 11
Parameter Qualiers 10
PatchParameter 5
PauseTransformFeedback 5
Per-Fragment Operaons 6
Pipeline Diagram 8
PixelStore{if} 2
PointParameter* 5
PointSize 5
Polygon{Mode, Oset} 5
{Pop, Push}DebugGroup 6
Precise & Precision Qualiers 10
Preprocessor 9
Primive Clipping 5
PrimiveRestartIndex 5
ProgramBinary 2
Program Objects 2
ProgramParameteri 2
ProgramUniform[Matrix]* 2
ProvokingVertex 5
Q
Qualiers 9
QueryCounter 1
R
Rasterizaon 5
ReadBuer 6
Read[n]Pixels 6
ReleaseShaderCompiler 1
Renderbuer Object Queries 4
RenderbuerStorage* 4
ResumeTransformFeedback 5
S
SampleCoverage 5
SampleMaski 5
SamplerParameter* 2
Sampler Queries 2
Scissor* 6
Shaders and Programs 1-2
Shader Funcons 12
Shader[Binary, Source] 1
ShadersStorageBlockBinding 2
Shading Language 9-12
State and State Requests 6-7
StencilFunc[Separate] 6
StencilMask[Separate] 6
StencilOp[Separate] 6
Storage Qualiers 9
Structures 10
Subroune Uniform Variables 2
Subrounes 10
Synchronizaon 1
T
Tessellaon Diagram 7
Tessellaon Variables 10
TexBuer* 3
Texel Lookup Funcons 12
TexImage*[Mulsample] 3
TexParameter* 3
TexStorage* 3
TexStorage*[Mulsample] 4
TexSubImage* 3
TextureBarrier 4
TextureBuer[Range] 3
Texture Funcons 12
Texture Queries 3
TextureStorage*[Mulsample] 4
TextureSubImage 3
TextureView 3
Texture View/State Diagram 7
Timer Queries 1
Transform Feedback 5
TransformFeedbackVaryings 5
Types 9
U
Uniform Qualiers 9-10
Uniform Variables 2
Uniform* 2
UniformBlockBinding 2
Uniform[Matrix]* 2
UniformSubrounesuiv 2
Unmap[Named]Buer 1
UseProgram[Stages] 2
V
ValidateProgram[Pipeline] 5
Vector & Matrix 10
Vector Relaonal Funcons 11
Vertex & Tessellaon Diagram 8
Vertex Arrays 4-5
VertexArib* 4
Vertex[Array]Arib* 4
VertexArrayBindingDivisor 5
VertexArray*Buer 4
VertexArib*Format 4
VertexArib*Pointer 5
VertexArib[Binding, Divisor] 4-5
VertexBindingDivisor 4
Vertex Language Variables 10
Viewport* 5
W
WaitSync 1