opengl44 quick reference card
TRANSCRIPT
-
8/12/2019 Opengl44 Quick Reference Card
1/12www.opengl.org/regis2013 Khronos Group - Rev. 0713
OpenGL 4.4 API Reference Card Page
OpenGL OperaonFloang-Point Numbers [2.3.3]
16-Bit1-bit sign, 5-bit exponent,10-bit manssa
Unsigned 11-Bitno sign bit, 5-bit exponent,6-bit manssa
Unsigned 10-Bitno sign bit, 5-bit exponent,5-bit manssa
Command Leers [Tables 2.1, 2.2]Where a leer from the table below is used todenote type in a funcon name, T within theprototype 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)
OpenGLis the only cross-plaorm graphics API that enables developers ofsoware for PC, workstaon, and supercompung hardware to create high-performance, visually-compelling graphics soware applicaons, in marketssuch as CAD, content creaon, energy, entertainment, game development,manufacturing, medical, and virtual reality. Specicaons are available atwww.opengl.org/registry
see FunctonNamerefers to funcons on this reference card.
[n.n.n]and[Table n.n] refer to secons and tables in the OpenGL 4.4 core specicaon.
[n.n.n]refers to secons in the OpenGL Shading Language 4.40 specicaon.
OpenGL Command Syntax [2.2]GL commands are formed from a return type, a name, and oponally up to 4 characters(or character pairs) from the Command Leers table (to the le), as shown by the prototype:
return-typeName{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 namesuxes. Nis 1, 2, 3, or 4 if present. If v is present, an array of Nitems is passed by a pointer.For brevity, the OpenGL documentaon and this reference may omit the standard prexes.
The actual names are of the forms: glFunconName(), GL_CONSTANT, GLtype
OpenGL Errors [2.3.1] enum GetError(void); Returns the numeric error code.
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, sizeilength);
Program Objects[7.3]uint CreateProgram(void);
void AachShader(uintprogram, uint shader);
void DetachShader(uintprogram,uint shader);
void LinkProgram(uintprogram);
void UseProgram(uintprogram);
uint CreateShaderProgramv(enum type,sizei count, const char * const * strings);
void ProgramParameteri(uintprogram,enumpname, int value);
pname: PROGRAM_SEPARABLE,PROGRAM_BINARY_RETRIEVABLE_HINT
value: TRUE, FALSE
void DeleteProgram(uintprogram);
boolean IsProgram(uintprogram);
Program Interfaces[7.3.1]void GetProgramInterfaceiv(uintprogram,
enumprogramInterface, enumpname,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(uintprogram, enumprogramInterface,const char *name);
void GetProgramResourceName(uintprogram, enumprogramInterface,uint index, sizei bufSize, sizei *length,char *name);
void GetProgramResourceiv(uintprogram,enumprogramInterface, uint index,sizeipropCount, const enum *props,sizei bufSize, sizei *length, int *params);
*props: [see Table 7.2]
int GetProgramResourceLocaon(uintprogram, enumprogramInterface,const char *name);
int GetProgramResourceLocaonIndex(uintprogram, enumprogramInterface,const char *name);
(Connued on next page
SynchronizaonFlush and Finish [2.3.2]void Flush(void);void Finish(void);
Sync Objects and Fences [4.1]void DeleteSync(sync sync);
sync FenceSync(enum condion,biieldags);
condion: SYNC_GPU_COMMANDS_COMPLETEags: must be 0
boolean IsSync(sync sync);
Waing for Sync Objects [4.1.1]enum ClientWaitSync(sync sync,
biieldags, uint64 meout_ns);ags: SYNC_FLUSH_COMMANDS_BIT, or zero
void WaitSync(sync sync, biieldags,uint64 meout);
meout: TIMEOUT_IGNORED
Sync Object Queries [4.1.3]void GetSynciv(sync sync, enumpname,
sizei bufSize, sizei *length, int *values);pname: OBJECT_TYPE,
SYNC_{STATUS, CONDITION, FLAGS}
Timer Queries[4.3]Timer queries use query objects to track theamount of me needed to fully complete a setof GL commands.
void QueryCounter(uint id, TIMESTAMP);
void GetInteger64v (TIMESTAMP, int64 *data);
Asynchronous Queries [4.2, 4.2.1]void GenQueries(sizei n, uint *ids);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, enumpname,int *params);
target: see BeginQuery, plus TIMESTAMP
pname: CURRENT_QUERY, QUERY_COUNTER_BITSvoid GetQueryIndexediv(enum target,
uint index, enumpname, int *params);target: see BeginQuery
pname:CURRENT_QUERY,QUERY_COUNTER_BITS
voidGetQueryObjecv(uint id,enumpname, int *params);
void GetQueryObjectuiv(uint id,enumpname, uint *params);
void GetQueryObjec64v(uint id,enumpname, int64 *params);
void GetQueryObjectui64v(uint id,enumpname, uint64 *params);
pname: QUERY_RESULT{_AVAILABLE},QUERY_RESULT_NO_WAIT
Buer Objects [6]void GenBuers(sizei n, uint *buers);
void DeleteBuers(sizei n,const uint *buers);
Create and Bind Buer Objects[6.1]void BindBuer(enum target, uint buer);
target:[Table 6.1] {ARRAY, UNIFORM}_BU FFER,ATOMIC_COUNTER_BUFFER,COPY_{READ, WRITE}_BUFFER,{DISPATCH, DRAW}_INDIRECT_BUFFER,
ELEMENT_ARRAY_BUFFER,PIXEL_[UN]PACK_BUFFER,{QUERY, TEXTURE}_BUFFER,SHADER_STORAGE_BUFFER,TRANSFORM_FEEDBACK_BUFFER
void BindBuerRange(enum target,uint index, uint buer, intptr oset,sizeiptr size);
target: ATOMIC_COUNTER_BUFFER,{SHADER_STORAGE, UNIFORM}_BUFFER,TRANSFORM_FEEDBACK_BUFFER
void BindBuerBase(enum target,uint index, uint buer);
target:see BindBuerRange
void BindBuersRange(enum target,uintrst, sizei count, const uint *buers,const intptr *osets, const sizeiptr *size);
target:see BindBuerRange
void BindBuersBase(enum target,uintrst, sizei count, const uint *buers);
target:see BindBuerRange
Create, Modify Buer Object Data [6.2]void BuerStorage(enum target,
sizeiptr size, const void *data,biieldags);
target:see BindBuerags: Bitwise OR of MAP_{READ, WRITE}_BIT,
{DYNAMIC, CLIENT}_STORAGE_BIT,MAP_{COHERENT, PERSISTENT}_BIT
void BuerData(enum target, sizeiptr size,const void *data, enum usage);
target:see BindBuerusage: DYNAMIC_{DRAW, READ, COPY},
STATIC_{DRAW, READ, C OPY},STREAM_{DRAW, READ, COPY}
void BuerSubData(enum target,intptr oset, sizeiptr size,const void *data);
target:see BindBuer
void ClearBuerSubData(enum target,enum internalFormat, intptr oset,sizeiptr size, enumformat, enum type,const void *data);
target:see BindBuerinternalformat:see TexBuer on pg. 3 of this card
format: RED, GREEN, BLUE, RG, RGB, RGBA, BGR,BGRA,{RED, GREEN, BLUE, RG, RGB}_INTEGER,{RGBA, BGR, BGRA} _INTEGER, STENCIL_INDEX,DEPTH_{COMPONENT, STENCIL}
void ClearBuerData(enum target,enum internalformat, enumformat,enum type, const void *data);
target, internalformat, format:seeClearBuerSubData
Map/Unmap Buer Data [6.3]void *MapBuerRange(enum target,
intptr oset, sizeiptr length,biield access);access: The logical OR of MAP_X_BIT, whereXmay
be READ, WRITE, PERSISTENT, COHERENT,INVALIDATE_{BUFFER, RANGE},FLUSH_EXPLICIT, UNSYNCHRONIZED
target:see BindBuer
void *MapBuer(enum target,enum access);
access: see MapBuerRange
void FlushMappedBuerRange(enum target, intptr oset, sizeiptr length);
target:see BindBuer
boolean UnmapBuer(enum target);target:see BindBuer
Invalidate Buer Data [6.5]void InvalidateBuerSubData(uint buer,
intptr oset, sizeiptr length);
void InvalidateBuerData(uint buer);
Copy Between Buers [6.6]void CopyBuerSubData(enum readtarget,
enum writetarget, intptr readoset,intptr writeoset, sizeiptr size);
readtargetand writetarget: see BindBuer
Buer Object Queries [6, 6.7]boolean IsBuer(uint buer);
void GetBuerParameteriv(enum target,enumpname, int *data);
target: see BindBuerpname: [Table 6.2]BUFFER_SIZE, BUFFER_USAGE,BUFFER_{ACCESS[_FLAGS], BUFFER_MAPPED,BUFFER_MAP_{OFFSET, LENGTH},BUFFER_IMMUTABLE_STORAGE, BUFFER_ACCESS_FLAGS
void GetBuerParameteri64v(enum target,enumpname, int64 *data);
target: see BindBuer
pname: see GetBuerParameteriv
void GetBuerSubData(enum target,intptr oset, sizeiptr size, void *data);
target: see BindBuer
void GetBuerPointerv(enum target,enumpname, const void **params);
target: see BindBuer
pname: BUFFER_MAP_POINTER
http://www.opengl.org/registryhttp://www.opengl.org/registryhttp://www.opengl.org/registry -
8/12/2019 Opengl44 Quick Reference Card
2/12www.opengl.org/registr013 Khronos Group - Rev. 0713
age 2 OpenGL 4.4 API Reference Card
extures and Samplers [8]oid AcveTexture(enum texture);exture: TEXTUREi(whereiis
[0, max(MAX_TEXTURE_COORDS,MAX_COMBINED_TEXTURE_IMAGE_UNITS)-1])
exture Objects [8.1]oid GenTextures(sizei n, uint *textures);
oid BindTexture(enum target, uint texture);arget: TEXTURE_{1D, 2D}[_ARRAY],
TEXTURE_{3D, RECTANGLE, BUFFER},TEXTURE_CUBE_MAP[_ARRAY],
TEXTURE_2D_MULTISAMPLE[_ARRAY]oid BindTextures(uintrst, sizei count, const
uint *textures);arget: see BindTexture
oid DeleteTextures(sizei n,const uint *textures);
oolean IsTexture(uint texture);
ampler Objects [8.2]oid GenSamplers(sizei count, uint *samplers);
oid BindSampler(uint unit, uint sampler);
oid BindSamplers(uintrst, sizei count,const uint *samplers);
oid SamplerParameter{i f}(uint sampler,enumpname, Tparam);
name: 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,enumpname, const T *param);
pname: see SamplerParameter{if}
void SamplerParameterI{i ui}v(uint sampler,enumpname, 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, enumpname, T *params);pname: see SamplerParameter{if}
void GetSamplerParameterI{i ui}v(uint sampler, enumpname, T *params);
pname: see SamplerParameter{if}
Pixel Storage Modes [8.4.1]void PixelStore{i f}(enumpname, Tparam);pname:[Tables 8.1, 18.1] [UN]PACK_X whereXmay be
SWAP_BYTES, LSB_FIRST, ROW_LENGTH,SKIP_{IMAGES, PIXELS, ROWS}, ALIGNMENT,IMAGE_HEIGHT, COMPRESSED_BLOCK_WIDTH,COMPRESSED_BLOCK_{HEIGHT, DEPTH, SIZE}
Texture Image Spec. [8.5]void TexImage3D(enum target, int level,
int internalformat, sizei width, sizei height,sizei depth, int border, enumformat,
enum type, const void *data);target: [PROXY_]TEXTURE_CUBE_MAP_ARRAY,
[PROXY_]TEXTURE_3D, [PROXY_]TEXTURE_2D_ARRAY
internalformat: STENCIL_INDEX, RED,DEPTH_{COMPONENT, STENCIL}, RG, RGB, RGBA,COMPRESSED_{RED, RG, RGB, RGBA, SRGB,SRGB_ALPHA), a sized internal format from [Tables8.12 - 8.13], or a specic compressed format in[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, enumformat,enum type, const void *data);
target: [PROXY_]TEXTURE_{2D, RECTANGLE},[PROXY_]TEXTURE_1D_ARRAY,PROXY_TEXTURE_CUBE_MAPTEXTURE_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,enumformat, enum type,const void *data);
target:TEXTURE_1D, PROXY_TEXTURE_1Dtype, internalformat, format: see TexImage3D
Alternate Texture Image Spec. [8.6]void CopyTexImage2D(enum target,
int level, enum internalformat, intx,
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, intx,int y, sizei width, int border);
target: TEXTURE_1D
internalformat:see TexImage3D
void TexSubImage3D(enum target, int level,intxoset, int yoset, int zoset,sizei width, sizei height, sizei depth,enumformat, 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,intxoset, int yoset, sizei width,sizei height, enumformat, enum type,const void *data);
target: see CopyTexImage2D
format, type: see TexImage3D
void TexSubImage1D(enum target, int level,intxoset, sizei width, enumformat,enum type, const void *data);
target: TEXTURE_1D
format, type: see TexImage3D
void CopyTexSubImage3D (enum target,int level, intxoset, int yoset, int zoset,intx, int y, sizei width, sizei height);
target: see TexSubImage3D
void CopyTexSubImage2D (enum target,int level, intxoset, int yoset, intx,
int y, sizei width, sizei height);target: see TexImage2D
(Connued on next page >)
haders and Programs (cont.)
rogram Pipeline Objects[7.4]oid GenProgramPipelines(sizei n,
uint *pipelines);
oid DeleteProgramPipelines(sizei n,const uint *pipelines);
oolean IsProgramPipeline(uintpipeline);
oid BindProgramPipeline(uintpipeline);
oid UseProgramStages(uintpipeline,biield stages, uintprogram);
tages: ALL_SHADER_BITS or the bitwise OR ofTESS_{CONTROL, EVALUATION}_SHADER_BIT,
{VERTEX, GEOMETRY, FRAGMENT}_SHADER_BIT,COMPUTE_SHADER_BIT
oid AcveShaderProgram(uintpipeline,uintprogram);
rogram Binaries[7.5]oid GetProgramBinary(uintprogram,
sizei bufSize, sizei *length,enum *binaryFormat, void *binary);
oid ProgramBinary(uintprogram,enum binaryFormat, const void *binary,sizei length);
niform Variables[7.6]t GetUniformLocaon(uintprogram,
const char *name);
oid GetAcveUniformName(uintprogram,uint uniformIndex, sizei bufSize,sizei *length, char *uniformName);
oid GetUniformIndices(uintprogram,sizei uniformCount,const char **uniformNames,uint *uniformIndices);
oid GetAcveUniform(uintprogram,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]
oid GetAcveUniformsiv(uintprogram,sizei uniformCount,const uint *uniformIndices, enumpname,int *params);
name: [Table 7.6] UNIFORM_{NAME_LENGTH, TYPE},UNIFORM_{SIZE, BLOCK_INDEX, UNIFORM_OFFSET},UNIFORM_{ARRAY, MATRIX}_STRIDE,UNIFORM_IS_ROW_MAJOR, UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX
nt GetUniformBlockIndex(uintprogram,const char *uniformBlockName);
void GetAcveUniformBlockName(uintprogram, uint uniformBlockIndex,sizei bufSize, sizei length,char *uniformBlockName);
void GetAcveUniformBlockiv(uintprogram, uint uniformBlockIndex,enumpname, int *params);
pname: UNIFORM_BLOCK_{BINDING, DATA_SIZE},UNIFORM_BLOCK_NAME_LENGTH, UNIFORM_BLOCK_ACTIVE_UNIFORMS[_INDICES],UNIFORM_BLOCK_REFERENCED_BY_X_SHADER,whereXmay be one of VERTEX, FRAGMENT,COMPUTE, GEOMETRY, TESS_CONTROL, orTESS_EVALUATION [Table 7.7]
void GetAcveAtomicCounterBueriv(
uintprogram, uint buerIndex,enumpname, int *params);
pname:see GetAcveUniformBlockiv, howeverreplace the prex UNIFORM_BLOCK_withATOMIC_COUNTER_BUFFER_
Load Uniform Vars. In Default Uniform Blockvoid Uniform{1234}{i f d ui}(int locaon,
T value);
void Uniform{1234}{i f d ui}v(int locaon,sizei count, const T *value);
void UniformMatrix{234}{f d}v(int locaon, sizei count, boolean transpose,const oat *value);
void UniformMatrix{2x3,3x2,2x4,4x2,3x4,4x3}{fd}v(int locaon, sizei count,boolean transpose, const oat *value);
void ProgramUniform{1234}{i f d}(
uintprogram, int locaon, T value);void ProgramUniform{1234}{i f d}v(
uintprogram, int locaon, sizei count,const T *value);
void ProgramUniform{1234}uiv(uintprogram, int locaon, sizei count,const T *value);
void ProgramUniform{1234}ui(uintprogram, int locaon, T value);
void ProgramUniformMatrix{234}{f d}v(uintprogram, int locaon, sizei count,boolean transpose, const T *value);
void ProgramUniformMatrixf{2x3,3x2,2x4,4x2, 3x4, 4x3}{f d}v(uintprogram, int locaon, sizei count,boolean transpose, const T *value);
Uniform Buer Object Bindings
void UniformBlockBinding(uintprogram,uint uniformBlockIndex,uint uniformBlockBinding);
Shader Buer Variables[7.8]void ShaderStorageBlockBinding(
uintprogram, uint storageBlockIndex,uint storageBlockBinding);
Subroune Uniform Variables[7.9]Parameter shadertypefor the funcons in thissecon may be one ofTESS_{CONTROL, EVALUATION}_SHADER,{COMPUTE, VERTEX}_SHADER,{FRAGMENT, GEOMETRY}_SHADER
int GetSubrouneUniformLocaon(uintprogram, enum shadertype,const char *name);
uint GetSubrouneIndex(uintprogram,
enum shadertype, const char *name);void GetAcveSubrouneName(
uintprogram, enum shadertype,uint index, sizei bufsize, sizei *length,char *name);
void GetAcveSubrouneUniformName(uintprogram, enum shadertype,uint index, sizei bufsize, sizei *length,char *name);
void GetAcveSubrouneUniformiv(uintprogram, enum shadertype,uint index, enumpname, int *values);
pname: [NUM_]COMPATIBLE_SUBROUTINES
void UniformSubrounesuiv(enum shadertype, sizei count,const uint *indices);
Shader Memory Access [7.12.2]
See diagram on page 6 for more informaon.
void MemoryBarrier(biield barriers);barriers: ALL_BARRIER_BITS or the OR of
X_BARRIER_BIT whereXmay be: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,QUERY_BUFFER
Shader|Program Queries [7.13]void GetShaderiv(uint shader, enumpname,
int *params);pname: SHADER_TYPE, INFO_LOG_LENGTH, {DELETE,
COMPILE}_STATUS, COMPUTE_SHADER, SHADER_SOURCE_LENGTH
void GetProgramiv(uintprogram,
enumpname, 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,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,VALIDATE_STATUS
void GetProgramPipelineiv(uintpipeline,enumpname, int *params);
pname: ACTIVE_PROGRAM, VALIDATE_STATUS,{VERTEX, FRAGMENT, GEOMETRY}_SHADER,TESS_{CONTROL, EVALUATION}_SHADER,INFO_LOG_LENGTH, COMPUTE_SHADER
void GetAachedShaders(uintprogram,sizei maxCount, sizei *count,uint *shaders);
void GetShaderInfoLog(uint shader,sizei bufSize, sizei *length, char *infoLog);
void GetProgramInfoLog(uintprogram,sizei bufSize, sizei *length, char *infoLog);
void GetProgramPipelineInfoLog(uintpipeline, sizei bufSize,sizei *length, char *infoLog);
void GetShaderSource(uint shader,sizei bufSize, sizei *length, char *source);
void GetShaderPrecisionFormat(enum shadertype, enumprecisiontype,int *range, int *precision);
shadertype: {VERTEX, FRAGMENT}_SHADERprecisiontype: {LOW, MEDIUM, HIGH}_{ FLOAT, INT}
void GetUniform{f d i ui}v(uintprogram,int locaon, T *params);
void GetUniformSubrouneuiv(enum shadertype, int locaon,uint *params);
void GetProgramStageiv(uint program,enum shadertype, enumpname,int *values);
pname: ACTIVE_SUBROUTINES,ACTIVE_SUBROUTINES_XwhereXmay beUNIFORMS, MAX_LENGTH, UNIFORM_LOCATIONS,UNIFORM_MAX_LENGTH
-
8/12/2019 Opengl44 Quick Reference Card
3/12
-
8/12/2019 Opengl44 Quick Reference Card
4/12www.opengl.org/registr013 Khronos Group - Rev. 0713
age 4 OpenGL 4.4 API Reference Card
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 BeginTransformFeedback(enumprimiveMode);
primiveMode: TRIANGLES, LINES, POINTS
void EndTransformFeedback(void);
void PauseTransformFeedback(void);
void ResumeTransformFeedback(void);
Transform Feedback Drawing[13.2.3]void DrawTransformFeedback(
enum mode, uint id);mode: see Drawing Commands [10.5]above
void DrawTransformFeedbackInstanced(enum mode, uint id,sizei instancecount);
void DrawTransformFeedbackStream(enum mode, uint id, uint stream);
voidDrawTransformFeedbackStreamInstanced(enum mode, uint id, uint stream,sizei instancecount);
Flatshading[13.4]void ProvokingVertex(enumprovokeMode);provokeMode: {FIRST, LAST}_VERTEX_CONVENTION
Primive Clipping [13.5]Enable/Disable/IsEnabled(target);
target: DEPTH_CLAMP, CLIP_DISTANCEi wherei = [0..MAX_CLIP_DISTANCES - 1]
Controlling Viewport [13.6.1]void DepthRangeArrayv(uintrst,
sizei count, const double *v);
void DepthRangeIndexed(uint index,double n, doublef);
void DepthRange(double n, doublef);
void DepthRangef(oat n, oatf);
void ViewportArrayv(uintrst, sizei count,constoat *v);
void ViewportIndexedf(uint index, oatx,
oat y, oat w, oat h);
void ViewportIndexedfv(uint index,const oat *v);
void Viewport(intx, int y, sizei w, sizei h);
Rasterizaon [13.4, 14]Enable/Disable/IsEnabled(target);
target: RASTERIZER_DISCARD
Mulsampling [14.3.1]Use to analias points, and lines.
Enable/Disable/IsEnabled(target);target: MULTISAMPLE, SAMPLE_SHADING
void GetMulsamplefv(enumpname,
uint index, oat *val);pname: SAMPLE_POSITION
void MinSampleShading(oat value);
Points [14.4]void PointSize(oat size);
void PointParameter{i f}(enumpname,Tparam);
pname, param: see PointParameter{if}v
void PointParameter{i f}v(enumpname, constT *params);
pname: POINT_FADE_THRESHOLD_SIZE,POINT_SPRITE_COORD_ORIGIN
param, params: The fade threshold ifpnameisPOINT_FADE_THRESHOLD_SIZE;{LOWER, UPPER}_LEFT ifpnameisPOINT_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
(Connued on next page >)
Verces
eparate Patches [10.1.15]oid PatchParameteri(enumpname,
int value);name: PATCH_VERTICES
urrent Vertex Aribute Values [10.2]ecify generic aributes with componentstype oat (VertexArib*), int or uintertexAribI*), or double (VertexAribL*).
void VertexArib{1234}{s f d}(uint index,T values);
void VertexArib{123}{s f d}v(uint index,const T *values);
void VertexArib4{b s i f d ub us ui}v(uint index, const T *values);
void VertexArib4Nub(uint index, T values);
void VertexArib4N{b s i ub us ui}v(uint index, const T *values);
void VertexAribI{1234}{i ui}(uint index,T values);
void VertexAribI{1234}{i ui}v(uint index,const T *values);
void VertexAribI4{b s ub us}v(uint index,const T *values);
void VertexAribL{1234}d(uint index,T values);
void VertexAribL{1234}dv(uint index,const T *values);
void VertexAribP{1234}ui (uint index,enum type, boolean normalized,uint value);
void VertexAribP{1234}uiv (uint index,enum type, boolean normalized,const uint *value);
type: [UNSIGNED_]INT_2_10_10_10_REV,UNSIGNED_INT_10F_11F_11F_REV
ertex Aributes[11.1.1]rtex shaders operate on array ofomponent items numbered from slot 0 to
AX_VERTEX_ATTRIBS - 1.
id BindAribLocaon(uintprogram,uint index, const char *name);
id GetAcveArib(uintprogram,uint index, sizei bufSize, sizei *length,int *size, enum *type, char *name);
GetAribLocaon(uintprogram,const char *name);
ansform Feedback Variables[11.1.2]id TransformFeedbackVaryings(uintprogram, sizei count,const char * const *varyings, enumbuerMode);
uferMode: {INTERLEAVED, SEPARATE}_ATTRIBS
id GetTransformFeedbackVarying(uintprogram, uint index, sizei bufSize,sizei *length, sizei *size, enum *type,char *name);ype returns NONE, FLOAT[_VECn],DOUBLE[_VECn], [UNSIGNED_]INT,[UNSIGNED_]INT_VEC n, MATnxm,{FLOAT, DOUBLE}_{MATn, MATnxm}
ader Execuon [11.1.3]id ValidateProgram(uintprogram);
id ValidateProgramPipeline(uintpipeline);
ssellaon Control Shaders [11.2.2]
id PatchParameterfv(enumpname,const oat *values);name: PATCH_DEFAULT_{INNER, OUTER} _LEVEL
Vertex Arrays
eneric Vertex Aribute Arrays [10.3.1]oid VertexAribFormat(uint aribindex,int size, enum type, boolean normalized,unit relaveoset);
ype: [UNSIGNED_]BYTE, [UNSIGNED_]SHORT,[UNSIGNED_]INT, [HALF_]FLOAT, DOUBLE, FIXED,[UNSIGNED_]INT_2_10_10_10_REV,UNSIGNED_INT_10F_11F_11F_REV
oid VertexAribIFormat(uint aribindex,int size, enum type, unit relaveoset);
ype: [UNSIGNED_]BYTE, [UNSIGNED_]SHORT,[UNSIGNED_]INT
oid VertexAribLFormat(uint aribindex,int size, enum type, unit relaveoset);
ype: DOUBLE
oid BindVertexBuer(uint bindingindex,uint buer, intptr oset, sizei stride);
oid BindVertexBuers(uintrst,sizei count, const uint *buers,const intptr *osets, const sizei *strides);
oid VertexAribBinding(uint aribindex,uint bindingindex);
oid VertexAribPointer(uint index, int size,enum type, boolean normalized,sizei stride, const void *pointer);
ype: see VertexAribFormat
oid VertexAribIPointer(uint index,int size, enum type, sizei stride,const void *pointer);
ype: see VertexAribIFormat
ndex: [0, MAX_VERTEX_ATTRIBS - 1]
oid VertexAribLPointer(uint index, int size,enum type, sizei stride, const void*pointer);
ype: DOUBLEndex: [0, MAX_VERTEX_ATTRIBS - 1]
void EnableVertexAribArray(uint index);
void DisableVertexAribArray(uint index);
index: [0, MAX_VERTEX_ATTRIBS - 1]
Vertex Aribute Divisors [10.3.2]void VertexBindingDivisor(uint bindingindex,
uint divisor);
void VertexAribDivisor(uint index,uint divisor);
Primive Restart [10.3.5]Enable/Disable/IsEnabled(target);
target: PRIMITIVE_RESTART{_FIXED_INDEX}
void PrimiveRestartIndex(uint index);
Vertex Array Objects [10.4]All states related to denion of data used byvertex processor is in a vertex array object.
void GenVertexArrays(sizei n, uint *arrays);
void DeleteVertexArrays(sizei n,const uint *arrays);
void BindVertexArray(uint array);
boolean IsVertexArray (uint array);
Drawing Commands [10.5]For all the funcons in this secon:
mode: POINTS, LINE_STRIP, LINE_LOOP, LINES,TRIANGLE_{STRIP, FAN}, TRIANGLES, PATCHES,LINES_ADJACENCY, TRIANGLES_ADJACENCY, {LINE,TRIANGLE}_STRIP_ADJACENCY,
type: UNSIGNED_{BYTE, SHORT, INT}
void DrawArrays(enum mode, intrst,sizei count);
void DrawArraysInstancedBaseInstance(enum mode, intrst, sizei count,sizei instancecount, uint baseinstance);
void DrawArraysInstanced(enum mode,intrst, sizei count, sizei instancecount);
void DrawArraysIndirect(enum mode,const void *indirect);
void MulDrawArrays(enum mode,const int *rst, const sizei *count,sizei drawcount);
void MulDrawArraysIndirect(enum mode,const void *indirect, sizei drawcount,sizei stride);
void DrawElements(enum mode, sizei count,enum type, const void *indices);
void DrawElementsInstancedBaseInstance(enum mode, sizei count, enum type,const void *indices, sizei instancecount,uint baseinstance);
void DrawElementsInstanced(enum mode,sizei count, enum type, const void *indices,sizei instancecount);
void MulDrawElements(enum mode,
const sizei *count, enum type,const void * const *indices,sizei drawcount);
void DrawRangeElements(enum mode,uint start, uint end, sizei count,enum type, const void *indices);
void DrawElementsBaseVertex(enum mode,sizei count, enum type, const void *indices,int basevertex);
void DrawRangeElementsBaseVertex(enum mode, uint start, uint end,sizei count, enum type, const void *indices,int basevertex);
void DrawElementsInstancedBaseVertex(enum mode, sizei count, enum type,const void *indices, sizei instancecount,int basevertex);
void DrawElementsInstancedBase-VertexBaseInstance(enum mode,sizei count, enum type,const void *indices, sizei instancecount,int basevertex, uint baseinstance);
void DrawElementsIndirect(enum mode,enum type, const void *indirect);
void MulDrawElementsIndirect(enum mode, enum type,const void *indirect, sizei drawcount,sizei stride);
void MulDrawElementsBaseVertex(enum mode, const sizei *count,enum type, const void *const *indices,sizei drawcount, const int *basevertex);
Vertex Array Queries [10.6]void GetVertexArib{d f i}v(uint index,
enumpname, T *params);pname: CURRENT_VERTEX_ATTRIB or
VERTEX_ATTRIB_ARRAY_XwhereXis one ofBUFFER_BINDING, DIVISOR, ENABLED, INTEGER,LONG, NORMALIZED, SIZE, STRIDE, or TYPE
void GetVertexAribI{i u i}v(uint index,enumpname, T *params);
pname: see GetVertexArib{d f i}v
void GetVertexAribLdv(uint index,enumpname, double *params);
pname: see GetVertexArib{d f i}v
void GetVertexAribPointerv(uint index,enumpname, const void **pointer);
pname: VERTEX_ATTRIB_ARRAY_POINTER
Condional Rendering [10.10]void BeginCondionalRender(uint id,
enum mode);mode: {QUERY_BY_REGION, QUERY}_{WAIT,
NO_WAIT}void EndCondionalRender(void);
-
8/12/2019 Opengl44 Quick Reference Card
5/12
-
8/12/2019 Opengl44 Quick Reference Card
6/12www.opengl.org/registr013 Khronos Group - Rev. 0713
age 6 OpenGL 4.4 API Reference Card
tates (cont.)oid GetInteger64i_v(enum target,
uint index, int64 *data);
oolean IsEnabled(enum cap);
oolean IsEnabledi(enum target, uint index);
ring Queries [22.2]oid GetPointerv(enumpname,
void **params);
byte *GetString(enum name);ame: RENDERER, VENDOR, VERSION,
SHADING_LANGUAGE_VERSION
byte *GetStringi(enum name, uint index);
ame: EXTENSIONS, SHADING_LANGUAGE_VERSIONndex: EXTENSIONS range = [0, NUM_EXTENSIONS - 1]
SHADING_LANGUAGE_VERSION range = [0, NUM_SHADING_LANGUAGE_VERSIONS-1]
Internal Format Queries [22.3]void GetInternalforma64v(enum target,
enum internalformat, enumpname,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,[MANUAL_GENERATE_]MIPMAP, 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,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,
STENCIL_RENDERABLE,TESS_CONTROL_TEXTURE,TESS_EVALUATION_TEXTURE, TEXTURE_COMPRESSED, TEXTURE_COMPRESSED_BLOCK_HEIGHT,TEXTURE_COMPRESSED_BLOCK_WIDTH,TEXTURE_COMPRESSED_BLOCK_SIZE,TEXTURE_GATHER[_SHADOW],[GET_]TEXTURE_IMAGE_FORMAT,[GET_]TEXTURE_IMAGE_TYPE,TEXTURE_SHADOW,TEXTURE_VIEW,VERTEX_TEXTURE,VIEW_COMPATIBILITY_CLASS
void GetInternalformav(enum target,
enum internalformat, enumpname,sizei bufSize, int *params);target, pname, internalformat:
see GetInternalforma64v,
OpenGL Texture Views and Texture Object State
T
exture state set with TextureView()num internalformat // base internal format enum target // texture target
int minlevel // rst level of mipmap uint numlevels // number of mipmap levels
int minlayer // rst layer of array texture uint numlayers // number of layers in array
Texture View Parameters (immutable)
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}_TYPETEXTURE_{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}_FILTERTEXTURE_SRGB_DECODE
TEXTURE_WRAP_{S,T,R}
OpenGL Compute Programming Model and Compute Memory Hierarchy
Use the barrierfuncon to synchronize invocaons in a work group:
void barrier();
Use the memoryBarrier*or groupMemoryBarrier funcons to orderreads/writes accessible to other invocaons:
void memoryBarrier();
void memoryBarrierAtomicCounter();
void memoryBarrierBuffer();
void memoryBarrierImage();
void memoryBarrierShared(); // Only for compute shaders
void groupMemoryBarrier(); // Only for compute shaders
Use the compute shader built-in variables to speciy work groups and invocaons:
in vec3 gl_NumWorkGroups; // Number of workgroups dispatched
const vec3 gl_WorkGroupSize; // Size of each work group for current shader
in vec3 gl_WorkGroupID; // Index of current work group being executed
in vec3 gl_LocalInvocationID; // index of current invocation in a work group
in vec3 gl_GlobalInvocationID; // Unique ID across all work groups and threads. (gl_GlobalInvocationID = gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID)
gl_WorkGroupSize = (4,2,0)
gl_WorkGroupID = (2,0,0)
gl_LocalInvocationID = (1,0,0)
gl_GlobalInvocationID = (9,0,0)
gl_NumWorkGroups = (4,2,0)
-
8/12/2019 Opengl44 Quick Reference Card
7/12www.opengl.org/regis2013 Khronos Group - Rev. 0713
OpenGL 4.4 API Reference Card Page
OpenGL Pipeline
A typical program that uses OpenGL
begins with calls to open a window into
the framebuer into which the program
will draw. Calls are made to allocate a GL
context which is then associated with the
window, then OpenGL commands can be
issued.
The heavy black arrows in this illustraon
show the OpenGL pipeline and indicate
data ow.
Blue blocks indicate various buersthat feed or get fed by the OpenGL
pipeline.
Green blocks indicate xed funconstages.
Yellow blocks indicate programmablestages.
Texture binding
Buer binding
T
B
Vertex & Tessellaon DetailsEach vertex is processed either by a vertex shaderor xed-funcon vertex processing (compabilityonly) to generate a transformed vertex, thenassembled into primives. Tessellaon (if enabled)operates on patch primives, consisng of a xed-size collecon of verces, each with per-vertexaributes and associated per-patch aributes.Tessellaon control shaders (if enabled) transforman input patch and compute per-vertex and per-patch aributes for a new output patch.
A xed-funcon primive generatorsubdivides the patch according totessellaon levels computed in thetessellaon control shaders or speciedas xed values in the API (TCS disabled).
The tessellaon evaluaon shadercomputes the posion and aributes ofeach vertex produced by the tessellator.
Orange blocks indicate features of the Corespecicaon.
Purple blocks indicate features of theCompability specicaon.
Green blocks indicate features new orsignicantly changed with OpenGL 4.x.
Geometry & Follow-on DetailsGeometry shaders (if enabled) consumeindividual primives built in previous primiveassembly stages. For each input primive,the geometry shader can output zero or moreverces, with each vertex directed at a specicvertex stream. The verces emied to eachstream are assembled into primives accordingto the geometry shaders output primive type.
Transform feedback (if acve) writes selectedvertex aributes of the primives of all vertexstreams into buer objects aached to one ormore binding points.
Primives on vertex stream zero are thenprocessed by xed-funcon stages, where theyare clipped and prepared for rasterizaon.
Orange blocks indicate features of the Corespecicaon.
Purple blocks indicate features of theCompability specicaon.
Green blocks indicate features new or
signicantly changed with OpenGL 4.x.
-
8/12/2019 Opengl44 Quick Reference Card
8/12www.opengl.org/registr013 Khronos Group - Rev. 0713
age 8 OpenGL Shading Language 4.40 Reference Card
ypes[4.1]ansparent Types
oid no funcon return value
ool Boolean
t, uint signed/unsigned integers
oat single-precision oang-pointscalar
ouble double-precision oang scalar
ec2, vec3, vec4 oang point vector
vec2, dvec3, dvec4 double precision oang-pointvectors
vec2, bvec3, bvec4 Boolean vectors
ec2, ivec3, ivec4vec2, uvec3, uvec4
signed and unsigned integervectors
at2, mat3, mat4 2x2, 3x3, 4x4 oat matrix
at2x2, mat2x3,at2x4
2-column oat matrix of2, 3, or 4 rows
at3x2, mat3x3,at3x4
3-column oat matrix of2, 3, or 4 rows
at4x2, mat4x3,
at4x4
4-column oat matrix of
2, 3, or 4 rows
mat2, dmat3,mat4
2x2, 3x3, 4x4 double-precisionoatmatrix
mat2x2, dmat2x3,mat2x4
2-col. double-precision oatmatrix of 2, 3, 4 rows
mat3x2, dmat3x3,mat3x4
3-col. double-precision oatmatrix of 2, 3, 4 rows
mat4x2, dmat4x3,mat4x4
4-column double-precision oatmatrix of 2, 3, 4 rows
Floang-Point Opaque Typessampler{1D,2D,3D} image{1D,2D,3D}
1D, 2D, or 3D texture
samplerCube imageCube
cube mapped texture
sampler2DRect image2DRect
rectangular texture
sampler{1D,2D}Arrayimage{1D,2D}Array
1D or 2D array texture
samplerBuerimageBuer
buer texture
sampler2DMSimage2DMS
2D mul-sample texture
sampler2DMSArrayimage2DMSArray
2D mul-sample arraytexture
samplerCubeArrayimageCubeArray
cube map array texture
sampler1DShadowsampler2DShadow
1D or 2D depth texturewith comparison
sampler2DRectShadow rectangular tex. / compare
sampler1DArrayShadowsampler2DArrayShadow
1D or 2D array depthtexture with comparison
samplerCubeShadow cube map depth texture
with comparisonsamplerCubeArrayShadow cube map array depth
texture with comparison
Signed Integer Opaque Typesisampler[1,2,3]D integer 1D, 2D, or 3D texture
iimage[1,2,3]D integer 1D, 2D, or 3D image
isamplerCube integer cube mapped texture
iimageCube integer cube mapped image
isampler2DRect int. 2D rectangular texture
Connue
Signed Integer Opaque Types (contd)iimage2DRect int. 2D rectangular image
isampler[1,2]DArray integer 1D, 2D array texture
iimage[1,2]DArray integer 1D, 2D array image
isamplerBuer integer buer textureiimageBuer integer buer image
isampler2DMS int. 2D mul-sample texture
iimage2DMS int. 2D mul-sample image
isampler2DMSArray int. 2D mul-sample array tex.
iimage2DMSArray int. 2D mul-sample array image
isamplerCubeArray int. cube map array texture
iimageCubeArray int. cube map array image
Unsigned Integer Opaque Typesatomic_uint uint atomic counter
usampler[1,2,3]D uint 1D, 2D, or 3D texture
uimage[1,2,3]D uint 1D, 2D, or 3D image
usamplerCube uint cube mapped texture
uimageCube uint cube mapped image
usampler2DRect uint rectangular texture
uimage2DRect uint rectangular image
usampler[1,2]DArray 1D or 2D array texture
uimage[1,2]DArray 1D or 2D array image
usamplerBuer uint buer texture
uimageBuer uint buer image
usampler2DMS uint 2D mul-sample texture
uimage2DMS uint 2D mul-sample image
usampler2DMSArray uint 2D mul-sample array tex.
Connue
Unsigned Integer Opaque Types (contd)uimage2DMSArray uint 2D mul-sample array image
usamplerCubeArray uint cube map array texture
uimageCubeArray uint cube map array image
Implicit Conversionsint -> uint uvec2 -> dvec2
int , uint -> oat uvec3 -> dvec3int, uint, oat -> double uvec4 -> dvec4ivec2 -> uvec2 vec2 -> dvec2ivec3 -> uve c3 vec3 -> dvec3ivec4 -> uv ec4 vec4 -> dvec4ivec2 -> vec2 mat2 -> dmat2ivec3 -> vec3 mat3 -> dmat3ivec4 -> vec4 mat4 -> dmat4uvec2 -> vec2 mat2x 3 -> dmat2x 3uvec3 -> vec3 mat2x 4 -> dmat2x 4uvec4 -> vec4 mat3x 2 -> dmat3x 2ivec2 -> dvec2 mat3x4 -> dmat3x4
ivec3 -> dvec3 mat4x2 -> dmat4x2
ivec4 -> dvec4 mat4x3 -> dmat4x4
Aggregaon of Basic Types
Arrays oat[3] foo; oat foo[3]; int a [3][2]; // Structures, blocks, and structure members // can be arrays. Arrays of arrays supported.
Structures structtype-name{ members} struct-name[];
// oponal variable declaraon
Blocks in/out/uniformblock-name {// interface matching by block name
oponally-qualied members} instance-name[];
// oponal instance name, oponally an array
Qualiersorage Qualiers[4.3]
eclaraons may have one storage qualier.
one(default) local read/write memory,or input parameter
onst read-only variable
linkage into shader from previous stage
ut linkage out of a shader to next stage
niformlinkage between a shader, OpenGL,and the applicaon
uer accessible by shaders and OpenGL API
haredcompute shader only, shared among workitems in a local work group
uxiliary Storage Qualierse to qualify some input and output variables:
entroid centroid-based interpolaon
mpler per-sample interpolaon
atch per-tessellaon-patch aributes
terface Blocks [4.3.9]out, uniform, and buervariable declaraons
n be grouped. For example:
uniformTransform {mat4 ModelViewMatrix;// allowed restatement qualieruniformmat3 NormalMatrix;
};
Layout Qualiers[4.4] layout(layout-qualiers ) block-declaraon
layout(layout-qualiers) in/out/uniform
layout(layout-qualiers ) in/out/uniformdeclaraon
INPIT/OUTPUT layout qualier for all shaderstages except compute:
locaon = integer-constant-expressioncomponent = integer-constant-expression
TessellaonINPUT: triangles, quads, equal_spacing,
isolines, fraconal_{even,odd}_spacing,cw, ccw, point_mode
OUTPUT:verces =integer-constant-expression
Geometry ShaderINPUT: points, lines, triangles,
{lines,triangles}_adjacency,invocaons = integer-constant-expression
OUTPUT:points, line_strip, triangle_strip,max_verces = integer-constant-expressionstream = integer-constant-expression
Fragment ShaderINPUT: For redeclaring built-in variable
gl_FragCoord: origin_upper_le,pixel_center_integer.
For inonly (not with variable declaraons):early_fragment_tests.
OUTPUT: gl_FragDepth may be redeclaredusing: depth_any, depth_greater,depth_less, depth_unchanged.Addional qualier for Fragment Shaders:index = integer-constant-expression
Compute ShaderINPUT:
local_size_x =integer-constant-expressionlocal_size_y = integer-constant-expressionlocal_size_z =integer-constant-expression
Addional Output Layout Qualiers [4.4.2]
Layout qualiers for Transform Feedback:The vertex, tessellaon, and geometry stagesallow the following on output declaraons:
x_buer = integer-constant-expressionx_oset = integer-constant-expressionx_stride = integer-constant-expression
Uniform Variable Layout Qualiers[4.4.3]
locaon = integer-constant-expression
Subroune Funcon Layout Qualiers[4.4.4]
index = integer-constant-expression
Uniform/Storage Block Layout Qualiers [4.4.5]
Layout qualier ideners for uniform blocks:shared, packed, std140, std340,{row, column}_major,binding = integer-constant-expressionoset = integer-constant-expressionalign = integer-constant-expression
Opaque Uniform Layout Qualiers [4.4.6]
Used to bind opaque uniform variables tospecic buers or units.
binding =integer-constant-expression
Atomic Counter Layout Qualiers
binding = integer-constant-expressionoset =integer-constant-expression
(Connued on next page >)
he OpenGLShading Languageis used to createhaders for each of the programmable processorsontained in the OpenGL processing pipeline.he OpenGL Shading Language is actually severalosely related languages. Currently, theserocessors are the vertex, tessellaon control,essellaon evaluaon, geometry, fragment, andompute shaders.
n.n.n]and[Table n.n] refer to secons andables in the OpenGL Shading Language 4.40pecicaon at www.opengl.org/registry
Operators and Expressions [5.1]e following operators are numbered in orderprecedence. Relaonal and equality operatorsaluate to Boolean. Also see lessThan(), equal().
1. ( ) parenthecal grouping
2.
[ ]( ).
++ --
array subscriptfuncon call, constructor, structureeld, selector, swizzleposix increment and decrement
3.++ --+ - ~ !
prex increment and decrementunary
4. * / % mulplicave
5. + - addive
6. > bit-wise shi
7. < > = relaonal
8. == != equality
9. & bit-wise and
10. ^ bit-wise exclusive or
11. | bit-wise inclusive or
12. && logical and
13. ^^ logical exclusive or
14. | | logical inclusive or
15. ? : selects an enre operand
16.
= += -=*= /=
%= =&= ^= |=
assignmentarithmec assignments
17. , sequence
Vector & Scalar Components [5.5]
In addion to array numeric subscript syntax,names of vector and scalar components aredenoted by a single leer. Components can beswizzled and replicated. Scalars have only anx, r,or scomponent.
{x, y, z, w} Points or normals
{r, g, b, a} Colors
{s, t, p, q} Texture coordinates
Preprocessor[3.3]Preprocessor Direcves
# #dene #elif #if #else#extens ion #vers ion #ifdef #ifndef #undef #error #pragma #line #endif
Preprocessor Operators#version 440
#version 440prole
Required when using version 4.40.proleis core, compability, or es.
#extensionextension_name: behavior
#extension all : behavior
behavior: require, enable, warn,disable
extension_name:extensionsupported by compiler, or all
Predened Macros
__LINE__ __FILE__Decimal integer constants.__FILE__sayswhich source string is being processed.
__VERSION__ Decimal integer, e.g.: 440
GL_core_prole Dened as 1
GL_es_prole1 if the implementaon supports the esprole
GL_compability_proleDened as 1 if the implementaonsupports the compability prole.
http://www.opengl.org/registryhttp://www.opengl.org/registryhttp://www.opengl.org/registry -
8/12/2019 Opengl44 Quick Reference Card
9/12www.opengl.org/regis2013 Khronos Group - Rev. 0713
OpenGL Shading Language 4.40 Reference Card Page
Operaons and ConstructorsVector & 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));
Array Example [5.4.4] const oat c[3];
c.length() // will return the integer 3
Matrix Examples [5.6]Examples of access components of a matrix witharray subscripng syntax:
mat4 m; // m is a matrix
m[1] = vec4(2.0); // sets 2nd col. to all 2.0
m[0][0] = 1.0; // sets upper le element to 1.0
m[2][3] = 2.0; // sets 4th element of 3rd col. to 2.0
Examples of operaons on matrices and vectors
m = f * m; // scalar * matrix component-wise
v = f * v; // scalar * vector component-wise
v = v * v; // vector * vector component-wise
m = m +/- m; // matrix +/- matrix comp.-wise
m = m * m; // linear algebraic mulply
f = dot(v, v); // vector dot product
v = cross(v, v); // vector cross product
Structure & Array Operaons [5.7]Select structure elds or length() method of anarray using the period (.) operator. Other operators
. eld or method selector
== != equality
= assignment
[ ] indexing (arrays only)
Array elements are accessed using the arraysubscript operator ( [ ] ), e.g.:
diuseColor += lightIntensity[3]*NdotL;
Statements and StructureSubrounes [6.1.2]Subroune type variables are assigned to funconsthrough the UniformSubrounesuivcommand in theOpenGL API.
Declare types with the subrounekeyword:
subrounereturnType subrouneTypeName(type0arg0,type1 arg1, ..., typenargn);
Associate funcons with subroune types ofmatching declaraons by dening the funconswith the subrounekeyword and a list ofsubroune types the funcon matches:
subroune(subrouneTypeName0, ...,subrouneTypeNameN)
returnType funconName(type0 arg0,type1 arg1, ..., typenargn){ ... }// funcon body
Declare subroune type variables with a specicsubroune type in a subroune uniform variabledeclaraon:
subrouneuniform subrouneTypeNamesubrouneVarName;
Iteraon and Jumps [6.3-4]Funcon call by value-return
Iteraon for (;;) { break, connue }while ( ) { break, connue }do { break, connue } while ( );
Selecon if ( ) { }if ( ) { } else { }switch ( ) { case integer: break; default: }
Entry void main()
Jump break, connue, return(There is no goto)
Exit return in main()discard // Fragment shader only
Qualiers (connued)Format Layout QualiersOne qualier may be used with variablesdeclared as image to specify the image format.
For tessellaon control shaders:binding = integer-constant-expression,rgba{32,16}f, rg{32,16}f, r{32,16}f,rgba{16,8}, r11f_g11f_b10f, rgb10_a2{ui},rg{16,8}, r{16,8}, rgba{32,16,8}i, rg{32,16,8}i,r{32,16,8}i, rgba{32,16,8}ui, rg{32,16,8}ui,r{32,16,8}ui, rgba{16,8}_snorm,rg{16,8}_snorm, r{16,8}_snorm
Interpolaon Qualiers[4.5]Qualify outputs from vertex shader and inputsto fragment shader.
smooth perspecve correct interpolaon
at no interpolaon
noperspecve linear interpolaon
Parameter Qualiers[4.6]Input values copied in at funcon call m e,output values copied out at funcon return.
none (default) same as in
in for funcon parameters passed intofuncon
const for funcon parameters that cannot bewrien to
out for funcon parameters passed back out offuncon, but not inialized when passed in
inout for funcon parameters passed both intoand out of a funcon
Precision Qualiers [4.7]Qualify individual variables:
{highp, mediump, lowp} variable-declaraon;
Establish a default precision qualier:
precision {highp, mediump, lowp}{int, oat};
Invariant Qualiers Examples[4.8]These are for vertex, tessellaon, geometry,and fragment languages.
#pragma STDGLinvariant(all)
force all output variablesto be invariant
invariantgl_Posion; qualify a previouslydeclared variable
invariant centroid outvec3 Color;
qualify as part of avariable declaraon
Precise Qualier[4.9]Ensures that operaons are executed in statedorder with operator consistency. For example,a fused mulply-add cannot be used in thefollowing; it requires two idencal mulplies,followed by an add.
precise outvec4 Posion = a * b + c * d;
Memory Qualiers[4.10]Variables qualied as image can have one ormore memory qualiers.
coherent reads and writes are coherent withother shader invocaons
volale underlying values may be changed byother sources
restrict wont be accessed by other code
readonly read only
writeonly write only
Order of Qualicaon[4.11]When mulple qualiers are present in adeclaraon they may appear in any order, butmust all appear before the type.
The layout qualier is the only qualier that canappear more than once. Further, a declaraoncan have at most one storage qualier, at mostone auxiliary storage qualier, and at most oneinterpolaon qualier.
Mulple memory qualiers can be used. Anyviolaon of these rules will cause a compile-me error.
Built-In Constants [7.3]
The following are provided to all shaders. Theactual values are implementaon-dependent, butmust be at least the value shown.
const ivec3 gl_MaxComputeWorkGroupCount =
{65535, 65535, 65535} ;
const ivec3 gl_MaxComputeWorkGroupSize [] ={1024, 1024, 64};
const int gl_MaxComputeUniformComponents = 1024;
const int gl_MaxComputeTextureImageUnits = 16;const int gl_MaxComputeImageUniforms = 8;const int gl_MaxComputeAtomicCounters = 8;const int gl_MaxComputeAtomicCounterBuers = 1;
const int gl_MaxVertexAribs = 16;const int gl_MaxVertexUniformComponents = 1024;const int gl_MaxVaryingComponents= 60;const int gl_MaxVertexOutputComponents = 64;
const int gl_MaxGeometryInputComponents = 64;
const int gl_MaxGeometryOutput Components = 128;const int gl_MaxFragmentInputComponents = 128;
const int gl_MaxVertexTextureImageUnits = 16;const int gl_MaxCombinedTextureImageUnits = 80;const int gl_MaxTextureImageUnits = 16;const int gl_MaxImageUnits = 8;const int gl_MaxCombinedImageUni tsAndFragment -
Outputs = 8;const int gl_MaxImageSamples = 0;const int gl_MaxVertexImageUniforms= 0;const int gl_MaxTessControlImageUni forms = 0;const int gl_MaxTessEvaluaonImageUniforms = 0;const int gl_MaxGeometryImageUniforms = 0;
const int gl_MaxFragmentImageUniforms = 8;const int gl_MaxCombinedImageUniforms = 8;const int gl_MaxFragmentUniformComponents = 1024;const int gl_MaxDrawBuers = 8;
const int gl_MaxClipDistances = 8;const int gl_MaxGeometryTextureImageUnits = 16;const int gl_MaxGeometryOutputVerces = 256;
const int gl_MaxGeometryTotalOutputComponents = 1024
const int gl_MaxGeometryUniformComponents = 1024;const int gl_MaxGeometryVaryingComponents = 64;const int gl_MaxTessControlInputComponents = 128;
const int gl_MaxTessControlOutputComponents = 128;const int gl_MaxTessControlTextureImageUnits = 16;const int gl_MaxTessControlUniformComponents = 1024;
const int gl_MaxTessControlTotalOutputComponents = 409
const int gl_MaxTessEvaluaonInputComponents = 128;const int gl_MaxTessEvaluaonOutputComponents = 128const int gl_MaxTessEvaluaonTextureImageUnits = 16;
const int gl_MaxTessEvaluaonUniformComponents = 102const int gl_MaxTessPatchComponents = 120;const int gl_MaxPatchVerces = 32;
const int gl_MaxTessGenLevel = 64;const int gl_MaxViewports = 16;const int gl_MaxVertexUniformVectors = 256;const int gl_MaxFragmentUniformVectors = 256;
const int gl_MaxVaryingVectors = 15;const int gl_MaxVertexAtomicCounters = 0;const int gl_MaxTessControlAtomicCounters = 0;const int gl_MaxTessEvaluaonAtomicCounters = 0;const int gl_MaxGeomet ryAtomicCounters = 0;const int gl_MaxFragmentAtomicCounters = 8;const int gl_MaxCombinedAtomicCounters = 8;
const int gl_MaxAtomicCounterBindings = 1;const int gl_MaxVertexAtomicCounterBuers = 0;const int gl_MaxTessControlAtomicCounterBuers = 0;const int gl_MaxTessEvaluaonAtomicCounterBuers = 0const int gl_MaxGeomet ryAtomicCounterBuers = 0;const int gl_MaxFragmentAtomicCounterBuers = 1;const int gl_MaxCombinedAtomicCounterBuers = 1;const int gl_MaxAtomicCounterBuerSize = 32;const int gl_MinProgramTexelOset = -8;const int gl_MaxProgramTexelOset = 7;
const int gl_MaxTransformFeedbackBuers = 4;const int gl_MaxTransformFeedbackInterleaved -
Components = 64;
Built-In Variables [7]Shaders communicate with xed-funconOpenGL pipeline stages and other shaderexecutables through built-in variables.
Vertex Language
Inputs in int gl_VertexID;
in int gl_InstanceID;
Outputs
out gl_PerVertex { vec4 gl_Posion;
oat gl_PointSize;
oat gl_ClipDistance[];};
Tessellaon Control Language
Inputs
in gl_PerVertex { vec4 gl_Posion;
oat gl_PointSize;oat gl_ClipDistance[];
} gl_in[gl_MaxPatchVerces];
in int gl_PatchVercesIn;in int gl_PrimiveID;in int gl_InvocaonID;
Outputs
out gl_PerVertex { vec4 gl_Posion;
oat gl_PointSize;oat gl_ClipDistance[];
} gl_out[];
patch out oat gl_TessLevelOuter[4];patch out oat gl_TessLevelInner[2];
Tessellaon Evaluaon Language
Inputs
in gl_PerVertex { vec4 gl_Posion;
oat gl_PointSize;oat gl_ClipDistance[];
} gl_in[gl_MaxPatchVerces];
in int gl_PatchVercesIn;in int gl_PrimiveID;in vec3 gl_TessCoord;patch inoat gl_TessLevelOuter[4];patch inoat gl_TessLevelInner[2];
Outputs
out gl_PerVertex { vec4 gl_Posion; oat gl_PointSize; oat gl_ClipDistance[];};
Geometry Language
Inputs
in gl_PerVertex { vec4 gl_Posion;
oat gl_PointSize;oat gl_ClipDistance[];
} gl_in[];
in int gl_PrimiveIDIn;in int gl_InvocaonID;
Outputs
out gl_PerVertex { vec4 gl_Posion;
oat gl_PointSize;oat gl_ClipDistance[];
};
out int gl_PrimiveID;out int gl_Layer;out int gl_ViewportIndex;
Fragment Language
Inputs
in vec4 gl_FragCoord;in bool gl_FrontFacing;in oat gl_ClipDistance[];in vec2 gl_PointCoord;in int gl_PrimiveID;in int gl_SampleID;
in vec2 gl_SamplePosion;in int gl_SampleMaskIn[];in int gl_Layer;in int gl_ViewportIndex;
Outputs
out oat gl_FragDepth;out int gl_SampleMask[];
Compute LanguageMore informaon in diagram on page 6.
Inputs
Work group dimensionsin uvec3 gl_NumWorkGroups;const uvec3 gl_WorkGroupSize;in uvec3 gl_LocalGroupSize;
Work group and invocaon IDsin uvec3 gl_WorkGroupID;in uvec3 gl_LocalInvocaonID;
Derived variables
in uvec3 gl_GlobalInvocaonID;in uint gl_LocalInvocaonIndex;
-
8/12/2019 Opengl44 Quick Reference Card
10/12www.opengl.org/registr013 Khronos Group - Rev. 0713
age 10 OpenGL Shading Language 4.40 Reference Card
uilt-In Funconsngle & Trig. Funcons[8.1]ncons will not result in a divide-by-zeroor. If the divisor of a rao is 0, then resultsl be undened. Component-wise operaon.rameters specied as angleare in units ofdians. Tf=oat, vecn.
radians(Tf degrees) degrees to radians
degrees(Tf radians) radians to degrees
sin(Tf angle) sine
cos(Tf angle) cosine
tan(Tf angle) tangentasin(Tfx) arc sine
acos(Tfx) arc cosine
atan(Tf y, Tfx)
atan(Tf y_over_x)arc tangent
sinh(Tfx) hyperbolic sine
cosh(Tfx) hyperbolic cosine
tanh(Tfx) hyperbolic tangent
asinh(Tfx) hyperbolic sine
acosh(Tfx) hyperbolic cosine
atanh(Tfx) hyperbolic tangent
ponenal Funcons [8.2]mponent-wise operaon. Tf=oat, vecn.= double, dvecn. Tfd= Tf, Td
pow(Tfx, Tf y) xy
exp(Tfx) ex
og(Tfx) ln
exp2(Tfx) 2x
og2(Tfx) log2
sqrt(Tfdx) square root
inversesqrt(Tfdx) inverse square root
mmon Funcons [8.3]
mponent-wise operaon. Tf=oat, vecn.Tb=bool,ecn.Ti=int, ivecn. Tu=uint, uvecn.= double, dvecn. Tfd= Tf, Td. Tiu= Ti, Tu.
turns absolute value:
Tfdabs(Tfdx) Ti abs(Tix)
turns -1.0, 0.0, or 1.0:
Tfdsign(Tfdx) Ti sign(Tix)
turns nearest integer =
bvecnequal(Tvecx, Tvec y)
bvecnequal(bvecnx, bvecny)==
bvecnnotEqual(Tvecx, Tvec y)
bvecnnotEqual(bvecnx, bvecny)!=
bool any(bvecnx) true if any component ofxis true
bool all(bvecnx) true if all comps. ofx are true
bvecnnot(bvecnx) logical complement ofx
Integer Funcons [8.8]Component-wise operaon. Tu=uint, uvecn.Ti=int, ivecn. Tiu=int, ivecn, uint, uvecn.
Adds 32-bit uintxand y, returning the summodulo 232:
Tu uaddCarry(Tux, Tu y, out Tu carry)
Subtractsyfromx, returningthe dierence if non-negave,
otherwise232plus the dierence:Tu usubBorrow(Tux, Tu y, out Tu borrow)
(Connue )
Integer Funcons (cont.)
Mulplies 32-bit integersxand y, producing a 64-bitresult:
void umulExtended(Tux, Tu y, out Tu msb, out Tu lsb)
void imulExtended(Tix, Ti y, out Ti msb, out Ti lsb)
Extracts bits [ofset, ofset+ bits- 1] from value, returns
them in the least signicant bits of the result:
Tiu biieldExtract(Tiuvalue, int ofset, int bits)
Returns the reversal of the bits of value:
TiubiieldReverse(Tiuvalue)
Inserts the bitsleast-signicant bits ofinsertinto base:
Tiu biieldInsert(Tiubase, Tiuinsert, int ofset, int bits)
Returns the number of bits set to 1:
TibitCount(Tiuvalue)
Returns the bit number of the least signicant bit:
TindLSB(Tiuvalue)
Returns the bit number of the most signicant bit:
Ti ndMSB(Tiuvalue)
Texture Lookup Funcons [8.9]Available to vertex, geometry, and fragmentshaders. See tables on next page.
Atomic-Counter Funcons [8.10]Returns the value of an atomic counter.
Atomically increments c then returns its prior value:
uint atomicCounterIncrement(atomic_uintc)
Atomically decrements c then returns its prior value:
uint atomicCounterDecrement(atomic_uintc)
Atomically returns the counter for c:
uint atomicCounter(atomic_uintc)
Atomic Memory Funcons [8.11]
Operates on individual integers in buer-objector shared-variable storage. OPis Add, Min, Max,And, Or, Xor, Exchange, or CompSwap.
uint atomicOP(inout uint mem, uint data)
int atomicOP(inout int mem, int data)
Image Funcons [8.12]In these image funcons, IMAGE_PARAMSmaybe one of the following:
gimage1D image, int Pgimage2D image, ivec2 Pgimage3D image, ivec3 Pgimage2DRect image, ivec2 PgimageCube image, ivec3 PgimageBuer image, int P
gimage1DArray image, ivec2 P
gimage2DArray image, ivec3 PgimageCubeArray image, ivec3 Pgimage2DMS image, ivec2 P,int sample
gimage2DMSArray image, ivec3 P, int sample
Returns the dimensions of the images or images:
int imageSize(gimage{1D,Buer} image)ivec2 imageSize(gimage{2D,Cube,Rect,1DArray,
2DMS} image)ivec3 imageSize(gimage{Cube,2D,2DMS}Array image)vec3 imageSize(gimage3D image)
Loads texel at the coordinate Pfrom the imageunit image:
gvec4 imageLoad(readonly IMAGE_PARAMS)
Stores datainto the texel at the coordinate Pfromthe image specied by image:
void imageStore(writeonly IMAGE_PARAMS, gvec4 data)
(Connued on next page >)
Type Abbreviaons for Built-in Funcons: In vector types, nis 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, ivecn, uint, uvecn. Tvec=vecn, uvecn, ivecn.
Within any one funcon, type sizes and dimensionality must correspond aer implicit typeconversions. For example, oat round(oat) is supported, but oat round(vec4) is not.
-
8/12/2019 Opengl44 Quick Reference Card
11/12www.opengl.org/regis2013 Khronos Group - Rev. 0713
OpenGL Shading Language 4.40 Reference Card Page 1
Texture Funcons [8.9]Available to vertex, geometry, and fragmentshaders. gvec4=vec4, ivec4, uvec4.gsampler* =sampler*, isampler*, usampler*.
The Pargument needs to have enoughcomponents to specify each dimension, arraylayer, or comparison for the selected sampler.The dPdxand dPdyarguments need enoughcomponents to specify the derivave for eachdimension of the sampler.
Texture Query Funcons [8.9.1]textureSize funcons return dimensions of lod(if present) for the texture bound to sampler.Components in return value are lled in with thewidth, height, depth of the texture. For array
forms, the last component of the return value isthe number of layers in the texture array.
{int,ivec2,ivec3} textureSize(gsampler{1D[Array],2D[Rect,Array],Cube} sampler[,int lod])
{int,ivec2,ivec3} textureSize(gsampler{Buer,2DMS[Array]}sampler)
{int,ivec2,ivec3} textureSize(sampler{1D, 2D, 2DRect,Cube[Array]}Shadow sampler[,int lod])
ivec3 textureSize(samplerCubeArray sampler, int lod)
textureQueryLodfuncons return the mipmaparray(s) that would be accessed in the xcomponent of the return value. Returns thecomputed level of detail relave to the base levelin the ycomponent 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)
textureQueryLevelsfuncons return the numberof mipmap levels accessible in the textureassociated with sampler.
int textureQueryLevels(gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler)
int textureQueryLevels(sampler{1D[Array],2D[Array],Cube[Array]}Shadow sampler)
Texel Lookup Funcons [8.9.2]Use texture coordinate Pto do a lookup in the texturebound to sampler. For shadow forms, compareisused as Drefand the array layer comes from P.w.For non-shadow forms, the array layer comes fromthe 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}Shadowsampler,{vec3,vec4} P[, oat bias])
oat texture(gsamplerCubeArrayShadow sampler, vec4 P,oat compare)
Texture lookup with projecon.
gvec4 textureProj(gsampler{1D,2D[Rect],3D}sampler,vec{2,3,4} P[,oat bias])
oat textureProj(sampler{1D,2D[Rect]}Shadow sampler,vec4 P[, oat bias])
Texture lookup as in texturebut with explicit LOD.
gvec4 textureLod(gsampler{1D[Array],2D[Array],3D,Cube[Array]} sampler,{oat,vec2,vec3} P, oat lod)
oat textureLod(sampler{1D[Array],2D}Shadow sampler,vec3 P, oat lod)
Oset added before texture lookup.
gvec4 textureOset(gsampler{1D[Array],2D[Array,Rect],3D}sampler,{oat,vec2,vec3}P, {int,ivec2,ivec3} ofset[, oat bias])
oat textureOset(sampler{1D[Array],2D[Rect,Array]}Shadow sampler,{vec3, vec4}P, {int,ivec2} ofset[, oat bias])
Use integer texture coordinatePto lookup a singletexel from sampler.
gvec4 texelFetch(gsampler{1D[Array],2D[Array,Rect],3D} sampler,{int,ivec2,ivec3} P[, {int,ivec2} lod])
gvec4 texelFetch(gsampler{Buer, 2DMS[Array]} sampler,
{int,ivec2,ivec3} P[, int sample])
Fetch single texel with ofset added before texture lookup.
gvec4 texelFetchOset(gsampler{1D[Array],2D[Array],3D} sampler,{int,ivec2,ivec3} P, int lod, {int,ivec2,ivec3} ofset)
gvec4 texelFetchOset(gsampler2DRect sampler, ivec2 P, ivec2 ofset)
Projecve texture lookup with ofset added beforetexture lookup.
gvec4 textureProjOset(gsampler{1D,2D[Rect],3D} sampler,vec{2,3,4} P, {int,ivec2,ivec3} ofset[, oat bias])
oat textureProjOset(sampler{1D,2D[Rect]}Shadow sampler, vec4 P,{int,ivec2} ofset[, oat bias])
Oset texture lookup with explicit LOD.
gvec4 textureLodOset(gsampler{1D[Array],2D[Array],3D} sampler,{oat,vec2,vec3} P, oat lod, {int,ivec2,ivec3} ofset)
oat textureLodOset(sampler{1D[Array],2D}Shadow sampler, vec3 P, oat lod,
{int,ivec2} ofset)
Projecve texture lookup with explicit LOD.
gvec4 textureProjLod(gsampler{1D,2D,3D} sampler,vec{2,3,4} P, oat lod)
oat textureProjLod(sampler{1D,2D}Shadow sampler,vec4 P, oat lod)
Oset projecve texture lookup with explicit LOD.
gvec4 textureProjLodOset(gsampler{1D,2D,3D} sampler,vec{2,3,4} P, oat lod, {int, ivec2, ivec3} ofset)
oat textureProjLodOset(sampler{1D,2D}Shadow sampler,vec4 P, oat lod, {int, ivec2} ofset)
Texture lookup as in texturebut with explicit gradients.
gvec4 textureGrad(gsampler{1D[Array],2D[Rect,Array],3D,Cube[Array]}sampler,
{oat, vec2, vec3,vec4} P, {oat, vec2, vec3} dPdx,{oat, vec2, vec3} dPdy)
oat textureGrad(sampler{1D[Array],2D[Rect,Array], Cube}Shadow sampler,{vec3,vec4} P, {oat,vec2} dPdx, {oat,vec2, vec3} dPdy)
Texture lookup with both explicit gradient and oset.
gvec4 textureGradOset(gsampler{1D[Array],2D[Rect,Array],3D} sampler,{oat,vec2,vec3} P, {oat,vec2,vec3} dPdx,{oat,vec2,vec3} dPdy, {int,ivec2,ivec3} ofset)
oat textureGradOset(sampler{1D[Array],2D[Rect,Array]}Shadow sampler,{vec3,vec4} P, {oat,vec2} dPdx, {oat,vec2}dPdy,{int,ivec2} ofset)
Texture lookup both projecvely as in textureProj, anwith 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 samplevec4 P, {oat,vec2} dPdx, {oat,vec2} dPdy)
Texture lookup projecvely and with explicit gradientas in textureProjGrad, as well as with oset as intextureOset.
gvec4 textureProjGradOset(gsampler{1D,2D[Rect],3D} sampler, vec{2,3,4} P,{oat,vec2,vec3} dPdx, {oat,vec2,vec3} dPdy,{int,ivec2,ivec3} ofset)
oat textureProjGradOset(sampler{1D,2D[Rect]Shadow} sampler, vec4 P,{oat,vec2} dPdx, {oat,vec2} dPdy, {ivec2,int,vec2} ofset
Texture Gather Instrucons [8.9.3]These funcons take components of a oang-poivector operand as a texture coordinate, determinea set of four texels to sample from the base level odetail of the specied texture image, and return ocomponent from each texel in a four-componentresult vector.
gvec4 textureGather(gsampler{2D[Array,Rect],Cube[Array]}sampler,{vec2,vec3,vec4}P[, int comp])
vec4 textureGather(sampler{2D[Array,Rect],Cube[Array]}Shadowsampler,{vec2,vec3,vec4} P, oat refZ)
Texture gather as in textureGatherby oset asdescribed in textureOsetexcept minimum andmaximum oset values are given by{MIN, MAX}_PROGRAM_TEXTURE_GATHER_OFFSET.
gvec4 textureGatherOset(gsampler2D[Array,Rect]sampler,{vec2,vec3} P, ivec2 ofset[, int comp])
vec4 textureGatherOset(sampler2D[Array,Rect]Shadowsampler,{vec2,vec3} P, oat refZ, ivec2 ofset)
Texture gather as in textureGatherOset exceptofsetsdetermines locaon of the four texels to sample.
gvec4 textureGatherOsets(gsampler2D[Array,Rect] sampler{vec2,vec3} P, ivec2 ofsets[4][, int comp])
vec4 textureGatherOsets(sampler2D[Array,Rect]Shadowsampler,{vec2,vec3} P, oat refZ, ivec2 ofsets[4])
Built-In Funcons (cont.)Image Funcons (cont.)
Adds the value of data to the contents of the selected texel:
uintimageAtomicAdd(IMAGE_PARAMS, uintdata)
int imageAtomicAdd(IMAGE_PARAMS, int data)
Takes the minimum of the value of dataand the contentsof the selected texel:
uint imageAtomicMin(IMAGE_PARAMS, uintdata)
int imageAtomicMin(IMAGE_PARAMS, int data)
Takes the maximum of the value dataand the contentsof the selected texel:
uintimageAtomicMax(IMAGE_PARAMS, uintdata)
int imageAtomicMax(IMAGE_PARAMS, int data)
Performs a bit-wise AND of the value of dataand thecontents of the selected texel:
uint imageAtomicAnd(IMAGE_PARAMS, uintdata)
int imageAtomicAnd(IMAGE_PARAMS, int data)
Performs a bit-wise OR of the value of dataand thecontents of the selectedtexel:
uintimageAtomicOr(IMAGE_PARAMS, uintdata)
int imageAtomicOr(IMAGE_PARAMS, int data)
(Connue )
Image Funcons (cont.)
Performs a bit-wiseexclusive ORof the value of dataandthe contents ofthe selected texel:
uintimageAtomicXor(IMAGE_PARAMS, uintdata)
int imageAtomicXor(IMAGE_PARAMS, int data)
Copies the value of data:
uintimageAtomicExchange(IMAGE_PARAMS, uintdata)
int imageAtomicExchange(IMAGE_PARAMS, int data)
Compares the value of compareand contents ofselectedtexel. If equal, the newvalue is given by data; otherwise,it is taken from theoriginal value loaded from texel:
uintimageAtomicCompSwap(IMAGE_PARAMS,uintcompare, uintdata)
int imageAtomicCompSwap(IMAGE_PARAMS, int compare,
int data)
Fragment Processing Funcons [8.13]Available only in fragment shaders.Tf=oat, vecn.
Derivave fragment-processing funcons
Tf dFdx(Tfp) derivave inx
Tf dFdy(Tfp) derivave in y
Tf fwidth(Tfp)sum of absolute derivave inxand y;abs(dFdx(p)) + abs(dFdy(p));
Interpolaon fragment-processing funcons
Return value of interpolant sampled inside pixel and theprimive:
Tf interpolateAtCentroid(Tf interpolant)
Return value of interpolantat locaon of sample # sample:
Tf interpolateAtSample(Tf interpolant, int sample)
Return value of interpolantsampled at xed oset ofsetfrom pixel center:
Tf interpolateAtOset(Tf interpolant, vec2 ofset)
Noise Funcons [8.14]
Returns noise value. Available to fragment, geometry,and vertex shaders. nis 2, 3, or 4:
oat noise1(Tfx) vecnnoisen(Tfx)
Geometry Shader Funcons [8.15]Only available in geometry shaders.
Emits values of output variables to current outputprimivestream stream:
void EmitStreamVertex(int stream)
Completes current output primivestream stream andstarts a new one:
void EndStreamPrimive (int stream)
(Connue )
Geometry Shader Funcons (contd)
Emits values of output variables to the current outputprimive:
void EmitVertex()
Completes output primive and starts a new one:
void EndPrimive()
Other Shader Funcons [8.16-17]See diagram on page 11 for more informaon.
Synchronizes across shader invocaons:
void barrier()
Controls ordering of memory transacons issued by a
single shaderinvocaon:
void memoryBarrier()
Controls ordering of memory transacons as viewed by
other invocaons in a compute work group:
void groupMemoryBarrier()
Order reads and writes accessible to other invocaons:
void memoryBarrierAtomicCounter()
void memoryBarrierShared()
void memoryBarrierBuer()
void memoryBarrierImage()
-
8/12/2019 Opengl44 Quick Reference Card
12/12
age 12 OpenGL 4.4 API Reference Card
OpenGL is a registered trademark of Silicon Graphics Internaonal, used under license by Khronos Group.
The Khronos Group is an industry consorum creang open standards for the authoring and acceleraonof parallel compung, graphics and dynamic m edia on a wide variety of plaorms and devices.
See www.khronos.org to learn more about the Khronos Group.See www.opengl.org to learn more about OpenGL.
OpenGL API and OpenGL Shading Language Reference Card Indexhe following index shows each item included on this card along with the page on which it is described. The color of the row in the table below is the color of the pane to which you should refer.
A
AcveShaderProgram 2
AcveTexture 2
Angle Funcons 10
Arrays 7
Asynchronous Queries 1
Atomic Counter Funcons 10
Atomic Memory Funcons 10
AachShader 1
B
BeginCondionalRender 4
BeginQuery[Indexed] 1
BeginQuery 5
BeginTransformFeedback 4
BindAribLocaon 4
BindBuer* 1
BindFramebuer 3
BindFragData* 5
BindImageTexture 3
BindProgramPipeline 2
BindRenderbuer 3
BindSampler 2
BindTexture 2
BindTransformFeedback 4
BindVertex{Buer, Array} 4BlendColor 5
BlendEquaon[Separate]* 5
BlendFunc[Separate]* 5
BlitFramebuer 5
Buer Objects 1
Buer Textures 2
BuerStorage 1
Buer[Sub]Data 1
C
Callback 5
CheckFramebuerStatus 3
ClampColor 5
Clear 5
ClearBuer[Sub]Data 1
ClearBuer* 5
ClearColor 5
ClearDepth[f] 5
ClearStencil 5
ClearTex[Sub]Image 3
ClientWaitSync 1
ColorMask[i] 5
Command Leers 1
Common Funcons 10
CompileShader 1
CompressedTexImage* 3
CompressedTexSubImage* 3
Compute Programming Diagram 6
Compute Shaders 5
Constants 9
Constructors 9
Conversions 6
CopyBuerSubData 1
CopyImageSubData 5
CopyTexImage* 2
CopyTexSubImage* 2,3
CreateProgram 1
CreateShader[Programv] 1
Cube Map Texture Select 3
CullFace 4
D
DebugMessage* 5
DeleteBuers 1
DeleteFramebuers 3
DeleteProgram 1
DeleteProgramPipelines 2
DeleteQueries 1
DeleteRenderbuers 3
DeleteSamplers 2
DeleteShader 1
DeleteSync 1
DeleteTextures 2
DeleteTransformFeedbacks 4
DeleteVertexArrays 4
DepthFunc 5
DepthMask 5
DepthRange* 4
Derivave Funcons 9
DetachShader 1
DisableVertexAribArray 4
DispatchCompute* 5
Dithering 5
DrawArrays* 4
DrawBuer 5
DrawElements* 4
DrawRangeElements[BaseVertex] 4
DrawTransformFeedback* 4
EEnableVertexAribArray 4
EndcondionalRender 4
EndQuery[Indexed] 1
EndQuery 5
EndTransformFeedback 4
Errors 1
Evaluators 6
Exponenal Funcons 10
F
FenceSync 1
Finish 1
Flatshading 4
Floang-point Numbers 1
Floang-Point Pack/Unpack Func. 10
Flush 1FlushMappedBuerRange 1
Fragment Operaons 4,5
Fragment Processing Funcons 11
Fragment Shaders 5
Framebuer 5
Framebuer Objects 3
FramebuerParameteri 3
FramebuerRenderbuer 3
FramebuerTexture* 3
FrontFace 4
G
GenBuers 1
GenerateMipmap 3
GenFramebuers 3
GenProgramPipelines 2
GenQueries 1
GenRenderbuers 3
GenSamplers 2
GenTextures 2
GenTransformFeedbacks 4
GenVertexArrays 4
Geometric Funcons 11
Geometry & Follow-on Diagram 7
GetAcveAtomicCounterBuer 2
GetAcveArib 4
GetAcveSubroune* 2
GetAcveUniform* 2
GetAachedShaders 3
GetAribLocaon 4
GetBoolean* 5
GetBuerParameter* 1
GetBuerPointerv 1
GetBuerSubData 1
GetCompressedTexImage 3
GetDebugMessageLog 5
GetDouble* 5
GetError 1
GetFloat* 5
GetFragData* 5
GetFramebuerAachment... 3
GetFramebuerParameteriv 3
GetInteger* 5,6
GetInteger64v 1
GetInternalFormat* 6
GetMulsamplefv 4
GetObject[Ptr]Label 5
GetPointerv 6
GetProgram* 1
GetProgramiv 2
GetProgramBinary 2
GetProgram[Pipeline]InfoLog 2
GetProgram[Pipeline, Stage]iv 2
GetQuery* 1
GetRenderbuerParameteriv 3
GetSamplerParameter* 2
GetShaderiv 2
GetShaderInfoLog 2
GetShaderPrecisionFormat 2
GetShaderSource 2
GetString* 6
GetSubrouneIndex 2
GetSubrouneUniformLocaon 2
GetSynciv 1
GetTexImage 3
GetTex[Level]Parameter* 3
GetTransformFeedbackVarying 4
GetUniform* 2
GetUniform{f d i ui}v 3
GetUniformSubrouneuiv 3
GetVertexArib* 4GL Command Syntax 1
H
Hint 5
I
Image Funcons 10,11
Integer Funcons 10
Interpolaon Funcons 9
Interpolaon Qualiers 9
InvalidateBuer* 1
Invalidate[Sub]Framebuer 5
InvalidateTex[Sub]Image 3
Invariant Qualiers 7
IsBuer 1
IsFramebuer 3IsProgram 1
IsProgramPipeline 2
IsQuery 1
IsRenderbuer 3
IsSampler 2
IsShader 1
IsSync 1
IsTexture 2
IsTransformFeedback 4
IsVertexArray 4
Iteraon and Jumps 9
L
Layout Qualiers 8
LineWidth 4
LinkProgram 1
LogicOp 5
M
Macros 6
MapBuer[Range] 1
Matrices 2Matrix Examples 9
Matrix Funcons 10
MemoryBarrier 2
MemoryBarrier 9
Memory Qualiers 7
MinSampleShading 4
MulDraw{Arrays, Elements}* 4
MulDrawElementsBaseVertex 4
Mulsample Fragment Ops 4
Mulsample Textures 2
Mulsampling 4
N
Noise Funcons 11
O
Object[Ptr]Label 5
Occlusion Queries 5
OpenGL Shading Language 8-11
Operators 8,9
P
Pack/Unpack Funcons 8
Parameter Qualiers 9
PatchParameter 4
PauseTransformFeedback 4
Pipeline Diagram 7
PixelStore{if} 2
PointParameter* 4
PointSize 4
Polygon{Mode, Oset} 5
{Pop, Push}DebugGroup 5
Precise & Precision Qualiers 9
Predened Macros 8
Preprocessor 8
Primive Clipping 4
PrimiveRestartIndex 4
Program Objects 2
Program Queries 2
ProgramBinary 2
ProgramParameteri 1
ProgramUniform[Matrix]* 2
ProvokingVertex 4
{Push, Pop}Group 5
Q
Qualiers 8,9
QueryCounter 1
R
Rasterizaon 4
ReadBuer 5
ReadPixels 5
ReleaseShaderCompiler 1
Renderbuer Object Queries 3
RenderbuerStorage[Mulsample] 3
ResumeTransformFeedback 4
S
SampleCoverage 5
SampleMaski 5
Sampler Queries 2
SamplerParameter* 2
Scissor[Indexed]* 5
ScissorArrayv 5
Shaders and Programs 1,2
Shader Funcons 11
Shader[Binary, Source] 1ShadersStorageBlockBinding 2
State and State Requests 5
Statements 9
StencilFunc[Separate] 5
StencilMask[Separate] 5
StencilOp[Separate] 5
Storage Qualiers 8
Structures 7
Subroune Uniform Variables 2
Subrounes 9
Synchronizaon 1
T
Tessellaon Diagram 7
TexBuer* 3
TexImage* 2TexImage*Mulsample 3
TexStorage{1, 2, 3}D 3
TexSubImage* 2
TexParameter* 3
Texture/Texel Funcons 11
Texture Queries 11
TextureView 3
Texture View/State Diagram 6
Texturing 2,3
Timer Queries 1
Transform Feedback 4
TransformFeedbackVaryings 4
Trigonometry Funcons 10
Types 8
U
Uniform Qualiers 6
Uniform Variables 2
Uniform* 2
UniformBlockBinding 2
UniformMatrix* 2
UniformSubrounesuiv 2
UnmapBuer 1
UseProgram 1
UseProgramStages 2
V
ValidateProgram[Pipeline] 4
Variables 9
Vector & Matrix 7
Vector Relaonal Funcons 10
Vertex & Tessellaon Diagram 7
Vertex Arrays 4
VertexArib* 4
VertexArib*Format 4
VertexArib*Pointer 4
VertexArib[Binding, Divisor] 4
VertexBindingDivisor 4
Viewport* 4
W
WaitSync 1