OpenGL reference

Prepared By Samira Lahmar

For the course

CS409 Computer Graphics

Extracted from the following site

First Semester 1432-1433

OpenGL reference

GL

glBegin, glEnd — delimit the vertices of a primitive or a group of like primitives
void glBegin / ( / GLenum mode );
mode
Specifies the primitive or primitives that will be created from vertices presented between glBegin and the subsequent glEnd. Ten symbolic constants are accepted: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON.
glClear — clear buffers to preset values
void glClear / ( / GLbitfield mask );
mask
Bitwise OR of masks that indicate the buffers to be cleared. The four masks are GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_ACCUM_BUFFER_BIT, and GL_STENCIL_BUFFER_BIT.
glClearColor specifies the red, green, blue, and alpha values used by glClear to clear the color buffers. Values specified by glClearColor are clamped to the range [0,1].
void glClearColor / ( / GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha );
red , green , blue , alpha
Specify the red, green, blue, and alpha values used when the color buffers are cleared. The initial values are all 0.
glColor : set the current color
void glColor4i / ( / GLint red , GLint green , GLint blue , GLint alpha );
red, green, blue
Specify new red, green, and blue values for the current color.
alpha
Specifies a new alpha value for the current color. Included only in the four-argument glColor4 commands.
glEnable, glDisable — enable or disable server-side GL capabilities
void glEnable / ( / GLenum cap );
void glDisable / ( / GLenum cap );
cap
Specifies a symbolic constant indicating a GL capability.
glFlush — force execution of GL commands in finite time
void glFlush / ( / );
glLineStipple — specify the line stipple pattern
void glLineStipple / ( / GLint factor , GLushort pattern );
factor
Specifies a multiplier for each bit in the line stipple pattern. If factor is 3, for example, each bit in the pattern is used three times before the next bit in the pattern is used. factor is clamped to the range [1, 256] and defaults to 1.
pattern
Specifies a 16-bit integer whose bit pattern determines which fragments of a line will be drawn when the line is rasterized. Bit zero is used first; the default pattern is all 1's.
glLineWidth — specify the width of rasterized lines
void glLineWidth / ( / GLfloat width );
width
Specifies the width of rasterized lines. The initial value is 1.
glLoadIdentity — replace the current matrix with the identity matrix
void glLoadIdentity / ( / );
glLoadMatrixd, glLoadMatrixf — replace the current matrix with the specified matrix
void glLoadMatrixd / ( / const GLdouble *m );
void glLoadMatrixf / ( / const GLfloat *m );
m
Specifies a pointer to 16 consecutive values, which are used as the elements of a 4×4 column-major matrix.
glMatrixMode — specify which matrix is the current matrix
void glMatrixMode / ( / GLenum mode );
mode
Specifies which matrix stack is the target for subsequent matrix operations. Three values are accepted: GL_MODELVIEW, GL_PROJECTION, and GL_TEXTURE. The initial value is GL_MODELVIEW. Additionally, if the GL_ARB_imaging extension is supported, GL_COLOR is also accepted.
glOrtho — multiply the current matrix with an orthographic matrix
void glOrtho / ( / GLdouble left , GLdouble right , GLdouble bottom , GLdouble top , GLdouble zNear , GLdouble zFar );
left, right
Specify the coordinates for the left and right vertical clipping planes.
bottom, top
Specify the coordinates for the bottom and top horizontal clipping planes.
zNear, zFar
Specify the distances to the nearer and farther depth clipping planes. These values are negative if the plane is to be behind the viewer.
glPointSize — specify the diameter of rasterized points
void glPointSize / ( / GLfloat size );
size
Specifies the diameter of rasterized points. The initial value is 1.
glPolygonMode — select a polygon rasterization mode
void glPolygonMode / ( / GLenum face , GLenum mode );
face
Specifies the polygons that mode applies to. Must be GL_FRONT for front-facing polygons, GL_BACK for back-facing polygons, or GL_FRONT_AND_BACK for front- and back-facing polygons.
mode
Specifies how polygons will be rasterized. Accepted values are GL_POINT, GL_LINE, and GL_FILL. The initial value is GL_FILL for both front- and back-facing polygons.
glPushMatrix, glPopMatrix — push and pop the current matrix stack
void glPushMatrix / ( / );
void glPopMatrix / ( / );
glRasterPos: The GL maintains a 3D position in window coordinates. This position, called the raster position, is used to position pixel and bitmap write operations. It is maintained with subpixel accuracy.
void glRasterPos4i / ( / GLint x , GLint y , GLint z , GLint w );
x , y , z , w
Specify the x, y, z, and w object coordinates (if present) for the raster position.
glRectd, glRectf, glRecti, glRects, glRectdv, glRectfv, glRectiv, glRectsv — draw a rectangle
void glRecti / ( / GLint x1 , GLint y1 , GLint x2 , GLint y2 );
x1, y1
Specify one vertex of a rectangle.
x2, y2
Specify the opposite vertex of the rectangle.
glRotated, glRotatef — multiply the current matrix by a rotation matrix
void glRotated / ( / GLdouble angle , GLdouble x , GLdouble y , GLdouble z );
void glRotatef / ( / GLfloat angle , GLfloat x , GLfloat y , GLfloat z );
angle
Specifies the angle of rotation, in degrees.
x, y, z
Specify the x, y, and z coordinates of a vector, respectively.
glScale produces a nonuniform scaling along the x, y, and z axes. The three parameters indicate the desired scale factor along each of the three axes.
void glScaled / ( / GLdouble x , GLdouble y , GLdouble z );
void glScalef / ( / GLfloat x , GLfloat y , GLfloat z );
x, y, z
Specify scale factors along the x, y, and z axes, respectively.
glTranslated, glTranslatef — multiply the current matrix by a translation matrix
void glTranslated / ( / GLdouble x , GLdouble y , GLdouble z );
void glTranslatef / ( / GLfloat x , GLfloat y , GLfloat z );
x, y, z
Specify the x, y, and z coordinates of a translation vector.
glVertex commands are used within glBegin/glEnd pairs to specify point, line, and polygon vertices. The current color, normal, and texture coordinates are associated with the vertex when glVertex is called. When only x and y are specified, z defaults to 0 and w defaults to 1. When x, y, and z are specified, w defaults to 1.
void glVertex4i / ( / GLint x , GLint y , GLint z , GLint w );
x , y , z , w
Specify x, y, z, and w coordinates of a vertex. Not all parameters are present in all forms of the command.
glViewport — set the viewport
void glViewport / ( / GLint x , GLint y , GLsizei width , GLsizei height );
x , y
Specify the lower left corner of the viewport rectangle, in pixels. The initial value is (0,0) .
width , height
Specify the width and height of the viewport. When a GL context is first attached to a window, width and height are set to the dimensions of that window.

