0% found this document useful (0 votes)
5 views5 pages

CG List of Functions

The document provides a list of OpenGL and GLUT functions along with their parameters and example usages. Each function is briefly explained, detailing its purpose in graphics rendering, such as setting up projections, managing transformations, and handling user input. This serves as a reference for developers working with OpenGL and GLUT for 2D and 3D graphics applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

CG List of Functions

The document provides a list of OpenGL and GLUT functions along with their parameters and example usages. Each function is briefly explained, detailing its purpose in graphics rendering, such as setting up projections, managing transformations, and handling user input. This serves as a reference for developers working with OpenGL and GLUT for 2D and 3D graphics applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Function Name Parameter List Example Usage Detailed Explanation

Marks the current

window as needing to

be redrawn. Causes

the registered display


glutPostRedisplay None glutPostRedisplay();
callback to be called

soon. Used in

animation loops or

after scene updates.

Sets up a 2D

orthographic

projection matrix
(GLdouble left, GLdouble
gluOrtho2D(0.0, 300.0, defining a clipping
gluOrtho2D right, GLdouble bottom,
0.0, 300.0); volume where z is
GLdouble top)
between -1 and 1.

Useful for 2D

rendering.

Replaces the current

matrix with the

identity matrix,

glLoadIdentity None glLoadIdentity(); resetting any

transformations. Used

before applying new

transforms.
Defines a perspective

projection matrix with


(GLdouble left, GLdouble
a viewing frustum
right, GLdouble bottom, glFrustum(-1.0, 1.0,
glFrustum (truncated pyramid).
GLdouble top, GLdouble -1.0, 1.0, 2.0, 10.0);
Used for 3D
nearVal, GLdouble farVal)
perspective

projections.

Sets a perspective

(GLdouble fovy, GLdouble gluPerspective(45.0, projection matrix with

gluPerspective aspect, GLdouble zNear, (GLfloat)w/(GLfloat)h, field of view, aspect


GLdouble zFar) 1.0, 20.0); ratio, and near/far

clipping planes.

Defines the viewport

rectangle in window

(GLint x, GLint y, GLsizei coordinates where


glViewport glViewport(0, 0, w, h);
width, GLsizei height) rendering occurs.

Usually set on window

resize.

Sets the current


(GLenum mode) (e.g.,
glMatrixMode(GL_PROJECTIO matrix stack to
glMatrixMode GL_PROJECTION,
N); operate on (projection
GL_MODELVIEW)
or modelview).
(GLfloat red, GLfloat Sets the color used to
glClearColor(1.0, 1.0,
glClearColor green, GLfloat blue, clear the color buffer
1.0, 1.0);
GLfloat alpha) (background color).

(GLbitfield mask) (e.g.,


`glClear(GL_COLOR_BUFFER_ GL_DEPTH_BUFFER_B
glClear GL_COLOR_BUFFER_BIT,
BIT IT);`
GL_DEPTH_BUFFER_BIT)

Enables server-side

(GLenum cap) (e.g., GL capabilities, such


glEnable glEnable(GL_DEPTH_TEST);
GL_DEPTH_TEST) as depth testing for

correct 3D rendering.

Begins specifying
(GLenum mode) (e.g.,
vertices for a
glBegin GL_TRIANGLES, GL_QUADS, glBegin(GL_QUADS);
primitive. Must be
GL_POLYGON)
paired with glEnd().

Ends vertex

glEnd None glEnd(); specification started

by glBegin().

Specifies a vertex

glVertex2f / (GLfloat x, GLfloat y) or coordinate in 2D or

glVertex3f / (GLfloat x, GLfloat y, glVertex3fv(vertices[a]); 3D. Variants accept

glVertex3fv GLfloat z) or pointer to array floats, doubles, or

pointers to arrays.
Sets the current
(GLfloat red, GLfloat drawing color.
glColor3f /
green, GLfloat blue) or glColor3fv(colors[a]); Variants accept floats
glColor3fv
pointer to array or pointers to float

arrays.

Applies a translation

(GLfloat x, GLfloat y, glTranslatef(0.0, 0.0, transformation to the


glTranslatef
GLfloat z) -5.0); current matrix, moving

objects in 3D space.

Applies a rotation

transformation by
(GLfloat angle, GLfloat x, glRotatef(theta[axis],
glRotatef angle degrees about
GLfloat y, GLfloat z) 1.0, 0.0, 0.0);
the axis (x,y,z) to

the current matrix.

Registers the display

callback function

glutDisplayFunc void (*func)(void) glutDisplayFunc(display); called when the

window needs

redrawing.

Registers the reshape

void (*func)(int width, callback function


glutReshapeFunc glutReshapeFunc(reshape);
int height) called on window

resize events.
Registers the idle

callback function

called when the event


glutIdleFunc void (*func)(void) glutIdleFunc(spinCube);
loop is idle; often

used for animation

updates.

Registers the
void (*func)(unsigned char glutKeyboardFunc(keyboard
glutKeyboardFunc keyboard input
key, int x, int y) );
callback function.

Registers the mouse


void (*func)(int button,
glutMouseFunc glutMouseFunc(mouse); button callback
int state, int x, int y)
function.

Swaps the front and

back buffers in

double-buffered mode
glutSwapBuffers None glutSwapBuffers();
to display the

rendered frame

smoothly.

You might also like