Chapter 3. Summary of Commands and Routines

This chapter lists the prototypes for OpenGL, the OpenGL Utility Library, and the OpenGL extension to the X Window System. The prototypes are grouped functionally, as shown below:


Since some of the OpenGL commands differ from each other only by the data type of the arguments they accept, certain conventions have been used to refer to these commands in a compact way:

void glVertex2{sifd}{v} (TYPE x, TYPE y);

In this example, the first set of braces encloses characters identifying the possible data types for the arguments listed as having data type TYPE. (The digit preceding the braces indicates how many arguments the command takes.) In this case, all the arguments have the placeholder TYPE, but in other situations some arguments may have an explicitly defined data type. The table shown below lists the set of possible data types, their corresponding characters, and the type definition OpenGL uses for referring to that data type.


data type

C-language type

OpenGL type definition


8-bit integer

signed char



16-bit integer




32-bit integer


GLint, GLsizei


32-bit floating-point


GLfloat, GLclampf


64-bit floating-point


GLdouble, GLclampd


8-bit unsigned integer

unsigned char

GLubyte, GLboolean


16-bit unsigned integer

unsigned short



32-bit unsigned integer

unsigned int

GLuint, GLenum, GLbitfield





The second set of braces, if present, contains a v for the vector form of the command. If you choose to use the vector form, all the TYPE arguments are collapsed into a single array. For example, here are the nonvector and vector forms of a command, using a 32-bit floating-point data type:

void glVertex2f(GLfloat x, GLfloat y);
void glVertex2fv(GLfloat v[2]);

Where the use of the vector form is ambiguous, both the vector and nonvector forms are listed. Note that not all commands with multiple arguments have a vector form and that some commands have only a vector form, in which case the v isn't enclosed in braces.

OpenGL Commands


Specify vertices or rectangles:

void glBegin (GLenum mode);
void glEnd (void);
void glVertex2{sifd}{v} (TYPE x, TYPE y);
void glVertex3{sifd}{v} (TYPE x, TYPE y, TYPE z);
void glVertex4{sifd}{v} (TYPE x, TYPE y, TYPE z, TYPE w);
void glRect{sifd} (TYPE x1, TYPE y1, TYPE x2, TYPE y2);
void glRect{sifd}v (const TYPE *v1, const TYPE *v2);

Specify polygon edge treatment:

void glEdgeFlag (GLboolean flag);
void glEdgeFlagv (const GLboolean *flag);

Coordinate Transformation

Transform the current matrix:

void glRotate{fd} (TYPE angle, TYPE x, TYPE y, TYPE z);
void glTranslate{fd} (TYPE x, TYPE y, TYPE z);
void glScale{fd} (TYPE x, TYPE y, TYPE z);
void glMultMatrix{fd} (const TYPE *m);
void glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);

Replace the current matrix:

void glLoadMatrix{fd} (const TYPE *m);
void glLoadIdentity (void);

Manipulate the matrix stack:

void glMatrixMode (GLenum mode);
void glPushMatrix (void);
void glPopMatrix (void);

Specify the viewport:

void glDepthRange (GLclampd near, GLclampd far);
void glViewport (GLint x, GLint y, GLsizei width, GLsizei height);

Coloring and Lighting

Set the current color, color index, or normal vector:

void glColor3{bsifd ubusui}{v} (TYPE red, TYPE green, TYPE blue);
void glColor4{bsifd ubusui}{v} (TYPE red, TYPE green, TYPE blue, TYPE alpha);
void glIndex{sifd}{v} (TYPE index);
void glNormal3{bsifd}{v} (TYPE nx, TYPE ny, TYPE nz);

Specify light source, material, or lighting model parameter values:

void glLight{if}{v} (GLenum light, GLenum pname, TYPE param);
void glMaterial{if}{v} (GLenum face, GLenum pname, TYPE param);
void glLightModel{if}{v} (GLenum pname, TYPE param);

Choose a shading model:

void glShadeModel (GLenum mode);

Specify which polygon orientation is front-facing:

void glFrontFace (GLenum dir);

Cause a material color to track the current color:

void glColorMaterial (GLenum face, GLenum mode);

Obtain light source or material parameter values:

void glGetLight{if}v (GLenum light, GLenum pname, TYPE *params);
void glGetMaterial{if}v (GLenum face, GLenum pname, TYPE *params);


Specify a clipping plane:

void glClipPlane (GLenum plane, const GLdouble *equation);

Return clipping plane coefficients:

void glGetClipPlane (GLenum plane, GLdouble *equation);


Set the current raster position:

void glRasterPos2{sifd}{v}(TYPE x, TYPE y);
void glRasterPos3{sifd}{v}(TYPE x, TYPE y, TYPE z);

void glRasterPos4{sifd}{v}(TYPE x, TYPE y, TYPE z, TYPE w);

Specify a bitmap:

void glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);

Specify the dimensions of points or lines:

void glPointSize (GLfloat size);
void glLineWidth (GLfloat width);

Specify or return a stipple pattern for lines or polygons:

void glLineStipple (GLint factor, GLushort pattern);
void glPolygonStipple (const GLubyte *mask);
void glGetPolygonStipple (GLubyte *mask);

Choose how polygons are rasterized:

void glCullFace (GLenum mode);
void glPolygonMode (GLenum face, GLenum mode);

Pixel Operations

Select the source for pixel reads or copies:

void glReadBuffer (GLenum mode);

Read, write, and copy pixels:

void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
void glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
void glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);

Specify or query how pixels are encoded or processed:

void glPixelStore{if} (GLenum pname, TYPE param);
void glPixelTransfer{if} (GLenum pname, TYPE param);
void glPixelMap{f usui}v (GLenum map, GLint mapsize, const TYPE *values);
void glGetPixelMap{f usui}v (GLenum map, TYPE *values);

Control pixel rasterization:

void glPixelZoom (GLfloat xfactor, GLfloat yfactor);

Texture Mapping

Control how a texture is applied to a fragment:

void glTexParameter{if}{v} (GLenum target, GLenum pname, TYPE param);
void glTexEnv{if}{v} (GLenum target, GLenum pname, TYPE param);

Set the current texture coordinates:

void glTexCoord1{sifd}{v} (TYPE s);
void glTexCoord2{sifd}{v} (TYPE s, TYPE t);
void glTexCoord3{sifd}{v} (TYPE s, TYPE t, TYPE r);
void glTexCoord4{sifd}{v} (TYPE s, TYPE t, TYPE r, TYPE q);

Control the generation of texture coordinates:

void glTexGen{ifd}{v} (GLenum coord, GLenum pname, TYPE param);

Specify a one- or two-dimensional texture image:

void glTexImage1D (GLenum target, GLint level, GLint components, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void glTexImage2D (GLenum target, GLint level, GLint components, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);

Obtain texture-related parameter values:

void glGetTexEnv{if}v (GLenum target, GLenum pname, TYPE *params);
void glGetTexGen{ifd}v (GLenum coord, GLenum pname, TYPE *params);
void glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
void glGetTexLevelParameter{if}v (GLenum target, GLint level, GLenum pname, TYPE *params);
void glGetTexParameter{if}v (GLenum target, GLenum pname, TYPE *params);


Set fog parameters:

void glFog{if}{v} (GLenum pname, TYPE param);

Frame Buffer Operations

Control per-fragment testing:

void glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
void glAlphaFunc (GLenum func, GLclampf ref);
void glStencilFunc (GLenum func, GLint ref, GLuint mask);
void glStencilOp (GLenum fail, GLenum pass, GLenum zpass);
void glDepthFunc (GLenum func);

Combine fragment and frame buffer values:

void glBlendFunc (GLenum sfactor, GLenum dfactor);
void glLogicOp (GLenum opcode);

Clear some or all buffers:

void glClear (GLbitfield mask);

Specify color, depth, and stencil values for clears:

void glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void glClearDepth (GLclampd depth);
void glClearIndex (GLfloat c);
void glClearStencil (GLint s);

Control buffers enabled for writing:

void glDrawBuffer (GLenum mode);
void glIndexMask (GLuint mask);
void glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void glDepthMask (GLboolean flag);
void glStencilMask (GLuint mask);

Operate on the accumulation buffer:

void glAccum (GLenum op, GLfloat value);


Define a one- or two-dimensional evaluator:

void glMap1{fd} (GLenum target, TYPE u1, TYPE u2, GLint stride, GLint order, const TYPE *points);
void glMap2{fd} (GLenum target, TYPE u1, TYPE u2, GLint ustride, GLint uorder, TYPE v1, TYPE v2, GLint vstride,

GLint vorder, const TYPE *points);

Generate and evaluate a series of map domain values:

void glMapGrid1{fd} (GLint n, TYPE u1, TYPE u2);
void glMapGrid2{fd} (GLint un, TYPE u1, TYPE u2, GLint vn, TYPE v1, TYPE v2);
void glEvalMesh1 (GLenum mode, GLint i1, GLint i2);
void glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
void glEvalPoint1 (GLint i);
void glEvalPoint2 (GLint i, GLint j);

Evaluate one- and two-dimensional maps at a specified domain coordinate:

void glEvalCoord1{fd}{v} (TYPE u);
void glEvalCoord2{fd}{v} (TYPE u, TYPE v);

Obtain evaluator parameter values:

void glGetMap{idf}v (GLenum target, GLenum query, TYPE *v);

Selection and Feedback

Control the mode and corresponding buffer:

GLint glRenderMode (GLenum mode);

void glSelectBuffer (GLsizei size, GLuint *buffer);
void glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer);