GLU

gluLookAt creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector.
void gluLookAt / ( / GLdouble eyeX , GLdouble eyeY , GLdouble eyeZ , GLdouble centerX , GLdouble centerY , GLdouble centerZ , GLdouble upX , GLdouble upY , GLdouble upZ );
eyeX, eyeY, eyeZ
Specifies the position of the eye point.
centerX, centerY, centerZ
Specifies the position of the reference point.
upX, upY, upZ
Specifies the direction of the up vector.
gluOrtho2D sets up a two-dimensional orthographic viewing region. This is equivalent to calling glOrtho with near=-1 and far=1.
void gluOrtho2D / ( / GLdouble left, GLdouble right, GLdouble bottom, GLdouble top );
eft, right
Specify the coordinates for the left and right vertical clipping planes.
bottom, top
Specify the coordinates for the bottom and top horizontal clipping planes.
gluPerspective — set up a perspective projection matrix
void gluPerspective / ( / GLdouble fovy , GLdouble aspect , GLdouble zNear , GLdouble zFar );
fovy
Specifies the field of view angle, in degrees, in the y direction.
aspect
Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
zNear
Specifies the distance from the viewer to the near clipping plane (always positive).
zFar
Specifies the distance from the viewer to the far clipping plane (always positive).

GLUT

