www.opengl.org/registry ©2012 Khronos Group - Rev. 0712
OpenGL 4.2 API Reference Card Page 1
Vertex Specicaon
[2.7]
Verces have 2, 3, or 4 coordinates. The
VertexArib* commands specify generic
aributes with components of type oat
(VertexArib*), int or uint (VertexAribI*), or
double (VertexAribL*).
void VertexArib{1234}{sfd}(uint index,
T values);
void VertexArib{123}{sfd}v(uint index,
const T values);
void VertexArib4{bsifd ub us ui}v(
uint index, const T values);
void VertexArib4Nub(uint index, T values);
void VertexArib4N{bsi 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{bs 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: INT_2_10_10_10_REV,
UNSIGNED_INT_2_10_10_10_REV
OpenGL Operaon
Floang-Point Numbers [2.1.1 - 2.1.2]
16-Bit 1-bit sign, 5-bit exponent,
10-bit manssa
Unsigned 11-Bit no sign bit, 5-bit exponent,
6-bit manssa
Unsigned 10-Bit no sign bit, 5-bit exponent,
5-bit manssa
Command Leers [Table 2.1]
Leers are used in commands to denote types.
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)
OpenGL
®
is the only cross-plaorm graphics API that enables developers of
soware for PC, workstaon, and supercompung hardware to create high-
performance, visually-compelling graphics soware applicaons, in markets
such as CAD, content creaon, energy, entertainment, game development,
manufacturing, medical, and virtual reality. Specicaons are available at
www.opengl.org/registry
• see FunconName refers to funcons on this reference card.
• [n.n.n] and [Table n.n] refer to secons and tables in the OpenGL 4.2 core specicaon.
• [n.n.n] refers to secons in the OpenGL Shading Language 4.20 specicaon.
OpenGL Command Syntax [2.3]
GL commands are formed from a return type, a name, and oponally up to 4 characters
(or character pairs) from the Command Leers table (above), as shown by the prototype:
return-type Name{1234}{b s i i64 f d ub us ui ui64}{v} ([args ,] T arg1 , . . . , T argN [, args]);
The arguments enclosed in brackets ([args ,] and [, args]) may or may not be present.
The argument type T and the number N of arguments may be indicated by the command name
suxes. N is 1, 2, 3, or 4 if present, or else corresponds to the type leers from the Command
Table (above). If “v” is present, an array of N items is passed by a pointer.
For brevity, the OpenGL documentaon and this reference may omit the standard prexes.
The actual names are of the forms:
glFunconName(), GL_CONSTANT, GLtype
Buer Objects
[2.9-10]
void GenBuers(sizei n, uint *buers);
void DeleteBuers(sizei n, const uint *buers);
Creang and Binding Buer Objects[2.9.1]
void BindBuer(enum target, uint buer);
target:
PIXEL_{PACK, UNPACK}_BUFFER,
{UNIFORM, ARRAY, TEXTURE}_BUFFER,
COPY_{READ, WRITE}_BUFFER,
DRAW_INDIRECT_BUFFER, ELEMENT_ARRAY_BUFFER,
{TRANSFORM_FEEDBACK, ATOMIC_COUNTER}_BUFFER
void BindBuerRange(enum target, uint index,
uint buer, intptr oset, sizeiptr size);
target: ATOMIC_COUNTER_BUFFER,
{TRANSFORM_FEEDBACK, UNIFORM}_BUFFER
void BindBuerBase(enum target,
uint index, uint buer);
target: see BindBuerRange
Creang Buer Object Data Stores[2.9.
2]
void BuerSubData(enum target,
intptr oset, sizeiptr size,
const void *data);
target: see BindBuer
void BuerData(enum target, sizeiptr size,
const void *data, enum usage);
usage: STREAM_{DRAW, READ, COPY},
{DYNAMIC, STATIC}_{DRAW, READ, COPY}
target: see BindBuer
Mapping/Unmapping Buer Data[2.9.3]
void *MapBuerRange(enum target,
intptr oset, sizeiptr length, biield access);
access: The logical OR of MAP_{READ, WRITE}_BIT,
MAP_INVALIDATE_{BUFFER, RANGE}_BIT,
MAP_{FLUSH_EXPLICIT, UNSYNCHRONIZED}_BIT
target: see BindBuer
void *MapBuer(enum target, enum access);
access: READ_ONLY, WRITE_ONLY, READ_WRITE
void FlushMappedBuerRange(
enum target, intptr oset, sizeiptr length);
target: see BindBuer
boolean UnmapBuer(enum target);
target: see BindBuer
Copying Between Buers [2.9.5]
void CopyBuerSubData(enum readtarget,
enum writetarget, intptr readoset,
intptr writeoset, sizeiptr size);
readtarget and writetarget: see BindBuer
Vertex Array Objects [2.10]
All states related to denion of data used by
vertex processor is in a vertex array object.
void GenVertexArrays(sizei n, uint *arrays);
void DeleteVertexArrays(sizei n,
const uint *arrays);
void BindVertexArray(uint array);
Vertex Array Object Queries [6.1.10]
boolean IsVertexArray(uint array);
Buer Object Queries [6.1.9]
boolean IsBuer(uint buer);
void GetBuerParameteriv(enum target,
enum pname, int *data);
target: see BindBuer
pname: BUFFER_SIZE, BUFFER_USAGE,
BUFFER_ACCESS{_FLAGS}, BUFFER_MAPPED,
BUFFER_MAP_{OFFSET, LENGTH}
void GetBuerParameteri64v(enum target,
enum pname, 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,
enum pname, void **params);
target: see BindBuer
pname: BUFFER_MAP_POINTER
OpenGL Errors
[2.5]
enum GetError(void); Returns the numeric error code.
Vertex Arrays [2.8]
void VertexAribPointer(uint index, int size,
enum type, boolean normalized,
sizei stride, const void *pointer);
type: SHORT, INT, FLOAT, HALF_FLOAT, DOUBLE,
{UNSIGNED_}INT_2_10_10_10_REV, FIXED,
BYTE,
UINT, UNSIGNED_{BYTE, SHORT}
void VertexAribIPointer(uint index,
int size, enum type, sizei stride,
const void *pointer);
type:
BYTE, SHORT, UNSIGNED_{BYTE, SHORT}, INT, UINT
index: [0, MAX_VERTEX_ATTRIBS - 1]
void VertexAribLPointer(uint index, int size,
enum type, sizei stride, const void *pointer);
type: DOUBLE
index: [0, MAX_VERTEX_ATTRIBS - 1]
void EnableVertexAribArray(uint index);
void DisableVertexAribArray(uint index);
index: [0, MAX_VERTEX_ATTRIBS - 1]
void VertexAribDivisor(uint index,
uint divisor);
Enable/Disable(PRIMITIVE_RESTART);
void PrimiveRestartIndex(uint index);
Drawing Commands [2.8.3]
For all the funcons in this secon:
mode: POINTS,
LINE_STRIP, LINE_LOOP,
LINES, TRIANGLE_{STRIP, FAN},
TRIANGLES, LINES_ADJACENCY,
{LINE, TRIANGLE}_STRIP_ADJACENCY,
PATCHES, TRIANGLES_ADJACENCY
type: UNSIGNED_{BYTE, SHORT, INT}
void DrawArraysOneInstance(enum mode,
int rst, sizei count, int instance,
uint baseinstance);
void DrawArrays(enum mode, int rst,
sizei count);
void DrawArraysInstanced(enum mode,
int rst, sizei count, sizei primcount);
void DrawArraysInstancedBaseInstance(
enum mode, int rst, sizei count,
sizei primcount, uint baseinstance);
void DrawArraysIndirect(enum mode,
const void *indirect);
void MulDrawArrays(enum mode,
const int *rst, const sizei *count,
sizei primcount);
void DrawElements(enum mode,
sizei count, enum type, const void *indices);
void DrawElementsInstanced(enum mode,
sizei count, enum type, const void *indices,
sizei primcount);
void DrawElementsInstancedBaseInstance(
enum mode, sizei count, enum type,
const void *indices, sizei primcount,
uint baseinstance);
void
DrawElementsInstancedBaseVertexBaseInstance(
enum mode, sizei count, enum type,
const void *indices, sizei primcount,
int basevertex, uint baseinstance);
void DrawElementsOneInstance(
enum mode, sizei count, enum type,
const void *indices, int instance,
uint baseinstance);
void MulDrawElements(enum mode,
sizei *count, enum type,
const void **indices, sizei primcount);
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 primcount,
int basevertex);
void
DrawElementsIndirect(enum mode,
enum type, const void *indirect);
void MulDrawElementsBaseVertex(
enum mode, sizei *count, enum type,
const void **indices, sizei primcount,
int *basevertex);
Shaders and Programs
Shader Objects [2.11.1-2]
uint CreateShader(enum type);
type: {VERTEX, FRAGMENT, GEOMETRY}_SHADER,
TESS_{EVALUATION, CONTROL}_SHADER
void ShaderSource(uint shader, sizei count,
const char **string, const int *length);
void CompileShader(uint shader);
void ReleaseShaderCompiler(void);
void DeleteShader(uint shader);
void ShaderBinary(sizei count,
const uint *shaders, enum binaryformat,
const void *binary, sizei length);
Program Objects [2.11.3]
uint CreateProgram(void);
void AachShader(uint program,
uint shader);
void DetachShader(uint program,
uint shader);
void LinkProgram(uint program);
void UseProgram(uint program);
uint CreateShaderProgramv(enum type,
sizei count, const char **strings);
void ProgramParameteri(uint program,
enum pname, int value);
(parameters
)
pname: PROGRAM_SEPARABLE,
PROGRAM_BINARY_{RETRIEVABLE_HINT}
value: TRUE, FALSE
void DeleteProgram(uint program);
Program Pipeline Objects
[2.11.4]
void GenProgramPipelines(sizei n,
uint *pipelines);
void DeleteProgramPipelines(sizei n,
const uint *pipelines);
void BindProgramPipeline(uint pipeline);
void UseProgramStages(uint pipeline,
biield stages, uint program);
stages: ALL_SHADER_BITS or the bitwise OR of
TESS_{CONTROL, EVALUATION}_SHADER_BIT,
{VERTEX, GEOMETRY, FRAGMENT}_SHADER_BIT
void AcveShaderProgram(uint pipeline,
uint program);
Program Binaries [2.11.5]
void GetProgramBinary(uint program,
sizei bufSize, sizei *length,
enum *binaryFormat, void *binary);
(Shaders and Programs Connue >)