Opengl 45 Reference Guide

User Manual:

Open the PDF directly: View PDF 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 FunconName refers to funcons on this reference card.
[n.n.n] and [Table n.n] refer to secons and tables in the OpenGL 4.5 core specicaon.
[n.n.n] refers to secons in the OpenGL Shading Language 4.50 specicaon.
OpenGL Command Syntax [2.2]
GL commands are formed from a return type, a name, and oponally up to 4 characters
(or character pairs) from the Command Leers 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
suxes. 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 documentaon and this reference may omit the standard prexes.
The actual names are of the forms: glFunconName(), GL_CONSTANT, GLtype
Command Execuon
[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);
Floang-Point Numbers [2.3.4]
16-Bit 1-bit sign, 5-bit exponent,
10-bit manssa
Unsigned 11-Bit no sign bit, 5-bit exponent,
6-bit manssa
Unsigned 10-Bit no sign bit, 5-bit exponent,
5-bit manssa
Command Leers [Tables 2.1, 2.2]
Where a leer denotes a type in a funcon
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);
(Connued on next page)
Synchronizaon
Sync Objects and Fences [4.1]
void DeleteSync(sync sync);
sync FenceSync(enum condion, biield ags);
condion: 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);
Buer Objects [6]
void GenBuers(sizei n, uint *buers);
void CreateBuers(sizei n, uint *buers);
void
DeleteBuers
(sizei n, const uint *buers);
Create and Bind Buer Objects [6.1]
void BindBuer(enum target, uint buer);
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 BindBuerRange(enum target,
uint index, uint buer, intptr oset,
sizeiptr size);
target: ATOMIC_COUNTER_BUFFER,
{SHADER_STORAGE, UNIFORM}_BUFFER,
TRANSFORM_FEEDBACK_BUFFER
void BindBuerBase(enum target,
uint index, uint buer);
target: See BindBuerRange
void BindBuersRange(enum target,
uint rst, sizei count, const uint *buers,
const intptr *osets, const sizeiptr *size);
target: See BindBuerRange
void BindBuersBase(enum target,
uint rst, sizei count,
const uint *buers
);
target: See BindBuerRange
Create/Modify Buer Object Data [6.2]
void BuerStorage(enum target,
sizeiptr size, const void *data,
biield ags);
target: See BindBuer
ags: Bitwise OR of MAP_{READ, WRITE}_BIT,
{DYNAMIC, CLIENT}_STORAGE_BIT,
MAP_{COHERENT, PERSISTENT}_BIT
void NamedBuerStorage(uint buer,
sizeiptr size, const void *data,
biield ags);
ags: See BuerStorage
void BuerData(enum target, sizeiptr size,
const void *data, enum usage);
target: See BindBuer
usage: DYNAMIC_{DRAW, READ, COPY},
{STATIC, STREAM}_{DRAW, READ, COPY}
void NamedBuerData(uint buer, sizeiptr
size, const void *data, enum usage);
void BuerSubData(enum target,
intptr oset, sizeiptr size,
const void *data);
target: See BindBuer
void NamedBuerSubData(uint buer,
intptr oset, sizeiptr size,
const void *data);
void ClearBuerSubData(enum target,
enum internalFormat, intptr oset,
sizeiptr size, enum format, enum type,
const void *data);
target: See BindBuer
internalformat: See TexBuer 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 ClearNamedBuerSubData(
uint buer, enum internalFormat,
intptr oset, sizeiptr size, enum format,
enum type, const void *data);
internalformat, format, type: See
ClearBuerSubData
void ClearBuerData(enum target,
enum internalformat, enum format,
enum type, const void *data);
target, internalformat, format: See
ClearBuerSubData
void ClearNamedBuerData(uint buer,
enum internalformat, enum format,
enum type, const void *data);
internalformat, format, type: See ClearBuerData
Map/Unmap Buer Data [6.3]
void *MapBuerRange(enum target,
intptr oset, sizeiptr length,
biield access);
target: See BindBuer
access: The Bitwise OR of MAP_X_BIT, where X may
be READ, WRITE, PERSISTENT, COHERENT,
INVALIDATE_{BUFFER, RANGE},
FLUSH_EXPLICIT, UNSYNCHRONIZED
void *MapNamedBuerRange(uint buer,
intptr oset, sizeiptr length,
biield access);
target: See BindBuer
access: See MapBuerRange
void *MapBuer(enum target, enum access);
access: See MapBuerRange
void *MapNamedBuer(uint buer,
enum access);
access: See MapBuerRange
void FlushMappedBuerRange(intptr oset,
sizeiptr length);
void FlushMappedNamedBuerRange(
uint buer, intptr oset, sizeiptr length);
boolean UnmapBuer(enum target);
target: See BindBuer
boolean UnmapNamedBuer(uint buer);
Invalidate Buer Data [6.5]
void InvalidateBuerSubData(uint buer,
intptr oset, sizeiptr length);
void InvalidateBuerData(uint buer);
Buer Object Queries [6, 6.7]
boolean IsBuer(uint buer);
void GetBuerSubData(enum target,
intptr oset, sizeiptr size, void *data);
target: See BindBuer
void GetNamedBuerSubData(uint buer,
intptr oset, sizeiptr size, void *data);
void GetBuerParameteri[64]v(
enum target, enum pname, int[64]*data);
target: See BindBuer
pname: [Table 6.2] BUFFER_SIZE, BUFFER_USAGE,
BUFFER_{ACCESS[_FLAGS]}, BUFFER_MAPPED,
BUFFER_MAP_{OFFSET, LENGTH},
BUFFER_{IMMUTABLE_STORAGE, ACCESS_FLAGS}
void GetNamedBuerParameteri[64]v(
uint buer, enum pname, int[64]*data);
void GetBuerPointerv(enum target,
enum pname, const void **params);
target: See BindBuer
pname: BUFFER_MAP_POINTER
void GetNamedBuerPointerv(uint buer,
enum pname, const void **params);
pname: BUFFER_MAP_POINTER
Copy Between Buers [6.6]
void CopyBuerSubData(enum readTarget,
enum writeTarget, intptr readOset,
intptr writeOset, sizeiptr size);
readTarget and writeTarget: See BindBuer
void CopyNamedBuerSubData(
uint readBuer, uint writeBuer,
intptr readOset, intptr writeOset,
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 GetQueryObjecv(uint id, enum pname,
int *params);
void GetQueryObjectuiv(uint id,
enum pname, uint *params);
void GetQueryObjec64v(uint id,
enum pname, int64 *params);
void GetQueryObjectui64v(uint id,
enum pname, uint64 *params);
pname: QUERY_TARGET,
QUERY_RESULT[_NO_WAIT, _AVAILABLE]
Waing for Sync Objects [4.1.1]
enum ClientWaitSync(sync sync,
biield ags, uint64 meout_ns);
ags: SYNC_FLUSH_COMMANDS_BIT, or zero
void WaitSync(sync sync, biield 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 AachShader(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 GetProgramResourceLocaon(
uint program, enum programInterface,
const char *name);
int GetProgramResourceLocaonIndex(
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,
biield 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 AcveShaderProgram(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 GetUniformLocaon(uint program,
const char *name);
void GetAcveUniformName(uint program,
uint uniformIndex, sizei bufSize,
sizei *length, char *uniformName);
void GetUniformIndices(uint program,
sizei uniformCount,
const char * const *uniformNames,
uint *uniformIndices);
void GetAcveUniform(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 GetAcveUniformsiv(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 GetAcveUniformBlockName(
uint program, uint uniformBlockIndex,
sizei bufSize, sizei length,
char *uniformBlockName);
void GetAcveUniformBlockiv(
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 GetAcveAtomicCounterBueriv(
uint program, uint buerIndex,
enum pname, int *params);
pname: See GetAcveUniformBlockiv, however
replace the prex UNIFORM_BLOCK_ with
ATOMIC_COUNTER_BUFFER_
Load Uniform Vars. in Default Uniform Block
void Uniform{1234}{i f d ui}(int locaon,
T value);
void Uniform{1234}{i f d ui}v(int locaon,
sizei count, const T *value);
void UniformMatrix{234}{f d}v(
int locaon, sizei count, boolean transpose,
const oat *value);
void
UniformMatrix{2x3,3x2,2x4,4x2,3x4, 4x3}
{fd}v( int locaon, sizei count,
boolean transpose, const oat *value);
void ProgramUniform{1234}{i f d}(
uint program, int locaon, T value);
void ProgramUniform{1234}{i f d}v(
uint program, int locaon, sizei count,
const T *value);
void ProgramUniform{1234}uiv(
uint program, int locaon, sizei count,
const T *value);
void ProgramUniform{1234}ui(
uint program, int locaon, T value);
void ProgramUniformMatrix{234}{f d}v(
uint program, int locaon, sizei count,
boolean transpose, const T *value);
void ProgramUniformMatrixf{2x3,3x2,2x4,
4x2, 3x4, 4x3}{f d}v(
uint program, int locaon, sizei count,
boolean transpose, const T *value);
Uniform Buer Object Bindings
void UniformBlockBinding(uint program,
uint uniformBlockIndex,
uint uniformBlockBinding);
Shader Buer Variables [7.8]
void ShaderStorageBlockBinding(
uint program, uint storageBlockIndex,
uint storageBlockBinding);
Subroune Uniform Variables [7.9]
Parameter shadertype for the funcons in this
secon may be {COMPUTE, VERTEX}_SHADER,
TESS_{CONTROL, EVALUATION}_SHADER, or
{FRAGMENT, GEOMETRY}_SHADER
int GetSubrouneUniformLocaon(
uint program, enum shadertype,
const char *name);
uint GetSubrouneIndex(uint program,
enum shadertype, const char *name);
void GetAcveSubrouneName(
uint program, enum shadertype,
uint index, sizei bufsize, sizei *length,
char *name);
void GetAcveSubrouneUniformName(
uint program, enum shadertype,
uint index, sizei bufsize, sizei *length,
char *name);
void GetAcveSubrouneUniformiv(
uint program, enum shadertype,
uint index, enum pname, int *values);
pname: [NUM_]COMPATIBLE_SUBROUTINES
void UniformSubrounesuiv(
enum shadertype, sizei count,
const uint *indices);
Shader Memory Access [7.12.2]
See diagram on page 6 for more informaon.
void MemoryBarrier(biield 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(biield
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 GetAachedShaders(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 locaon, T *params);
void GetnUniform{f d i ui}v(uint program,
int locaon, sizei bufSize, T *params);
void GetUniformSubrouneuiv(
enum shadertype, int locaon,
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 AcveTexture(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}
(Connued 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 xoset, int yoset, int zoset,
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 xoset, int yoset, 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 xoset, sizei width, enum format,
enum type, const void *data);
target, format, type: See CopyTexImage1D
void CopyTexSubImage3D(enum target,
int level, int xoset, int yoset, int zoset,
int x, int y, sizei width, sizei height);
target: See TexSubImage3D
void CopyTexSubImage2D(enum target,
int level, int xoset, int yoset, int x,
int y, sizei width, sizei height);
target: See TexImage2D
void CopyTexSubImage1D(enum target,
int level, int xoset, int x, int y, sizei width);
target: See TexSubImage1D
void TextureSubImage3D(uint texture, int level,
int xoset, int yoset, int zoset,
sizei width, sizei height, sizei depth,
enum format, enum type,
const void *pixels);
format, type: See TexImage3D
void TextureSubImage2D(uint texture, int level,
int xoset, int yoset, sizei width,
sizei height, enum format, enum type,
const void *pixels);
format, type: See TexImage3D
void TextureSubImage1D(uint texture, int level,
int xoset, sizei width, enum format,
enum type, const void *pixels);
format, type: See TexImage3D
void CopyTextureSubImage3D(uint texture,
int level, int xoset, int yoset, int zoset,
int x, int y, sizei width, sizei height);
void CopyTextureSubImage2D(uint texture,
int level, int xoset, int yoset, int x,
int y, sizei width, sizei height);
void CopyTextureSubImage1D(uint texture,
int level, int xoset, 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, oming
compressed rectangular texture formats
void CompressedTexSubImage3D(
enum target, int level, int xoset,
int yoset, int zoset, 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 xoset,
int yoset, 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 xoset,
sizei width, enum format, sizei imageSize,
const void *data);
target: See TexSubImage1D
format: See internalformat for
CompressedTexImage1D
void CompressedTextureSubImage3D(
uint texture, int level, int xoset,
int yoset, int zoset, 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 xoset,
int yoset, sizei width, sizei height,
enum format, sizei imageSize,
cont void *data);
format: See internalformat for
CompressedTexImage2D
void CompressedTextureSubImage1D(
uint texture, int level, int xoset,
sizei width, enum format, sizei imageSize,
const void *data);
format: See internalformat for
CompressedTexImage1D
Mulsample Textures [8.8]
void TexImage3DMulsample(enum target,
sizei samples, int internalformat,
sizei width, sizei height, sizei depth,
boolean xedsamplelocaons);
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 TexImage2DMulsample(enum target,
sizei samples, int internalformat, sizei width,
sizei height, boolean xedsamplelocaons);
target: [PROXY_]TEXTURE_2D_MULTISAMPLE
internalformat: See TexImage3DMulsample
Buer Textures [8.9]
void TexBuerRange(enum target,
enum internalFormat, uint buer,
intptr oset, sizeiptr size);
void TextureBuerRange(uint texture,
enum internalFormat, uint buer,
intptr oset, sizeiptr size);
internalformat: See TexBuer
void TexBuer(enum target,
enum internalformat, uint buer);
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 TextureBuer(uint texture,
enum internalformat, uint buer);
internalformat: See TexBuer
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 xoset, int yoset, int zoset,
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 xoset, int yoset,
int zoset, 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 Generaon [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]
(Connued on next page)
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 4 OpenGL 4.5 API Reference Card
Framebuer Objects
Binding and Managing [9.2]
void BindFramebuer(enum target,
uint framebuer);
target: [DRAW_, READ_]FRAMEBUFFER
void CreateFramebuers(sizei n,
uint *framebuers);
void GenFramebuers(sizei n,
uint *framebuers);
void DeleteFramebuers(sizei n,
const uint *framebuers);
boolean IsFramebuer(uint framebuer);
Framebuer Object Parameters [9.2.1]
void FramebuerParameteri(
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 NamedFramebuerParameteri(
uint framebuer, enum pname, int param);
pname: See FramebuerParameteri
Framebuer Object Queries [9.2.3]
void GetFramebuerParameteriv(
enum target, enum pname, int *params);
target: See FramebuerParameteri
pname: See FramebuerParameteri plus
DOUBLEBUFFER, SAMPLES, SAMPLE_BUFFERS,
IMPLEMENTATION_COLOR_READ_FORMAT,
IMPLEMENTATION_COLOR_READ_TYPE, STEREO
void GetNamedFramebuerParameteriv(
uint framebuer, enum pname, int
*params);
pname: See GetFramebuerParameteri
void GetFramebuerAachmentParameteriv(
enum target, enum aachment,
enum pname, int *params);
target: [DRAW_, READ_]FRAMEBUFFER
aachment: 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 GetNamedFramebuerAachment-
Parameteriv(uint framebuer,
enum aachment, enum pname,
int *params);
aachment, pname: See GetFramebuerParameteriv
Renderbuer Objects [9.2.4]
void BindRenderbuer(enum target,
uint renderbuer);
target: RENDERBUFFER
void {Create, Gen}Renderbuers(sizei n,
uint *renderbuers);
void DeleteRenderbuers(sizei n,
const uint *renderbuers);
boolean IsRenderbuer(uint renderbuer);
void RenderbuerStorageMulsample(
enum target, sizei samples,
enum internalformat, sizei width,
sizei height);
target: RENDERBUFFER
internalformat: See TexImage3DMulsample
void
NamedRenderbuerStorageMulsample(
uint renderbuer, sizei samples,
enum internalformat, sizei width,
sizei height);
internalformat: See TexImage3DMulsample
void RenderbuerStorage(enum target,
enum internalformat, sizei width,
sizei height);
target: RENDERBUFFER
internalformat: See TexImage3DMulsample
void NamedRenderbuerStorage(
uint renderbuer, enum internalformat,
sizei width, sizei height);
internalformat: See TexImage3DMulsample
Renderbuer Object Queries [9.2.6]
void GetRenderbuerParameteriv(
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 GetNamedRenderbuerParameteriv(
uint renderbuer, enum pname,
int *params);
pname: See GetRenderbuerParameteriv
Aaching Renderbuer Images [9.2.7]
void FramebuerRenderbuer(
enum target, enum aachment,
enum renderbuertarget,
uint renderbuer);
target: [DRAW_, READ_]FRAMEBUFFER
aachment: [Table 9.1]
{DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT,
COLOR_ATTACHMENTi where i is
[0, MAX_COLOR_ATTACHMENTS - 1]
renderbuertarget: RENDERBUFFER if renderbuer is
non-zero, else undened
void NamedFramebuerRenderbuer(
uint framebuer, enum aachment,
enum renderbuertarget,
uint renderbuer);
aachment, renderbuertarget: See
FramebuerRenderbuer
Aaching Texture Images [9.2.8]
void FramebuerTexture(enum target,
enum aachment, uint texture, int level);
target: [DRAW_, READ_]FRAMEBUFFER
aachment: See FramebuerRenderbuer
void NamedFramebuerTexture(
uint framebuer, enum aachment,
uint texture, int level);
aachment: See FramebuerRenderbuer
void FramebuerTexture1D(enum target,
enum aachment, enum textarget,
uint texture, int level);
textarget: TEXTURE_1D
target, aachment: See FramebuerRenderbuer
void FramebuerTexture2D(enum target,
enum aachment, 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}
(unspecied if texture is 0)
target, aachment: See FramebuerRenderbuer
void FramebuerTexture3D(enum target,
enum aachment, enum textarget,
uint texture, int level, int layer);
textarget: TEXTURE_3D (unspecied if texture is 0)
target, aachment: See FramebuerRenderbuer
void FramebuerTextureLayer(enum target,
enum aachment, uint texture,
int level, int layer);
target, aachment: See FramebuerRenderbuer
void NamedFramebuerTextureLayer(
uint framebuer, enum aachment,
uint texture, int level, int layer);
aachment: See FramebuerRenderbuer
Feedback Loops [9.3.1]
void TextureBarrier(void);
Framebuer Completeness [9.4.2]
enum CheckFramebuerStatus(enum target);
target: [DRAW_, READ_]FRAMEBUFFER
returns: FRAMEBUFFER_COMPLETE or a constant
indicang the violang value
enum CheckNamedFramebuerStatus(
uint framebuer, enum target);
target: See CheckFramebuerStatus
Verces
Separate Patches [10.1.15]
void PatchParameteri(enum pname, int value);
pname: PATCH_VERTICES
Current Vertex Aribute Values [10.2]
Use the commands VertexArib*for aributes
of type oat, VertexAribI* for int or uint, or
VertexAribL* for double.
void VertexArib{1234}{s f d}(uint index,
T values);
void VertexArib{123}{s f d}v(uint index,
const T *values);
void VertexArib4{b s i f d ub us ui}v(
uint index, const T *values);
void VertexArib4Nub(uint index, ubyte x,
ubyte y, ubyte z, ubyte w);
void VertexArib4N{b s i ub us ui}v(
uint index, const T *values);
void VertexAribI{1234}{i ui}(uint index,
T values);
void VertexAribI{1234}{i ui}v(uint index,
const T *values);
void VertexAribI4{b s ub us}v(uint index,
const T *values);
void VertexAribL{1234}d(uint index,
const T values);
void VertexAribL{1234}dv(uint index,
const T *values);
void VertexAribP{1234}ui(uint index,
enum type, boolean normalized, uint value);
void VertexAribP{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
VertexAribP4uiv)
Vertex Arrays
Vertex Array Objects [10.3.1]
All states related to denion 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 VertexArrayElementBuer(uint vaobj,
uint buer);
Generic Vertex Aribute Arrays [10.3.2]
void VertexAribFormat(uint aribindex,
int size, enum type, boolean normalized,
unit relaveoset);
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 VertexAribIFormat(uint aribindex,
int size, enum type, unit relaveoset);
type: [UNSIGNED_]BYTE, [UNSIGNED_]SHORT,
[UNSIGNED_]INT
void VertexAribLFormat(uint aribindex,
int size, enum type, unit relaveoset);
type: DOUBLE
void VertexArrayAribFormat(uint vaobj,
uint aribindex, int size, enum type,
boolean normalized, uint relaveoset);
type: See VertexAribFormat
void VertexArrayAribIFormat(uint vaobj,
uint aribindex, int size, enum type,
uint relaveoset);
type: See VertexAribIFormat
void VertexArrayAribLFormat(uint vaobj,
uint aribindex, int size, enum type,
uint relaveoset);
type: See VertexAribLFormat
void BindVertexBuer(uint bindingindex,
uint buer, intptr oset, sizei stride);
void VertexArrayVertexBuer(uint vaobj,
uint bindingindex, uint buer, intptr oset,
sizei stride);
void BindVertexBuers(uint rst,
sizei count, const uint *buers,
const intptr *osets, const sizei *strides);
void VertexArrayVertexBuers(uint vaobj,
uint rst, sizei count, const uint *buers,
const intptr *osets, const sizei *strides);
void VertexAribBinding(uint aribindex,
uint bindingindex);
(Connued 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 TexStorage2DMulsample(
enum target, sizei samples,
enum internalformat, sizei width,
sizei height, boolean xedsamplelocaons);
target: TEXTURE_2D_MULTISAMPLE
void TexStorage3DMulsample(
enum target, sizei samples,
enum internalformat, sizei width,
sizei height, sizei depth,
boolean xedsamplelocaons);
target: TEXTURE_2D_MULTISAMPLE_ARRAY
void TextureStorage2DMulsample(
uint texture, sizei samples,
enum internalformat, sizei width,
sizei height, boolean xedsamplelocaons);
void TextureStorage3DMulsample(
uint texture, sizei samples,
enum internalformat, sizei width,
sizei height, sizei depth,
boolean xedsamplelocaons);
Invalidate Texture Image Data [8.20]
void InvalidateTexSubImage(uint texture,
int level, int xoset, int yoset, int zoset,
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 xoset, int yoset, int zoset,
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 primiveMode);
primiveMode: TRIANGLES, LINES, POINTS
void EndTransformFeedback(void);
void PauseTransformFeedback(void);
void ResumeTransformFeedback(void);
void TransformFeedbackBuerRange(
uint x, uint index, uint buer, intptr oset,
sizeiptr size);
void TransformFeedbackBuerBase(
uint x, uint index, uint buer);
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
Primive 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);
Rasterizaon [13.4, 14]
Enable/Disable/IsEnabled(target);
target: RASTERIZER_DISCARD
Mulsampling [14.3.1]
Use to analias points, and lines.
Enable/Disable/IsEnabled(target);
target: MULTISAMPLE, SAMPLE_SHADING
void GetMulsamplefv(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 Oset [14.6.4-5]
void PolygonMode(enum face, enum mode);
face: FRONT_AND_BACK
mode: POINT, LINE, FILL
void PolygonOset(oat factor, oat units);
Enable/Disable/IsEnabled(target);
target: POLYGON_OFFSET_{POINT, LINE, FILL}
Vertex Aributes [11.1.1]
Vertex shaders operate on array of
4-component items numbered from slot 0 to
MAX_VERTEX_ATTRIBS - 1.
void BindAribLocaon(uint program,
uint index, const char *name);
void GetAcveArib(uint program,
uint index, sizei bufSize, sizei *length,
int *size, enum *type, char *name);
int GetAribLocaon(uint program,
const char *name);
Transform Feedback Variables [11.1.2]
void TransformFeedbackVaryings(
uint program, sizei count,
const char * const *varyings,
enum buerMode);
buerMode:
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 Execuon [11.1.3]
void ValidateProgram(uint program);
void ValidateProgramPipeline(uint pipeline);
Tessellaon Prim. Generaon [11.2.2]
void PatchParameterfv(enum pname,
const oat *values);
pname: PATCH_DEFAULT_INNER_LEVEL,
PATCH_DEFAULT_OUTER_LEVEL
Vertex Arrays (cont.)
void VertexArrayAribBinding(uint vaobj,
uint aribindex, uint bindingindex);
void VertexAribPointer(uint index, int size,
enum type, boolean normalized,
sizei stride, const void *pointer);
type: See VertexAribFormat
void VertexAribIPointer(uint index,
int size, enum type, sizei stride,
const void *pointer);
type: See VertexAribIFormat
index: [0, MAX_VERTEX_ATTRIBS - 1]
void VertexAribLPointer(uint index, int size,
enum type, sizei stride, const void*pointer);
type: DOUBLE
void EnableVertexAribArray(uint index);
void EnableVertexArrayArib(uint vaobj,
uint index);
void DisableVertexAribArray(uint index);
void DisableVertexArrayArib(uint vaobj,
uint index);
Vertex Aribute Divisors [10.3.4]
void VertexBindingDivisor(uint bindingindex,
uint divisor);
void VertexArrayBindingDivisor(uint vaobj,
uint bindingindex, uint divisor);
void VertexAribDivisor(uint index,
uint divisor);
Primive Restart [10.3.6]
Enable/Disable/IsEnabled(target);
target: PRIMITIVE_RESTART[_FIXED_INDEX]
void PrimiveRestartIndex(uint index);
Drawing Commands [10.4]
For all the funcons in this secon:
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 MulDrawArrays(enum mode,
const int *rst, const sizei *count,
sizei drawcount);
void MulDrawArraysIndirect(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 MulDrawElements(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 MulDrawElementsIndirect(
enum mode, enum type,
const void *indirect, sizei drawcount,
sizei stride);
void MulDrawElementsBaseVertex(
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 GetVertexArib{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 GetVertexAribI{i ui}v(uint index,
enum pname, T *params);
pname: See GetVertexArib{d f i}v
void GetVertexAribLdv(uint index,
enum pname, double *params);
pname: See GetVertexArib{d f i}v
void GetVertexAribPointerv(uint index,
enum pname, const void **pointer);
pname: VERTEX_ATTRIB_ARRAY_POINTER
Condional Rendering [10.9]
void BeginCondionalRender(uint id,
enum mode);
mode: QUERY _[NO_]WAIT[_INVERTED],
QUERY_BY_REGION_[NO_]WAIT[_INVERTED]
void EndCondionalRender(void);
Fragment Shaders
[15.2]
void BindFragDataLocaonIndexed(
uint program, uint colorNumber,
uint index, const char *name);
void BindFragDataLocaon(uint program,
uint colorNumber, const char *name);
int GetFragDataLocaon(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 Operaons
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 boom, sizei width, sizei height);
void ScissorIndexedv(uint index, int *v);
void Scissor(int le, int boom, sizei width,
sizei height);
Mulsample 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,
biield 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 Buer 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 BlendEquaon(enum mode);
void BlendEquaonSeparate(enum modeRGB,
enum modeAlpha);
modeRGB, modeAlpha: MIN, MAX ,
FUNC_{ADD, SUBTRACT, REVERSE_SUBTRACT}
void BlendEquaoni(uint buf, enum mode);
void BlendEquaonSeparatei(uint buf,
enum modeRGB, enum modeAlpha);
modeRGB, modeAlpha:
See BlendEquaonSeparate
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 Operaon [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 idener, uint name,
sizei length, const char *label);
idener: 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 *severies, sizei *lengths,
char *messageLog);
void GetObjectLabel(enum idener,
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
(Connued on next page)
Whole Framebuer
Selecng Buers for Wring [17.4.1]
void DrawBuer(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 NamedFramebuerDrawBuer(
uint framebuer, enum buf);
buf: See DrawBuer
void DrawBuers(sizei n, const enum *bufs);
*bufs: [Tables 17.5-6] {FRONT, BACK}_{LEFT, RIGHT},
NONE, COLOR_ATTACHMENTi (i = [0,
MAX_COLOR_ATTACHMENTS - 1 ])
void NamedFramebuerDrawBuers(
uint framebuer, sizei n,
const enum
*bufs);
*bufs: See DrawBuers
Fine Control of Buer 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 Buers [17.4.3]
void Clear(biield 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 ClearBuer{i f ui}v(enum buer,
int drawbuer, const T *value);
buer: COLOR, DEPTH, STENCIL
void ClearNamedFramebuer{i f ui}v(
uint framebuer, enum buer,
int drawbuer, const T *value);
buer: See ClearBuer{i f ui}v
void ClearBuer(enum buer,
int drawbuer, oat depth, int stencil);
buer: DEPTH_STENCIL
void ClearNamedFramebuer(
uint framebuer, enum buer,
int drawbuer, oat depth, int stencil);
buer: See ClearBueri
Invalidang Framebuers [17.4.4]
void InvalidateSubFramebuer(
enum target, sizei numAachments,
const enum *aachments, int x, int y,
sizei width, sizei height);
target: [DRAW_ , READ_]FRAMEBUFFER
aachments: COLOR_ATTACHMENTi, DEPTH, COLOR,
{DEPTH, STENCIL, DEPTH_STENCIL}_ATTACHMENT,
{FRONT, BACK}_{LEFT, RIGHT}, STENCIL
void InvalidateNamedFramebuerSubData(
uint framebuer, sizei numAachments,
const enum *aachments, int x, int y,
sizei width, sizei height);
aachments: See InvalidateSubFramebuer
void InvalidateFramebuer(
enumtarget, sizei numAachments,
const enum *aachments);
target, *aachments: See InvalidateSubFramebuer
void InvalidateNamedFramebuerData(
uint framebuer, sizei numAachments,
const enum *aachments);
*aachments: See InvalidateSubFramebuer
Reading and Copying Pixels
Reading Pixels [18.2]
void ReadBuer(enum src);
src: NONE, {FRONT, BACK}_{LEFT, RIGHT},
FRONT, BACK, LEFT, RIGHT,
FRONT_AND_BACK, COLOR_ATTACHMENTi
(i = [0, MAX_COLOR_ATTACHMENTS - 1 ])
void NamedFramebuerReadBuer(
uint framebuer, enum src);
src: See ReadBuer
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 BlitFramebuer(int srcX0, int srcY0,
int srcX1, int srcY1, int dstX0, int dstY0,
int dstX1, int dstY1, biield mask,
enum lter);
mask: Bitwise 0 of the bitwise OR of
{COLOR, DEPTH, STENCIL}_BUFFER_BIT
lter: LINEAR, NEAREST
void BlitNamedFramebuer(
uint readFramebuer,
uint drawFramebuer, int srcX0,
int srcY0, int srcX1, int srcY1, int dstX0,
int dstY0, int dstX1, int dstY1,
biield mask, enum lter);
mask, lter: See BlitFramebuer
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
secon [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 funcon to synchronize invocaons in a work group:
void barrier();
Use the memoryBarrier* or groupMemoryBarrier funcons to order
reads/writes accessible to other invocaons:
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 speciy work groups and invocaons:
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 GetInternalformav(enum target,
enum internalformat, enum pname,
sizei bufSize, int *params);
target, pname, internalformat:
See GetInternalforma64v
void GetInternalforma64v(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 framebuer 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 illustraon
show the OpenGL pipeline and indicate
data ow.
Blue blocks indicate various buers
that feed or get fed by the OpenGL
pipeline.
Green blocks indicate xed funcon
stages.
Yellow blocks indicate programmable
stages.
Texture binding
Buer binding
T
B
Vertex & Tessellaon Details
Each vertex is processed either by a vertex shader
or xed-funcon vertex processing (compability
only) to generate a transformed vertex, then
assembled into primives. Tessellaon (if enabled)
operates on patch primives, consisng of a xed-
size collecon of verces, each with per-vertex
aributes and associated per-patch aributes.
Tessellaon control shaders (if enabled) transform
an input patch and compute per-vertex and per-
patch aributes for a new output patch.
A xed-funcon primive generator
subdivides the patch according to
tessellaon levels computed in the
tessellaon control shaders or specied
as xed values in the API (TCS disabled).
The tessellaon evaluaon shader
computes the posion and aributes of
each vertex produced by the tessellator.
Orange blocks indicate features of the Core
specicaon.
Purple blocks indicate features of the
Compability specicaon.
Green blocks indicate features new or
signicantly changed with OpenGL 4.x.
Geometry & Follow-on Details
Geometry shaders (if enabled) consume
individual primives built in previous primive
assembly stages. For each input primive,
the geometry shader can output zero or more
verces, with each vertex directed at a specic
vertex stream. The verces emied to each
stream are assembled into primives according
to the geometry shader’s output primive type.
Transform feedback (if acve) writes selected
vertex aributes of the primives of all vertex
streams into buer objects aached to one or
more binding points.
Primives on vertex stream zero are then
processed by xed-funcon stages, where they
are clipped and prepared for rasterizaon.
Orange blocks indicate features of the Core
specicaon.
Purple blocks indicate features of the
Compability specicaon.
Green blocks indicate features new or
signicantly 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 funcon return value
bool Boolean
int, uint signed/unsigned integers
oat single-precision oang-point
scalar
double double-precision oang scalar
vec2, vec3, vec4 oang point vector
dvec2, dvec3, dvec4 double precision oang-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
Floang-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
samplerBuer
imageBuer
buer 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
Connue
Signed Integer Opaque Types (contd)
iimage2DRect
int.
2D rectangular image
isampler[1,2]DArray integer 1D, 2D array texture
iimage[1,2]DArray integer 1D, 2D array image
isamplerBuer integer buer texture
iimageBuer integer buer 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
usamplerBuer
uint buer texture
uimageBuer
uint buer image
usampler2DMS
uint 2D mul-sample texture
uimage2DMS
uint 2D mul-sample image
usampler2DMSArray
uint 2D mul-sample array tex.
Connue
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
Aggregaon 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[];
// oponal variable declaraon
Blocks in/out/uniform block-name {
// interface matching by block name
oponally-qualied members
} instance-name[];
// oponal instance name, oponally an array
Qualiers
Storage Qualiers [4.3]
Declaraons may have one storage qualier.
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 applicaon
buer
accessible by shaders and OpenGL API
shared
compute shader only, shared among work
items in a local work group
Auxiliary Storage Qualiers
Use to qualify some input and output variables:
centroid
centroid-based interpolaon
sampler
per-sample interpolaon
patch
per-tessellaon-patch aributes
Interface Blocks [4.3.9]
in, out, uniform, and buer variable
declaraons can be grouped. For example:
uniform Transform {
// allowed restatement qualier:
mat4 ModelViewMatrix;
uniform mat3 NormalMatrix;
};
Layout Qualiers [4.4]
The following table summarizes the use of layout qualiers applied to non-opaque types and the kinds of declaraons they may be applied to.
Op = Opaque types only, FC = gl_FragCoord only, FD = gl_FragDepth only.
Layout Qualier
Qualif.
Only Indiv.
Va r. Block Block
Mem.
Allowed Interfaces
shared, packed, std{140, 430}
X X
uniform/buer
{row, column}_major
X X X
binding =
Op
X
oset =
X
align =
X X
locaon =
Xuniform/buer and
subroune variables
locaon =
X X X all in/out, except for
compute
component =
X X
index =
Xfragment out and
subroune funcons
triangles, quads, isolines
X
tessellaon evaluaon
in
equal_spacing,
fraconal_even_spacing,
fraconal_odd_spacing
X
cw, ccw
X
point_mode
X
points
Xgeometry in/out
[ points ], lines, triangles,
{triangles, lines}_adjacency
Xgeometry in
invocaons =
Xgeometry in
Layout Qualier
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_{buer, stride} =
X X X X vertex, tessellaon, and
geometry out
x_oset =
X X X
verces =
Xtessellaon control out
[ points ], line_strip,
triangle_strip
X
geometry out
max_verces =
X
stream =
X X X X
depth_{any, greater,
less, unchanged}
FD
fragment out
Opaque Uniform Layout Qualiers [4.4.6]
Used to bind opaque uniform variables to specic buers or units.
binding = integer-constant-expression
Atomic Counter Layout Qualiers
binding = integer-constant-expression
oset = integer-constant-expression
(Connued 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, tessellaon control, tessellaon evaluaon,
geometry, fragment, and compute shaders.
[n.n.n] and [Table n.n] refer to secons and tables in
the OpenGL Shading Language 4.50 specicaon at
www.opengl.org/registry
Operators and Expressions
[5.1]
The following operators are numbered in order
of precedence. Relaonal and equality operators
evaluate to Boolean. Also See lessThan(), equal().
1. ( )
parenthecal grouping
2.
[ ]
( )
.
++ --
array subscript
funcon call, constructor, structure
eld, selector, swizzle
posix increment and decrement
3. ++ --
+ - ~ !
prex increment and decrement
unary
4 . * / %
mulplicave
5. + -
addive
6. << >>
bit-wise shi
7. < > <= >=
relaonal
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 enre operand
16.
= += -=
*= /=
%= <<= >>=
&= ^= |=
assignment
arithmec assignments
17. ,
sequence
Vector & Scalar Components [5.5]
In addion to array numeric subscript syntax,
names of vector and scalar components are
denoted by a single leer. 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 prole
Required when using version 4.50.
prole is core, compability, 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 Direcves
##dene #elif #else #endif #error #extension
#if #ifdef #ifndef #line #pragma #undef #version
Predened Macros
__LINE__ __FILE__
Decimal integer constants.
__FILE__
says
which source string is being processed.
__VERSION__
Decimal integer, e.g.: 450
GL_core_prole
Dened as 1
GL_es_prole
1 if the ES prole is supported
GL_compability_prole
Dened as 1 if the implementaon
supports the compability prole.
www.opengl.org/registry
©2014 Khronos Group - Rev. 0814
Page 10 OpenGL Shading Language 4.50 Reference Card
Operaons 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 subscripng 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 operaons 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 mulply
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 Operaons [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.:
diuseColor += lightIntensity[3]*NdotL;
Statements and Structure
Subrounes [6.1.2]
Subroune type variables are assigned to funcons
through the UniformSubrounesuiv command in the
OpenGL API.
Declare types with the subroune keyword:
subroune returnType subrouneTypeName(type0
arg0,
type1 arg1, ..., typen argn);
Associate funcons with subroune types of
matching declaraons by dening the funcons
with the subroune keyword and a list of
subroune types the funcon matches:
subroune(subrouneTypeName0,
...,
subrouneTypeNameN)
returnType
funconName(type0 arg0,
type1 arg1, ..., type
n
arg
n
)
{
... }
// funcon body
Declare subroune type variables with a specic
subroune type in a subroune uniform variable
declaraon:
subroune
uniform subrouneTypeName
subrouneVarName;
Iteraon and Jumps [6.3-4]
Funcon
call by value-return
Iteraon for (;;) { break, connue }
while ( ) { break, connue }
do { break, connue } while ( );
Selecon if ( ) { }
if ( ) { } else { }
switch ( ) { case integer: … break; …
default: … }
Entry void main()
Jump break, connue, return
(There is no ‘goto’)
Exit return in main()
discard
// Fragment shader only
Qualiers (connued)
Format Layout Qualiers
One qualier 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
Interpolaon Qualiers [4.5]
Qualify outputs from vertex shader and inputs
to fragment shader.
smooth perspecve correct interpolaon
at no interpolaon
noperspecve linear interpolaon
Parameter Qualiers [4.6]
Input values copied in at funcon call me,
output values copied out at funcon return.
none (default) same as in
in for funcon parameters passed into
funcon
const for funcon parameters that cannot be
wrien to
out for funcon parameters passed back out of
funcon, but not inialized when passed in
inout for funcon parameters passed both into
and out of a funcon
Precision Qualiers [4.7]
Qualify individual variables:
{highp, mediump, lowp} variable-declaraon;
Establish a default precision qualier:
precision {highp, mediump, lowp} {int, oat};
Invariant Qualiers Examples [4.8]
These are for vertex, tessellaon, geometry,
and fragment languages.
#pragma STDGL
invariant(all)
force all output variables
to be invariant
invariant gl_Posion; qualify a previously
declared variable
invariant centroid out
vec3 Color;
qualify as part of a
variable declaraon
Precise Qualier [4.9]
Ensures that operaons are executed in stated
order with operator consistency. For example,
a fused mulply-add cannot be used in the
following; it requires two idencal mulplies,
followed by an add.
precise out vec4 Posion = a * b + c * d;
Memory Qualiers [4.10]
Variables qualied as “image” can have one or
more memory qualiers.
coherent reads and writes are coherent with
other shader invocaons
volale underlying values may be changed by
other sources
restrict won’t be accessed by other code
readonly read only
writeonly write only
Order of Qualicaon [4.11]
When mulple qualiers are present in a
declaraon they may appear in any order, but
must all appear before the type.
The layout qualier is the only qualier that can
appear more than once. Further, a declaraon
can have at most one storage qualier, at most
one auxiliary storage qualier, and at most one
interpolaon qualier.
Mulple memory qualiers can be used. Any
rule violaon will cause a compile-me error.
Built-In Constants [7.3]
The following are provided to all shaders. The
actual values are implementaon-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_MaxComputeAtomicCounterBuers = 1;
const int gl_MaxVertexAribs = 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_MaxTessEvaluaonImageUniforms = 0;
const int gl_MaxGeometryImageUniforms = 0;
const int gl_MaxFragmentImageUniforms = 8;
const int gl_MaxCombinedImageUniforms = 8;
const int gl_MaxFragmentUniformComponents = 1024;
const int gl_MaxDrawBuers = 8;
const int gl_MaxClipDistances = 8;
const int gl_MaxGeometryTextureImageUnits = 16;
const int gl_MaxGeometryOutputVerces = 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_MaxTessEvaluaonInputComponents = 128;
const int gl_MaxTessEvaluaonOutputComponents = 128;
const int gl_MaxTessEvaluaonTextureImageUnits = 16;
const int gl_MaxTessEvaluaonUniformComponents = 1024;
const int gl_MaxTessPatchComponents = 120;
const int gl_MaxPatchVerces = 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_MaxTessEvaluaonAtomicCounters = 0;
const int gl_MaxGeometryAtomicCounters = 0;
const int gl_MaxFragmentAtomicCounters = 8;
const int gl_MaxCombinedAtomicCounters = 8;
const int gl_MaxAtomicCounterBindings = 1;
const int gl_MaxVertexAtomicCounterBuers = 0;
const int gl_MaxTessControlAtomicCounterBuers = 0;
const int gl_MaxTessEvaluaonAtomicCounterBuers = 0;
const int gl_MaxGeometryAtomicCounterBuers = 0;
const int gl_MaxFragmentAtomicCounterBuers = 1;
const int gl_MaxCombinedAtomicCounterBuers = 1;
const int gl_MaxAtomicCounterBuerSize = 32;
const int gl_MinProgramTexelOset = -8;
const int gl_MaxProgramTexelOset = 7;
const int gl_MaxTransformFeedbackBuers = 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_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
};
Tessellaon Control Language
Inputs
in gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_in[gl_MaxPatchVerces];
in
int
gl_PatchVercesIn;
in
int
gl_PrimiveID;
in
int
gl_InvocaonID;
Outputs
out gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_out[];
patch
out
oat
gl_TessLevelOuter[4];
patch
out
oat
gl_TessLevelInner[2];
Tessellaon Evaluaon Language
Inputs
in gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_in[gl_MaxPatchVerces];
in int gl_PatchVercesIn;
in int gl_PrimiveID;
in vec3
gl_TessCoord;
patch in
oat gl_TessLevelOuter[4];
patch in
oat
gl_TessLevelInner[2];
Outputs
out gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
};
Geometry Language
Inputs
in gl_PerVertex {
vec4
gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
} gl_in[];
in int gl_PrimiveIDIn;
in int gl_InvocaonID;
Outputs
out gl_PerVertex {
vec4 gl_Posion;
oat
gl_PointSize;
oat
gl_ClipDistance[];
oat
gl_CullDistance[];
};
out
int
gl_PrimiveID;
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_PrimiveID;
in
int
gl_SampleID;
in
vec2
gl_SamplePosion;
in
int
gl_SampleMaskIn[];
in
int
gl_Layer;
in
int
gl_ViewportIndex;
in
bool
gl_HelperInvocaon;
Outputs
out
oat
gl_FragDepth;
out
int
gl_SampleMask[];
Compute Language
More informaon in diagram on page 6.
Inputs
Work group dimensions
in uvec3 gl_NumWorkGroups;
const uvec3 gl_WorkGroupSize;
in uvec3 gl_LocalGroupSize;
Work group and invocaon IDs
in uvec3 gl_WorkGroupID;
in uvec3 gl_LocalInvocaonID;
Derived variables
in uvec3 gl_GlobalInvocaonID;
in uint gl_LocalInvocaonIndex;
www.opengl.org/registry ©2014 Khronos Group - Rev. 0814
OpenGL Shading Language 4.50 Reference Card Page 11
Built-In Funcons
Angle & Trig. Funcons [8.1]
Funcons will not result in a divide-by-zero
error. If the
divisor of a rao is 0, then results
will be undened. Component-wise operaon.
Parameters specied 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
Exponenal Funcons [8.2]
Component-wise operaon.
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 Funcons [8.3]
Component-wise operaon. 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, implementaon-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 fraconal 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)
(Connue )
Common Funcons (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 posive or negave innity:
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 operaon
when using precise:
Tfd fma(Tfd a, Tfd b, Tfd c)
Splits x into a oang-point signicand in the range [0.5, 1.0)
and an integer exponent of 2:
Tfd frexp(Tfd x, out Ti exp)
Builds a oang-point number from x and the corresponding
integral exponent of 2 in exp:
Tfd ldexp(Tfd x, in Ti exp)
Floang-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 representaon of v:
uvec2 unpackDouble2x32(double v)
Returns a uint by converng the components of a two-
component oang-point vector:
uint packHalf2x16(vec2 v)
Returns a two-component oang-point vector:
vec2 unpackHalf2x16(uint v)
Geometric Funcons [8.5]
These funcons 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 reect(Tfd I, Tfd N)reecon direcon
I - 2 * dot(N,I) * N
Tfd refract(Tfd I, Tfd N,
oat eta)refracon vector
Matrix Funcons [8.6]
N and M are 1, 2, 3, 4.
mat matrixCompMult(mat x, mat y)
dmat matrixCompMult(dmat x, dmat y)
component-wise
mulply
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 Relaonal Funcons [8.7]
Compare x and y component-wise. Sizes of the
input and return vectors for any parcular 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 Funcons [8.8]
Component-wise operaon.
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 dierence if non-negave,
otherwise 2
32
plus the dierence:
Tu usubBorrow(Tu x, Tu y, out Tu borrow)
(Connue )
Integer Funcons (cont.)
Mulplies 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 [oset, oset + bits - 1] from value, returns
them in the least signicant bits of the result:
Tiu biieldExtract(Tiu value, int oset, int bits)
Returns the reversal of the bits of value:
Tiu
biieldReverse(
Tiu
value)
Inserts the bits least-signicant bits of insert into base:
Tiu biieldInsert(Tiu base, Tiu insert,
int oset, int bits)
Returns the number of bits set to 1:
Ti
bitCount(
Tiu
value)
Returns the bit number of the least signicant bit:
Ti
ndLSB(
Tiu
value)
Returns the bit number of the most signicant bit:
Ti ndMSB(Tiu value)
Texture Lookup Funcons [8.9]
Available to vertex, geometry, and fragment
shaders. See tables on next page.
Atomic-Counter Funcons [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 Funcons [8.11]
Operates on individual integers in buer-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 Funcons [8.12]
In the image funcons 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
gimageBuer 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,Buer} 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 specied by image:
void imageStore(writeonly IMAGE_PARAMS, gvec4 data)
(Connued on next page)
Type Abbreviaons for Built-in Funcons: 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 funcon, type sizes and dimensionality must correspond aer 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 Funcons [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 derivave for each
dimension of the sampler.
Texture Query Funcons [8.9.1]
textureSize funcons 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{Buer,2DMS[Array]}sampler)
{int,ivec2,ivec3} textureSize(
sampler{1D, 2D, 2DRect,Cube[Array]}Shadow sampler[,
int lod])
ivec3 textureSize(samplerCubeArray sampler, int lod)
textureQueryLod funcons return the mipmap
array(s) that would be accessed in the x
component of the return value. Returns the
computed level of detail relave 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 funcons 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 Funcons [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 projecon.
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)
Oset added before texture lookup.
gvec4 textureOset(
gsampler{1D[Array],2D[Array,Rect],3D} sampler,
{oat,vec2,vec3} P, {int,ivec2,ivec3} oset [, oat bias])
oat textureOset(
sampler{1D[Array],2D[Rect,Array]}Shadow sampler,
{vec3, vec4} P, {int,ivec2} oset [, 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{Buer, 2DMS[Array]} sampler,
{int,ivec2,ivec3} P[, int sample])
Fetch single texel with oset added before texture lookup.
gvec4 texelFetchOset(
gsampler{1D[Array],2D[Array],3D} sampler,
{int,ivec2,ivec3} P, int lod, {int,ivec2,ivec3} oset)
gvec4 texelFetchOset(
gsampler2DRect sampler, ivec2 P, ivec2 oset)
Projecve texture lookup
with oset added before
texture lookup.
gvec4 textureProjOset(gsampler{1D,2D[Rect],3D} sampler,
vec{2,3,4} P, {int,ivec2,ivec3} oset [, oat bias])
oat textureProjOset(
sampler{1D,2D[Rect]}Shadow sampler, vec4 P,
{int,ivec2} oset [, oat bias])
Oset texture lookup with explicit LOD.
gvec4 textureLodOset(
gsampler{1D[Array],2D[Array],3D} sampler,
{oat,vec2,vec3} P, oat lod, {int,ivec2,ivec3} oset)
oat textureLodOset(
sampler{1D[Array],2D}Shadow sampler, vec3 P, oat lod,
{int,ivec2} oset)
Projecve 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)
Oset projecve texture lookup with explicit LOD.
gvec4 textureProjLodOset(gsampler{1D,2D,3D} sampler,
vec{2,3,4} P, oat lod, {int, ivec2, ivec3} oset)
oat textureProjLodOset(sampler{1D,2D}Shadow sampler,
vec4 P, oat lod, {int, ivec2} oset)
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 oset.
gvec4 textureGradOset(
gsampler{1D[Array],2D[Rect,Array],3D} sampler,
{oat,vec2,vec3} P, {oat,vec2,vec3} dPdx,
{oat,vec2,vec3} dPdy, {int,ivec2,ivec3} oset)
oat textureGradOset(
sampler{1D[Array],2D[Rect,Array]}Shadow sampler,
{vec3,vec4} P, {oat,vec2} dPdx, {oat,vec2}dPdy,
{int,ivec2} oset)
Texture lookup both projecvely 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 projecvely and with explicit gradient
as in textureProjGrad, as well as with oset as in
textureOset.
gvec4 textureProjGradOset(
gsampler{1D,2D[Rect],3D} sampler, vec{2,3,4} P,
{oat,vec2,vec3} dPdx, {oat,vec2,vec3} dPdy,
{int,ivec2,ivec3} oset)
oat textureProjGradOset(
sampler{1D,2D[Rect]Shadow} sampler, vec4 P,
{oat,vec2} dPdx, {oat,vec2} dPdy, {ivec2,int,vec2} oset)
Texture Gather Instrucons [8.9.3]
These funcons take components of a oang-point
vector operand as a texture coordinate, determine
a set of four texels to sample from the base level of
detail of the specied 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 oset as
described in textureOset except minimum and
maximum oset values are given by
{MIN, MAX}_PROGRAM_TEXTURE_GATHER_OFFSET.
gvec4 textureGatherOset(gsampler2D[Array,Rect] sampler,
{vec2,vec3} P, ivec2 oset [, int comp])
vec4 textureGatherOset(
sampler2D[Array,Rect]Shadow sampler,
{vec2,vec3} P, oat refZ, ivec2 oset)
Texture gather as in textureGatherOset except osets
determines locaon of the four texels to sample.
gvec4 textureGatherOsets(gsampler2D[Array,Rect] sampler,
{vec2,vec3} P, ivec2 osets[4] [, int comp])
vec4 textureGatherOsets(
sampler2D[Array,Rect]Shadow sampler,
{vec2,vec3} P, oat refZ, ivec2 osets[4])
Built-In Funcons (cont.)
Image Funcons (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)
(Connue )
Image Funcons (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 Funcons [8.13]
Available only in fragment shaders.
Tf=oat, vecn.
Derivave fragment-processing funcons
Tf dFdx(Tf p)
Tf dFdy(Tf p)
derivave in x and y, either
ne or coarse derivaves
Tf dFdxFine(Tf p)
Tf dFdyFine(Tf p)
ne derivave in x and y per
pixel-row/column derivave
Tf dFdxCoarse(Tf p)
Tf dFdyCoarse(Tf p)
coarse derivave in x and y per
2x2-pixel derivave
Tf fwidth(Tf p)
Tf fwidthFine(Tf p)
Tf fwidthCoarse(Tf p)
sum of absolute values of x and y
derivaves
Interpolaon fragment-processing funcons
Return value of
interpolant
sampled inside pixel and the
primive:
Tf interpolateAtCentroid(Tf interpolant)
Return value of
interpolant
at locaon of sample #
sample
:
Tf interpolateAtSample(Tf interpolant, int sample)
Return value of
interpolant
sampled at xed oset
oset
from pixel center:
Tf interpolateAtOset(Tf interpolant, vec2 oset)
Noise Funcons [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 Funcons [8.15]
Only available in geometry shaders.
Emits values of output variables to current output
primive stream stream
:
void EmitStreamVertex(int stream)
Completes current output primive stream stream and
starts a new one
:
void EndStreamPrimive(int stream)
(Connue )
Geometry Shader Funcons (cont’d)
Emits values of output variables to the current output
primive
:
void EmitVertex()
Completes output primive and starts a new one
:
void EndPrimive()
Other Shader Funcons [8.16-17]
See diagram on page 11 for more informaon.
Synchronizes across shader invocaons
:
void barrier()
Controls ordering of memory transacons issued by a
single shader invocaon
:
void memoryBarrier()
Controls ordering of memory transacons as viewed by
other invocaons in a compute work group:
void groupMemoryBarrier()
Order reads and writes accessible to other invocaons:
void memoryBarrierAtomicCounter()
void memoryBarrierShared()
void memoryBarrierBuer()
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 Internaonal, used under license by Khronos Group.
The Khronos Group is an industry consorum creang open standards for the authoring and acceleraon
of parallel compung, graphics and dynamic media on a wide variety of plaorms 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 producon by Miller & Mattson www.millermason.com www.opengl.org/registry
Page 13
A
AcveShaderProgram 2
AcveTexture 2
Angle Funcons 11
Asynchronous Queries 1
Atomic Funcons 11
AachShader 2
B
BeginCondionalRender 5
BeginQuery[Indexed] 1
BeginTransformFeedback 5
BindAribLocaon 5
BindBuer* 1
BindBuer[s]{Base, Range} 1
BindFragDataLocaon[Indexed] 5
BindFramebuer 4
BindImageTexture[s] 4
BindProgramPipeline 2
BindRenderbuer 4
Bind{Sampler, Texture}[s] 2
BindTexture[s] 2
BindTextureUnit 2
BindTransformFeedback 5
BindVertexArray 4
BindVertexBuer[s] 4
BlendColor 6
BlendEquaon[Separate]* 6
BlendFunc[Separate]* 6
Blit[Named]Framebuer 6
Buer[Sub]Data 1
BuerStorage 1
BuerTextures 3
C
Callback 6
Check[Named]FramebuerStatus 4
ClampColor 6
Clear 6
Clear[Named]Buer[Sub]Data 1
ClearBuer* 6
ClearColor 6
ClearDepth* 6
ClearStencil 6
ClearTex[Sub]Image 4
ClientWaitSync 1
Clip Control 5
ColorMask* 6
Command Leers 1
Common Funcons 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]BuerSubData 1
CopyImageSubData 6
CopyTex[Sub]Image* 3
CopyTextureSubImage* 3
CreateBuers 1
CreateFrameBuers 4
CreateProgram[Pipelines] 2
CreateQueries* 1
CreateRenderBuers 4
CreateSamplers* 2
CreateShader 1
CreateShaderProgramv 2
Createtextures* 2
CreateTransformFeedbacks 5
CreateVertexArrays 4
CullFace 5
D
DebugMessage* 6
DeleteBuers 1
DeleteFramebuers 4
DeleteProgram[Pipelines] 2
DeleteQueries 1
DeleteRenderbuers 4
DeleteSamplers 2
DeleteShader 1
DeleteSync 1
DeleteTextures 2
DeleteTransformFeedbacks 5
DeleteVertexArrays 4
DepthFunc 6
DepthMask 6
DepthRange* 5
Derivave Funcons 12
DetachShader 2
DisableVertexArrayArib 5
DisableVertexAribArray 5
DispatchCompute* 5
Dithering 6
DrawArrays* 5
DrawBuer[s] 6
Draw[Range]Elements* 5
DrawTransformFeedback* 5
E
EnableVertexArrayArib 5
EnableVertexAribArray 5
EndCondionalRender 5
EndQuery[Indexed] 1
EndQuery 6
EndTransformFeedback 5
Errors 1
Exponenal Funcons 11
F
Feedback Loops 4
FenceSync 1
Finish 1
Flatshading 5
Floang-Point Pack/Unpack Func. 11
Flush 1
FlushMapped* 1
Fragment Language Variables 10
Fragment Processing Funcons 12
Fragment Shaders 5
Framebuer Objects 4
FramebuerParameteri 4
FramebuerRenderbuer 4
FramebuerTexture* 4
FrontFace 5
G
GenBuers 1
Generate[Texture]Mipmap 3
GenFramebuers 4
GenProgramPipelines 2
GenQueries 1
GenRenderbuers 4
GenSamplers 2
GenTextures 2
GenTransformFeedbacks 4
GenVertexArrays 4
Geometric Funcons 11
Geometry & Follow-on Diagram 8
Geometry Shader Funcons 12
GetAcveAtomicCounterBuer* 2
GetAcveArib 5
GetAcveSubroune* 2
GetAcveUniform* 2
GetAachedShaders 2
GetAribLocaon 5
GetBoolean* 6
GetBuerParameter* 1
GetBuer{Pointerv, SubData} 1
Get[n]CompressedTexImage 3
GetCompressedTexSubImage 3
GetCompressedTextureImage 3
GetDebugMessageLog 6
GetDouble* 6
GetError 1
GetFloat* 6
GetFragData* 5
GetFramebuer* 4
GetGraphicsResetStatus 1
GetInteger* 7
GetInteger64* 7
GetInternalformat* 7
GetMulsamplefv 5
GetNamedBuer[Indexed] 1
GetNamedFramebuer 4
GetNamedRenderbuer 4
GetObject[Ptr]Label 6
GetPointerv 6-7
GetProgram* 2
GetQuery* 1
GetRenderbuerParameteriv 4
GetSamplerParameter* 2
GetShader* 2
GetString* 6
GetSubroune* 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, Arib}* 5
GL Command Syntax 1
H
Hint 6
I
Image Funcons 11
Integer Funcons 11
Interpolaon Funcons 12
Interpolaon Qualiers 10
InvalidateBuer* 1
Invalidate[Sub]Framebuer 6
InvalidateNamedFramebuer 6
InvalidateTex[Sub]Image 4
Invariant Qualiers 10
IsBuer 1
IsFramebuer 4
IsProgram[Pipeline] 5
IsQuery 1
IsRenderbuer 4
IsSampler 2
IsShader 1
IsSync 1
IsTexture 2
IsTransformFeedback 5
IsVertexArray 4
Iteraon and Jumps 10
L
Layout Qualiers 9
LineWidth 5
LinkProgram 2
LogicOp 6
M
Macros 9
Map[Named]Buer* 1
Matrix Operaons 10
Matrix Funcons 11
MemoryBarrier 2
MemoryBarrier 12
Memory Qualiers 10
MinSampleShading 5
MulDraw{Arrays, Elements}* 5
Mulsample Fragment Ops 6
Mulsample Textures 3
Mulsampling 5
N
NamedBuer 1
NamedFramebuerDraw 6
NamedFramebuer 4
NamedFramebuerReadBuer 6
NamedRenderbuerStorage 4
Noise Funcons 12
O
Object[Ptr]Label 5
Occlusion Queries 6
Operators 9
P
Pack/Unpack Funcons 11
Parameter Qualiers 10
PatchParameter 5
PauseTransformFeedback 5
Per-Fragment Operaons 6
Pipeline Diagram 8
PixelStore{if} 2
PointParameter* 5
PointSize 5
Polygon{Mode, Oset} 5
{Pop, Push}DebugGroup 6
Precise & Precision Qualiers 10
Preprocessor 9
Primive Clipping 5
PrimiveRestartIndex 5
ProgramBinary 2
Program Objects 2
ProgramParameteri 2
ProgramUniform[Matrix]* 2
ProvokingVertex 5
Q
Qualiers 9
QueryCounter 1
R
Rasterizaon 5
ReadBuer 6
Read[n]Pixels 6
ReleaseShaderCompiler 1
Renderbuer Object Queries 4
RenderbuerStorage* 4
ResumeTransformFeedback 5
S
SampleCoverage 5
SampleMaski 5
SamplerParameter* 2
Sampler Queries 2
Scissor* 6
Shaders and Programs 1-2
Shader Funcons 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 Qualiers 9
Structures 10
Subroune Uniform Variables 2
Subrounes 10
Synchronizaon 1
T
Tessellaon Diagram 7
Tessellaon Variables 10
TexBuer* 3
Texel Lookup Funcons 12
TexImage*[Mulsample] 3
TexParameter* 3
TexStorage* 3
TexStorage*[Mulsample] 4
TexSubImage* 3
TextureBarrier 4
TextureBuer[Range] 3
Texture Funcons 12
Texture Queries 3
TextureStorage*[Mulsample] 4
TextureSubImage 3
TextureView 3
Texture View/State Diagram 7
Timer Queries 1
Transform Feedback 5
TransformFeedbackVaryings 5
Types 9
U
Uniform Qualiers 9-10
Uniform Variables 2
Uniform* 2
UniformBlockBinding 2
Uniform[Matrix]* 2
UniformSubrounesuiv 2
Unmap[Named]Buer 1
UseProgram[Stages] 2
V
ValidateProgram[Pipeline] 5
Vector & Matrix 10
Vector Relaonal Funcons 11
Vertex & Tessellaon Diagram 8
Vertex Arrays 4-5
VertexArib* 4
Vertex[Array]Arib* 4
VertexArrayBindingDivisor 5
VertexArray*Buer 4
VertexArib*Format 4
VertexArib*Pointer 5
VertexArib[Binding, Divisor] 4-5
VertexBindingDivisor 4
Vertex Language Variables 10
Viewport* 5
W
WaitSync 1

Navigation menu