Supply a token for feedback mode:

void glPassThrough (GLfloat token);

Control the name stack for selection:

void glInitNames (void);
void glLoadName (GLuint name);
void glPushName (GLuint name);
void glPopName (void);

Display Lists

Create or delete display lists:

void glNewList (GLuint list, GLenum mode);
void glEndList (void);
void glDeleteLists (GLuint list, GLsizei range);

Execute a display list or set of lists:

void glCallList (GLuint list);
void glCallLists (GLsizei n, GLenum type, const GLvoid *lists);

Manage display-list indices:

GLuint glGenLists (GLsizei range);
GLboolean glIsList (GLuint list);
void glListBase (GLuint base);

Modes and Execution

Enable, disable, and query modes:

void glEnable (GLenum cap);
void glDisable (GLenum cap);
GLboolean glIsEnabled (GLenum cap);

Wait until all OpenGL commands have executed completely:

void glFinish (void);

Force all issued OpenGL commands to be executed:

void glFlush (void);

Specify hints for OpenGL operation:

void glHint (GLenum target, GLenum mode);

State Queries

Obtain information about an error or the current OpenGL connection:

GLenum glGetError (void);
const GLubyte * glGetString (GLenum name);

Query state variables:

void glGetBooleanv (GLenum pname, GLboolean *params);
void glGetDoublev (GLenum pname, GLdouble *params);
void glGetFloatv (GLenum pname, GLfloat *params);

void glGetIntegerv (GLenum pname, GLint *params);

Save and restore sets of state variables:

void glPushAttrib (GLbitfield mask);
void glPopAttrib (void);

GLU Routines

Texture Images

Magnify or shrink an image:

int gluScaleImage (GLenum format, GLint widthin, GLint heightin,GLenum typein, const void *datain, GLint widthout, GLint heightout, GLenum typeout, void *dataout);

Generate mipmaps for an image:

int gluBuild1DMipmaps (GLenum target, GLint components, GLint width, GLenum format, GLenum type, void *data);
int gluBuild2DMipmaps (GLenum target, GLint components, GLint width, GLint height, GLenum format, GLenum type, void *data);

Coordinate Transformation

Create projection or viewing matrices:

void gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom,GLdouble top);
void gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
void gluPickMatrix (GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4]);
void gluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz);

Convert object coordinates to screen coordinates:

int gluProject (GLdouble objx, GLdouble objy, GLdouble objz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *winx, GLdouble *winy, GLdouble *winz);

int gluUnProject (GLdouble winx, GLdouble winy, GLdouble winz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *objx, GLdouble *objy, GLdouble *objz);

Polygon Tessellation

Manage tessellation objects:

GLUtriangulatorObj* gluNewTess (void);

void gluTessCallback (GLUtriangulatorObj *tobj, GLenum which, void (*fn)());
void gluDeleteTess (GLUtriangulatorObj *tobj);

Describe the input polygon:

void gluBeginPolygon (GLUtriangulatorObj *tobj);
void gluEndPolygon (GLUtriangulatorObj *tobj);
void gluNextContour (GLUtriangulatorObj *tobj, GLenum type);
void gluTessVertex (GLUtriangulatorObj *tobj, GLdouble v[3], void *data);

Quadric Objects

Manage quadric objects:

GLUquadricObj* gluNewQuadric (void);
void gluDeleteQuadric (GLUquadricObj *state);
void gluQuadricCallback (GLUquadricObj *qobj, GLenum which, void (*fn)());

Control the rendering:

void gluQuadricNormals (GLUquadricObj *quadObject, GLenum normals);
void gluQuadricTexture (GLUquadricObj *quadObject, GLboolean textureCoords);
void gluQuadricOrientation (GLUquadricObj *quadObject, GLenum orientation);
void gluQuadricDrawStyle (GLUquadricObj *quadObject, GLenum drawStyle);

Specify a quadric primitive:

void gluCylinder (GLUquadricObj *qobj, GLdouble baseRadius,
GLdouble topRadius, GLdouble height, GLint slices, GLint stacks);
void gluDisk (GLUquadricObj *qobj, GLdouble innerRadius,
GLdouble outerRadius, GLint slices, GLint loops);
void gluPartialDisk (GLUquadricObj *qobj, GLdouble innerRadius,
GLdouble outerRadius, GLint slices, GLint loops,
GLdouble startAngle, GLdouble sweepAngle);
void gluSphere (GLUquadricObj *qobj, GLdouble radius, GLint slices,
GLint stacks);

NURBS Curves and Surfaces

Manage a NURBS object:

GLUnurbsObj* gluNewNurbsRenderer (void);
void gluDeleteNurbsRenderer (GLUnurbsObj *nobj);
void gluNurbsCallback (GLUnurbsObj *nobj, GLenum which, void (*fn)());

Create a NURBS curve:

void gluBeginCurve (GLUnurbsObj *nobj);
void gluEndCurve (GLUnurbsObj *nobj);
void gluNurbsCurve (GLUnurbsObj *nobj, GLint nknots, GLfloat *knot, GLint stride, GLfloat *ctlarray, GLint order, GLenum type);

Create a NURBS surface:

void gluBeginSurface (GLUnurbsObj *nobj);void gluEndSurface (GLUnurbsObj *nobj);
void gluNurbsSurface (GLUnurbsObj *nobj, GLint uknot_count, GLfloat *uknot, GLint vknot_count, GLfloat *vknot, GLint u_stride, GLint v_stride, GLfloat *ctlarray, GLint sorder, GLint torder, GLenum type);

Define a trimming region:

void gluBeginTrim (GLUnurbsObj *nobj);
void gluEndTrim (GLUnurbsObj *nobj);
void gluPwlCurve (GLUnurbsObj *nobj, GLint count, GLfloat *array, GLint stride, GLenum type);

Control NURBS rendering:

void gluLoadSamplingMatrices (GLUnurbsObj *nobj, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4]);
void gluNurbsProperty (GLUnurbsObj *nobj, GLenum property, GLfloat value);
void gluGetNurbsProperty (GLUnurbsObj *nobj, GLenum property,
GLfloat *value);

Error Handling

Produce an error string from an OpenGL error code:

const GLubyte* gluErrorString (GLenum errorCode);

GLX Routines


Determine whether the GLX extension is defined on the X server:

Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase);
Bool glXQueryVersion (Display *dpy, int *major, int *minor);

Obtain the desired visual:

XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList);
int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value);

Controlling Rendering

Manage or query an OpenGL rendering context:

GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
void glXDestroyContext (Display *dpy, GLXContext ctx);
void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLuint mask);
Bool glXIsDirect (Display *dpy, GLXContext ctx);
Bool glXMakeCurrent (Display *dpy, GLXDrawable draw, GLXContext ctx);
GLXContext glXGetCurrentContext (void);
GLXDrawable glXGetCurrentDrawable (void);

Perform off-screen rendering:

GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis,

Pixmap pixmap);

void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix);

Synchronize execution:

void glXWaitGL (void);
void glXWaitX (void);

Exchange front and back buffers:

void glXSwapBuffers (Display *dpy, Window window);

Use an X font:

void glXUseXFont (Font font, int first, int count, int listBase);