glutAddMenuEntry - adds a menu entry to the bottom of the current menu.
void glutAddMenuEntry / ( / char *name , int value );
name ASCII character string to display in the menu entry.
value Value to return to the menu's callback function if the menu entry is selected.
glutAddSubMenu - adds a sub-menu trigger to the bottom of the current menu.
void glutAddSubMenu / ( / char *name , int menu );
name ASCII character string to display in the menu item from which to cascade the sub-menu.
Menu Identifier of the menu to cascade from this sub-menu menu item.
glutAttachMenu/glutDetachMenu - attaches/detaches a mouse button for the current window to the identifier of the current menu
void glutAttachMenu / ( / int button );
void glutDetachMenu / ( / int button );
button The button to attach a menu or detach a menu.
glutBitmapCharacter — renders a bitmap character using OpenGL.
void glutBitmapCharacter / ( / void *font , int character );
font
Bitmap font to use.
character
Character to render (not confined to 8 bits).
glutBitmapWidth returns the width in pixels of a bitmap character in a supported bitmap font. While the width of characters in a font may vary (though fixed width fonts do not vary), the maximum height characteristics of a particular font are fixed.
glutBitmapLength returns the length in pixels of a string (8-bit characters). This length is equivalent to summing all the widths returned by glutBitmapWidth for each character in the string.
int glutBitmapWidth / ( / void *font , int character );
int glutBitmapLength / ( / void *font , const unsigned char *string );
font
Bitmap font to use. For valid values, see the glutBitmapCharacter description.
character
Character to return width of (not confined to 8 bits).
string
Text string (8-bit characters), nul terminated.
glutCreateMenu - creates a new pop-up menu.
int glutCreateMenu / ( / void (*func)(int value));
func The callback function for the menu that is called when a menu entry from the menu is selected. The value passed to the callback is determined by the value for the selected menu entry.
glutCreateWindow - creates a top-level window.
int glutCreateSubWindow / ( / int win , int x , int y , int width , int height );
win Identifier of the subwindow's parent window.
x Window X location in pixels relative to parent window's origin.
y Window Y location in pixels relative to parent window's origin.
Width Width in pixels.
height Height in pixels.
glutDestroyMenu destroys the specified menu by menu. If menu was the current menu, the current menu becomes invalid and glutGetMenu will return zero.
void glutDestroyMenu / ( / int menu );
menu
The identifier of the menu to destroy.
glutDisplayFunc - sets the display callback for the current window.
void glutDisplayFunc / ( / void (*func)(void));
func
The new display callback function.
glutFullScreen - requests that the current window be made full screen.
void glutFullScreen / ( / );
glutIdleFunc - sets the global idle callback.
void glutIdleFunc ( / void (*func)());
func
The new idle callback function.
glutIgnoreKeyRepeat determines if auto repeat keystrokes are reported to the current window.
void glutIgnoreKeyRepeat / ( / int ignore );
ignore
Non-zero indicates auto repeat keystrokes should not be reported by the keyboard and special callbacks; zero indicates that auto repeat keystrokes will be reported.
glutInit - initialize the GLUT library.
void glutInit / ( / int *argcp , char **argv );
argcp A pointer to the program's unmodified argc variable from main. Upon return, the value pointed to
by argcp will be updated, because glutInit extracts any command line options intended for the
GLUT library.
argv The program's unmodified argv variable from main. Like argcp, the data for argv will be
updated because glutInit extracts any command line options understood by the GLUT library.
glutInitDisplayMode - sets the initial display mode.
void glutInitDisplayMode / ( / unsigned int mode );
mode Display mode, normally the bitwise OR-ing of GLUT display mode bit masks. See values below:
GLUT_RGBA
Bit mask to select an RGBA mode window. This is the default if neither GLUT_RGBA nor GLUT_INDEX are specified.
GLUT_RGB
An alias for GLUT_RGBA.
.
GLUT_SINGLE
Bit mask to select a single buffered window. This is the default if neither GLUT_DOUBLE or GLUT_SINGLE are specified.
GLUT_DOUBLE
Bit mask to select a double buffered window. This overrides GLUT_SINGLE if it is also specified.
GLUT_DEPTH
Bit mask to request a window with a depth buffer.

