www.opengl.org/registry
©2009 Khronos Group - Rev. 0809
OpenGL 3.2 API Quick Reference Card
www.opengl.org/registry
©2009 Khronos Group - Rev. 0809
OpenGL 3.2 API Quick Reference Card
Shaders and Programs
Shader Objects [2.11.1] [2.14.1]
uint CreateShader(uint type);
type: VERTEX_SHADER, FRAGMENT_SHADER, GEOMETRY_SHADER
void ShaderSource(uint shader, sizei count,
const char **string, const int *length);
void CompileShader(uint shader);
void DeleteShader(uint shader);
Program Objects [2.11.2] [2.14.2]
uint CreateProgram(void);
void AachShader(uint program, uint shader);
void DetachShader(uint program, uint shader);
void LinkProgram(uint program);
void UseProgram(uint program);
void DeleteProgram(uint program);
Vertex Aributes [2.11.3] [2.14.3]
Vertex shaders operate on an array of 4-component items
numbered from slot 0 to MAX_VERTEX_ATTRIBS - 1.
void GetAcveArib(uint program, uint index,
sizei bufSize, sizei *length, int *size, enum *type,
char *name);
*type returns: FLOAT, FLOAT_VECn, FLOAT_MAT*, INT, INT_VECn,
UNSIGNED_INT, UNSIGNED_INT_VECn
int GetAribLocaon(uint program, const char *name);
void BindAribLocaon(uint program, uint index,
const char *name);
Uniform Variables [2.11.4] [2.14.4]
int GetUniformLocaon(uint program, const char *name);
uint GetUniformBlockIndex(uint program,
const char *uniformBlockName);
void GetAcveUniformBlockName(uint program,
uint uniformBlockIndex, sizei bufSize, sizei *length,
char *uniformBlockName);
void GetAcveUniformBlockiv(uint program,
uint uniformBlockIndex, enum pname, int *params);
pname: UNIFORM_BLOCK_BINDING, UNIFORM_BLOCK_DATA_SIZE,
UNIFORM_BLOCK_NAME_LENGTH,
UNIFORM_BLOCK_ACTIVE_UNIFORMS,
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES,
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER,
UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER
void GetUniformIndices(uint program, sizei uniformCount,
const char **uniformNames, uint *uniformIndices);
void GetAcveUniformName(uint program,
uint uniformIndex, sizei bufSize, sizei *length,
char *uniformName);
void GetAcveUniform(uint program, uint index,
sizei bufSize, sizei *length, int *size, enum *type,
char *name);
void GetAcveUniformsiv(uint program, sizei uniformCount,
const uint *uniformIndices, enum pname, int *params);
pname: UNIFORM_TYPE, UNIFORM_SIZE, UNIFORM_NAME_LENGTH,
UNIFORM_BLOCK_INDEX, UNIFORM_OFFSET,
UNIFORM_ARRAY_STRIDE, UNIFORM_MATRIX_STRIDE,
UNIFORM_IS_ROW_MAJOR
type: FLOAT, FLOAT_VECn, INT, INT_VECn, UNSIGNED_INT,
UNSIGNED_INT_VECn, BOOL, BOOL_VECn, FLOAT_MAT*,
SAMPLER_*, INT_SAMPLER_*, UNSIGNED_INT_SAMPLER_*
Loading Uniform Variables In Default Uniform Block
void Uniform{1234}{if}(int locaon, T value);
void Uniform{1234}{if}v(int locaon, sizei count, T value);
void Uniform{1234}ui(int locaon, T value);
void Uniform{1234}uiv(int locaon, sizei count, T value);
void UniformMatrix{234}fv(int locaon, sizei count,
boolean transpose, const oat *value);
void UniformMatrix{2x3,3x2,2x4,4x2,3x4,4x3}fv(
int locaon, sizei count, boolean transpose,
const oat *value);
Uniform Buer Object Bindings
void UniformBlockBinding(uint program,
uint uniformBlockIndex, uint uniformBlockBinding);
Varying Variables [2.11.6] [2.14.6]
void TransformFeedbackVaryings(uint program,
sizei count, const char **varyings, enum buerMode);
buerMode: INTERLEAVED_ATTRIBS, SEPARATE_ATTRIBS
void GetTransformFeedbackVarying(uint program,
uint index, sizei bufSize, sizei *length, sizei *size,
enum *type, char *name);
*type returns any of the scalar, vector, or matrix aribute types
returned by GetAcveArib.
Shader Execuon (Validaon) [2.11.7] [2.14.7]
void ValidateProgram(uint program);
Geometry Shaders [2.12] [2.15]
GetProgramiv(uint program, GEOMETRY_INPUT_TYPE,
int *params)
*params returns: POINTS, LINES, LINES_ADJACENCY, TRIANGLES,
TRIANGLES_ADJACENCY
GetProgramiv(uint program, GEOMETRY_OUTPUT_TYPE,
int *params)
*params returns: POINTS, LINE_STRIP, TRIANGLE_STRIP
Fragment Shaders [3.9.2] [3.12.2]
void BindFragDataLocaon(uint program, uint colorNumber,
const char *name);
int GetFragDataLocaon(uint program, const char *name);
name: null-terminated string
Shader Queries
Shader Queries [6.1.10] [6.1.16]
boolean IsShader(uint shader);
void GetShaderiv(uint shader, enum pname, int *params);
pname: SHADER_TYPE, DELETE_STATUS, COMPILE_STATUS,
INFO_LOG_LENGTH, SHADER_SOURCE_LENGTH
void GetAachedShaders(uint program, sizei maxCount,
sizei *count, uint *shaders);
void GetShaderInfoLog(uint shader, sizei bufSize,
sizei *length, char *infoLog);
void GetShaderSource(uint shader, sizei bufSize,
sizei *length, char *source);
void GetVertexArib{d li lui}v(uint index, enum pname,
double *params);
pname: CURRENT_VERTEX_ATTRIB , VERTEX_ATTRIB_ARRAY_x
(where x may be BUFFER_BINDING, ENABLED, SIZE, STRIDE, TYPE,
NORMALIZED, INTEGER)
void GetVertexAribPointerv(uint index, enum pname,
void **pointer);
pname: VERTEX_ATTRIB_ARRAY_POINTER
void GetUniform{if ui}v(uint program, int locaon,
T *params)
Program Queries [6.1.10] [6.1.16]
boolean IsProgram(uint program);
void GetProgramiv(uint program, enum pname, int *params);
pname: DELETE_STATUS, LINK_STATUS, VALIDATE_STATUS,
INFO_LOG_LENGTH, ATTACHED_SHADERS,
GEOMETRY_INPUT_TYPE, GEOMETRY_VERTICES_OUT,
GEOMETRY_OUTPUT_TYPE, ACTIVE_ATTRIBUTES,
ACTIVE_ATTRIBUTE_MAX_LENGTH, ACTIVE_UNIFORMS,
TRANSFORM_FEEDBACK_*, ACTIVE_UNIFORM_*
void GetProgramInfoLog(uint program, sizei bufSize,
sizei *length, char *infoLog);
Lighng and Color
Lighng/ Lighng Parameter Specicaon [2.13.1]
Enable/Disable(LIGHTING) (aects all lights)
Enable/Disable(LIGHTi) (aects individual lights)
void Material{if}(enum face, enum pname, T param);
void Material{if}v(enum face, enum pname, T params);
face: FRONT, BACK, FRONT_AND_BACK
pname: AMBIENT, DIFFUSE, AMBIENT_AND_DIFFUSE, SPECULAR,
EMISSION, SHININESS, COLOR_INDEXES
void Light{if}(enum light, enum pname, T param);
void Light{if}v(enum light, enum pname, T params);
light: LIGHTi (where i >= 0)
pname: AMBIENT, DIFFUSE, SPECULAR, POSITION, SPOT_DIRECTION,
SPOT_EXPONENT, SPOT_CUTOFF, CONSTANT_ATTENTUATION,
LINEAR_ATTENUATION, QUADRATIC_ATTENUATION
void LightModel{if}(enum pname, T param);
void LightModel{if}v(enum pname, T params);
pname: LIGHT_MODEL_AMBIENT, LIGHT_MODEL_LOCAL_VIEWER,
LIGHT_MODEL_TWO_SIDE, LIGHT_MODEL_COLOR_CONTROL
ColorMaterial [2.13.3, 2.13.6]
Enable/Disable(COLOR_MATERIAL)
void ColorMaterial(enum face, enum mode);
face: FRONT, BACK, FRONT_AND_BACK
mode: EMISSION, AMBIENT, DIFFUSE, SPECULAR,
AMBIENT_AND_DIFFUSE
void ClampColor(enum target, enum clamp);
target: CLAMP_VERTEX_COLOR
clamp: TRUE, FALSE, FIXED_ONLY
Flatshading [2.18] [2.21]
void ProvokingVertex(enum provokeMode);
provokeMode: FIRST_VERTEX_CONVENTION,
LAST_VERTEX_CONVENTION
void ShadeModel(enum mode);
mode: SMOOTH, FLAT
Queries [6.13]
void GetLight{if}v(enum light, enum value, T data);
void GetMaterial{if}v(enum face, enum value, T data);
face: FRONT, BACK
Rendering Control and Queries
Condional Rendering [2.18]
void BeginCondionalRender(uint id, enum mode);
void EndCondionalRender(void);
mode: QUERY_WAIT, QUERY_NO_WAIT,
QUERY_BY_REGION_WAIT, QUERY_BY_REGION_NO_WAIT
Transform Feedback [2.19]
void BeginTransformFeedback(enum primiveMode);
void EndTransformFeedback(void);
primiveMode: TRIANGLES, LINES, POINTS
void BindBuerRange(enum target, uint index,
uint buer, intptr oset, sizeiptr size);
void BindBuerBase(enum target, uint index, uint buer);
target: TRANSFORM_FEEDBACK_BUFFER
Current Raster Posion [2.24]
void RasterPos{234}{sifd}(T coords);
void RasterPos{234}{sifd}v(T coords);
void WindowPos{23}{sifd}(T coords);
void WindowPos{23}{sifd}v(const T coords);
Asynchronous Queries [2.17]
void BeginQuery(enum target, uint id);
target: PRIMITIVES_GENERATED, SAMPLES_PASSED,
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
void EndQuery(enum target);
void GenQueries(sizei n, uint *ids);
void DeleteQueries(sizei n, const uint *ids);
Asynchronous State Queries [6.1.6] [6.1.12]
boolean IsQuery(uint id);
void GetQueryiv(enum target, enum pname,
int *params);
target: SAMPLES_PASSED, PRIMITIVES_GENERATED,
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
pname: CURRENT_QUERY, QUERY_COUNTER_BITS
void GetQueryObjecv(uint id, enum pname,
int *params);
void GetQueryObjectuiv(uint id, enum pname,
uint *params);
pname: QUERY_RESULT, QUERY_RESULT_AVAILABLE
Viewport and Clipping
Controlling the Viewport [2.16.1]
void DepthRange(clampd n, clampd f);
void Viewport(int x, int y, sizei w, sizei h);
Clipping [2.23]
Enable/Disable(CLIP_DISTANCEi)
i: [0, MAX_CLIP_DISTANCES - 1]
void ClipPlane(enum p, double eqn[4]);
p: CLIP_PLANEi (where i is [0, MAX_CLIP_PLANES - 1])
Rectangles, Matrices, Texture Coordinates
Rectangles [2.11]
Speciy rectangles as two corner verces.
void Rect{sifd}(T x1, T y1, T x2, T y2);
void Rect{sifd}v(T v1[2], T v2[2]);
Matrices [2.12.1]
void MatrixMode(enum mode);
mode: TEXTURE, MODELVIEW, COLOR, PROJECTION
void LoadMatrix{fd}(T m[16]);
void MultMatrix{fd}(T m[16]);
void LoadTransposeMatrix{fd}(T m[16]);
void MultTransposeMatrix{fd}(T m[16]);
void LoadIdenty(void);
void Rotate{fd}(Ty, T x, T y, T z);
void Translate{fd}(T x, T y, T z);
void Scale{fd}(T x, T y, T z);
void Frustum(double l, double r, double b, double t,
double n, double f);
void Ortho(double l, double r, double b, double t,
double n, double f);
void PushMatrix(void);
void PopMatrix(void);
Generang Texture Coordinates [2.12.3]
void TexGen{ifd}(enum coord, enum pname, T param);
void TexGen{ifd}v(enum coord, enum pname, T *params);
coord: S, T, R, Q
pname: TEXTURE_GEN_MODE, OBJECT_PLANE, EYE_PLANE