CG Help Manual
CG Help Manual
INTRODUCTION
OpenGL (Open Graphics Library) is an application program interface (API) that is used to define 2D
and 3D computer graphics.
The interface consists of over 250 different function calls which can be used to draw complex threedimensional scenes from simple primitives. OpenGL was developed by Silicon Graphics Inc. (SGI) in 1992 and
is widely used in CAD, virtual reality, scientific visualization, information visualization, and flight simulation.
OpenGL's basic operation is to accept primitives such as points, lines and polygons, and convert them into
pixels. This is done by a graphics pipeline known as the OpenGL state machine.
FEATURES OF OpenGL :
Viewing and Modeling permits arranging objects in a 3-dimensional scene, move our camera around
space and select the desired vantage point for viewing the scene to be rendered.
Texture mapping helps to bring realism into our models by rendering images of realistic looking
Materials lighting OpenGL provides commands to compute the color of any point given the properties
Double buffering helps to eliminate flickering from animations. Each successive frame in an animation
is built in a separate memory buffer and displayed only when rendering of the frame is complete.
Anti-aliasing reduces jagged edges in lines drawn on a computer display. Jagged lines often appear
when lines are drawn at low resolution. Anti-aliasing is a common computer graphics technique that modifies
the color and intensity of the pixels near the line in order to reduce the artificial zig-zag.
Gouraud shading is a technique used to apply smooth shading to a 3D object and provide subtle color
Z-buffering keeps track of the Z coordinate of a 3D object. The Z-buffer is used to keep track of the
proximity of the viewer's object. It is also crucial for hidden surface removal
GLUT Fuctions :The OpenGL Utility Toolkit (GLUT) is a programming interface with ANSI C and FORTRAN bindings
for writing window system independent OpenGL programs.
Meaning
Bit mask to select an RGBA mode window. This is the default if neither
GLUT_RGBA nor GLUT_INDEX are specified.
An alias for GLUT_RGBA.
Bit mask to select a color index mode window. This overrides
GLUT_RGBA if it is also specified.
GLUT_SINGLE
Bit mask to select a single buffered window. This is the default if neither
GLUT_DOUBLE
GLUT_DEPTH
Value
GL_POINTS
Meaning
Treats each vertex as a single point. Vertex n defines point n. Npoints are
drawn.
GL_LINES
Treats each pair of vertices as an independent line segment. Vertices 2n 1 and 2n define line n. N/2 lines are drawn.
GL_LINE_STRIP
Draws a connected group of line segments from the first vertex to the last.
Draws a connected group of line segments from the first vertex to the last,
then back to the first. Vertices n and n + 1 define line n. The last line,
however, is defined by vertices N and 1. N lines are drawn.
GL_TRIANGLES
GL_TRIANGLE_STRIP Draws a connected group of triangles. One triangle is defined for each vertex
presented after the first two vertices. For odd n, vertices n, n + 1, and n +
2 define triangle n. For even n, vertices n + 1, n, and n + 2 define triangle n. N
- 2 triangles are drawn.
GL_TRIANGLE_FAN
Draws a connected group of triangles. one triangle is defined for each vertex
presented after the first two vertices. Vertices 1, n + 1, n + 2 define
triangle n. N - 2 triangles are drawn.
GL_QUADS
GL_QUAD_STRIP
GL_POLYGON
Value
Meaning
GL_COLOR_BUFFER_BIT
GL_DEPTH_BUFFER_BIT
glClearColor:- The glClearColor function specifies clear values for the color buffers.
Value
GL_DEPTH_TEST
Meaning
If enabled, do depth comparisons and update the depth buffer.
SeeglDepthFunc and glDepthRange.
GL_LINE_SMOOTH If enabled, draw lines with correct filtering. If disabled, draw aliased lines.
See glLineWidth.
GL_LINE_STIPPLE
If enabled, use the current line stipple pattern when drawing lines. SeeglLineStipple.
GL_NORMALIZE
If enabled, normal vectors specified with glNormal are scaled to unit length after
transformation. See glNormal.
GL_POINT_SMOOTH If enabled, draw points with proper filtering. If disabled, draw aliased points.
See glPointSize.
glFlush:- The glFlush function forces execution of OpenGL functions in finite time.
Syntax:- void glFlush(void);
This function has no parameters.
glFrustum:- The glFrustum function multiplies the current matrix by a perspective matrix.
Syntax :- void glFrustum(GLdouble left, GLdouble right, GLdouble bottom,
GLdouble top, GLdouble zNear, GLdouble zFar);
left :- The coordinate for the left-vertical clipping plane.
right :- The coordinate for the right-vertical clipping plane.
bottom :- The coordinate for the bottom-horizontal clipping plane.
Meaning
The params parameter contains four floating-point values that
specify the ambient RGBA intensity of the light. Floating-point
values are mapped directly. Neither integer nor floating-point
values are clamped. The default ambient light intensity is (0.0, 0.0,
0.0, 1.0).
GL_DIFFUSE
GL_SPECULAR
GL_POSITION
param :- Specifies the value that parameter pname of light source light will be set to.
glLoadIdentity :- The glLoadIdentity function replaces the current matrix with the identity matrix.
Syntax :- void WINAPI glLoadIdentity(void);
glMatrixMode:- The glMatrixMode function specifies which matrix is the current matrix.
Syntax:- void glMatrixMode(GLenum mode);
mode :- The matrix stack that is the target for subsequent matrix operations. The mode parameter can assume
one of three values.
Value
Meaning
glOrtho:- The glOrtho function multiplies the current matrix by an orthographic matrix.
Syntax:- void glOrtho(GLdouble left, GLdouble right, GLdouble bottom,
GLdouble top, GLdouble zNear, GLdouble zFar);
left :-The coordinates for the left vertical clipping plane.
right :- The coordinates for theright vertical clipping plane.
Bottom:- The coordinates for the bottom horizontal clipping plane.
top :- The coordinates for the top horizontal clipping plans.
zNear :- The distances to the nearer depth clipping plane. This distance is negative if the plane is to be behind
the viewer.
zFar :- The distances to the farther depth clipping plane. This distance is negative if the plane is to be behind the
viewer.
glPointSize :- The glPointSize function specifies the diameter of rasterized points.
Syntax :- void glPointSize(GLfloat size);
Size:-The diameter of rasterized points. The default is 1.0.
glPushMatrix & glPopMatrix:- The glPushMatrix and glPopMatrix functions push and pop the current
matrix stack.
Syntax:- void WINAPI glPopMatrix(void);
glRotatef:- The glRotatef function multiplies the current matrix by a rotation matrix.
Syntax :- void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
angle :- The angle of rotation, in degrees.
X :- The x coordinate of a vector.
y :- The y coordinate of a vector.
z :- The z coordinate of a vector.
glScalef :- The glScaled and glScalef functions multiply the current matrix by a general scaling matrix.
Syntax
top,
:- void
gluOrtho2D(GLdouble
left,
GLdouble bottom);
GLdouble
right,
GLdouble