glutInitWindowSize-
glutInitWindowPosition - set the initial window position and size respectively.
void glutInitWindowSize / ( / int width , int height );
void glutInitWindowPosition / ( / int x , int y );
width
Width in pixels.
height
Height in pixels.
x
Window X location in pixels.
y
Window Y location in pixels.
glutKeyboardFunc - sets the keyboard callback for the current window.
void glutKeyboardFunc / ( / void (*func)(unsigned char key, int x, int y));
func
The new keyboard callback function.
glutMainLoop - enters the GLUT event processing loop.
void glutMainLoop();
glutMenuStatusFunc — sets the global menu status callback.
void glutMenuStatusFunc / ( / void (*func)(int status, int x, int y));
void glutMenuStateFunc / ( / void (*func)(int status));
func
The new menu status (or state) callback function.
glutMotionFunc / glutMotionFunc - set the motion and passive motion callbacks respectively for the current window.
void glutMotionFunc / ( / void (*func)(int x, int y));
void glutPassiveMotionFunc / ( / void (*func)(int x, int y));
func
The new motion or passive motion callback function.
glutMouseFunc - sets the mouse callback for the current window. Passing NULL to glutMouseFunc disables the generation of mouse callbacks.
void glutMouseFunc / ( / void (*func)(int button, int state, int x, int y));
func
The new mouse callback function.
glutPositionWindow - requests a change to the position of the current window.
void glutPositionWindow / ( / int x , int y );
x
New X location of window in pixels.
y
New Y location of window in pixels.
glutPostRedisplay - marks the current or specified window as needing to be redisplayed. glutPostWindowRedisplay works the specified window as needing to be redisplayed. After either call, the next iteration through glutMainLoop, the window's display callback will be called to redisplay the window's normal plane.
void glutPostRedisplay / ( / );
void glutPostWindowRedisplay / ( / int win );
glutReshapeFunc - sets the reshape callback for the current window.
void glutReshapeFunc / ( / void (*func)(int width, int height));
func
The new reshape callback function.
glutReshapeWindow - requests a change to the size of the current window.
void glutReshapeFunc / ( / void (*func)(int width, int height));
func
The new reshape callback function.
glutSetWindow - set/get the current window
void glutSetWindow / ( / int win );
int glutGetWindow / ( / );
win
Identifier of GLUT window to make the current window.
glutSolidCone and glutWireCone render a solid or wireframe cone respectively oriented along the z axis. The base of the cone is placed at z=0, and the top at z=height. The cone is subdivided around the z axis into slices, and along the z axis into stacks.
void glutSolidCone / ( / GLdouble base , GLdouble height , GLint slices , GLint stacks );
void glutWireCone / ( / GLdouble base , GLdouble height , GLint slices , GLint stacks );
base
The radius of the base of the cone.
height
The height of the cone.
slices
The number of subdivisions around the Z axis.
stacks
The number of subdivisions along the Z axis.
glutSolidSphere, glutWireSphere : Renders a sphere centered at the modeling coordinates origin of the specified radius. The sphere is subdivided around the Z axis into slices and along the Z axis into stacks.
void glutSolidSphere / ( / GLdouble radius , GLint slices , GLint stacks );
void glutWireSphere / ( / GLdouble radius , GLint slices , GLint stacks );
radius
The radius of the sphere.
slices
The number of subdivisions around the Z axis (similar to lines of longitude).
stacks
The number of subdivisions along the Z axis (similar to lines of latitude).
glutSpecialFunc sets the special keyboard callback for the current window. The special keyboard callback is triggered when keyboard function or directional keys are pressed. The key callback parameter is a GLUT_KEY_* constant for the special key pressed. The x and y callback parameters indicate the mouse in window relative coordinates when the key was pressed. When a new window is created, no special callback is initially registered and special key strokes in the window are ignored. Passing NULL to glutSpecialFunc disables the generation of special callbacks.
void glutSpecialFunc / ( / void (*func)(int key, int x, int y));
func
The new special callback function.
glutSpecialUpFunc sets the special keyboard up (key release) callback for the current window. The special keyboard up callback is triggered when keyboard function or directional keys are released. The key callback parameter is a GLUT_KEY_* constant for the special key pressed. The x and y callback parameters indicate the mouse in window relative coordinates when the key was pressed. When a new window is created, no special up callback is initially registered and special key releases in the window are ignored. Passing NULL to glutSpecialUpFunc disables the generation of special up callbacks.
void glutSpecialUpFunc / ( / void (*func)(int key, int x, int y));
func
The new special callback function.
glutStrokeCharacter: Without using any display lists, glutStrokeCharacter renders the character in the named stroke font. The available fonts are:
void glutStrokeCharacter / ( / void *font , int character );
font
Stroke font to use.
character
Character to render (not confined to 8 bits).
glutStrokeWidth returns the width in modeling units of a stroke character in a supported stroke font. While the width of characters in a font may vary (though fixed width fonts do not vary), the maximum height characteristics of a particular font are fixed.
glutStrokeLength returns the length in modeling units of a string (8-bit characters). This length is equivalent to summing all the widths returned by glutStrokeWidth for each character in the string.
int glutStrokeWidth / ( / void *font , int character );
int glutStrokeLength / ( / void *font , const unsigned char *string );
font
Stroke font to use. For valid values, see the glutStrokeWidth description.
character
Character to return width of (not confined to 8 bits).
string
Text string (8-bit characters), null terminated.
glutSwapBuffers - swaps the buffers of the current window if double buffered.
void glutSwapBuffers / ( / );

Additional Part