0% found this document useful (0 votes)
28 views16 pages

UNIT I Part III-Introduction-to-OpenGL

Uploaded by

mangobanana0709
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)
28 views16 pages

UNIT I Part III-Introduction-to-OpenGL

Uploaded by

mangobanana0709
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/ 16

--------------------------------------------------------------------------------------------

Introduction to OpenGL
--------------------------------------------------------------------------------------------

OpenGL is a library of function calls for doing computer graphics. With it, one can create
interactive applications that render high-quality color images composed of 3D geometric objects
and images. The current version of OpenGL is 4.5, released on August 11, 2014, and is the
eightieth revision since the original version 1.0.
1. Steps To install Open GL for Ubuntu :
# sudo apt-get install freeglut3 freeglut3-dev
# sudo apt-get install binutils-gold

2. Configure Open GL in Eclipse Environment:

 Create C/C++ Project


 Create file Demo.cpp
 Right Click on Project
 Click on Properties
 Select C/C++ Build Tab
 Click on Settings
 Select Cross G++ Linker
 Select Libraries tab.
 Insert 3 libraries:
GL
GLU
glut
3. Software Organization in Open GL
The OpenGL API is window and operating system independent. That means that the part of
the application that draws can be platform independent. However, in order for OpenGL to be able
to render, it needs a window to draw into. Generally, this is controlled by the windowing system
on whatever platform you are working on.
Software Organization

The OpenGL Interface consists of functions in three libraries.


i. OpenGL core library: OpenGL32 on Windows and GL on most unix/linux systems (libGL.a)
ii. OpenGL Utility Library (GLU): Provides functionality in OpenGL core but avoids having to
rewrite code
iii. Links with window system: GLX for X window systems, WGL for Windows, AGL for
Macintosh
4. OpenGL Utility Toolkit (GLUT)
GLUT provides functionality common to all window systems such as opening a window,
getting input from mouse and keyboard, menus. GLUT is event-driven and its code is portable.
GLUT is designed for constructing small to medium sized OpenGL programs. But GLUT lacks the
functionality of a good toolkit for a specific platform. For example, it does not provide slide bars.
So, large applications requiring sophisticated user interfaces are better off using native window
system toolkits.
The GLUT library has C, C++ (same as C), FORTRAN, and Ada programming bindings. The
GLUT source code distribution is portable to nearly all OpenGL implementations and platforms.
The current version is 3.7.
The toolkit supports multiple windows for OpenGL rendering, callback driven event
processing, sophisticated input devices, an 'idle' routine and timers, a simple, cascading pop-up
menu facility, utility routines to generate various solid and wire frame objects, support for bitmap
and stroke fonts.
5. OpenGL Pipeline Architecture
Generally data flows from an application through the GPU to generate an image in the
frame buffer. The application will provide vertices, which are collections of data that are
composed to form geometric objects, to the OpenGL pipeline. The vertex processing stage uses a
vertex shader to process each vertex, doing any computations necessary to determine where in
the frame buffer each piece of geometry should go. The other shading stages like tessellation and
geometry shading are also used for vertex processing.

OpenGL Pipeline Architecture

A Simplified Model of the OpenGL Pipeline


After all the vertices for a piece of geometry are processed, the rasterizer determines
which pixels in the frame buffer are affected by the geometry, and for each pixel, the fragment
processing stage is employed, where the fragment shader runs to determine the final color of the
pixel.
6. Primitives and Attributes
In OpenGL, as in other graphics libraries, objects in the scene are composed of geometric
primitives, which themselves are described by vertices. A vertex in modern OpenGL is a collection
of data values associated with a location in space. Vertices may be specified in 2D, 3D, or 4D. 2D
coordinates are promoted to 3D by assigning a Z value of zero. 4D homogeneous coordinates are
reduced to 3D by dividing x, y, and z by the w coordinate (if non-zero).
Optional vertex attributes are picked up from state if not specified per-vertex. The normal
is a 3D vector perpendicular to the surface being described, and is used during lighting
calculations. The color may be an RGBA value, or a Color Index, depending on the visual type of
the window. Texture coordinates determine the mapping of a texture onto the vertex, and may be
specified with 1, 2, 3, or 4 parameters. Edge flags are used to specify if the vertex is on a boundary
of a surface. Material properties specify such things as reflectance, ambience, etc, and are used for
lighting calculations. These vertex and attribute commands, as well as many other OpenGL
commands, accept arguments either explicitly or through pointers. They also accept a variety of
data types as arguments, such as ints, floats, doubles, bytes, unsigned ints and bytes, etc.
Commands not associated with primitives are not allowed within Begin/End blocks. This allows
increased optimization of primitive processing.
The model-view matrix, texture matrix, and projection matrix each affect the vertex and its
attributes, and may be easily manipulated via transformations such as rotation, scaling, and
translation. Lighting parameters, such as material properties, light source properties, and lighting
model parameters affect lighting on a per-vertex basis.
Geometric primitives are defined in the problem domain and can be rotated, translated and
scaled. OpenGL also supports image or raster primitives. These like an array of pixels lack
geometric properties.
OpenGL only knows how to draw three things: points, lines, and triangles, but can use
collections of the same type of primitive to optimize rendering.
OpenGL Total Vertices
Description
Primitive for n Primitives

Render a single point per vertex (points may be


GL_POINTS n
larger than a single pixel)

Connect each pair of vertices with a single line


GL_LINES 2n
segment.

Connect each successive vertex to the previous one


GL_LINE_STRIP n+1
with a line segment.

GL_LINE_LOOP Connect all vertices in a loop of line segments. n

GL_TRIANGLES Render a triangle for each triple of vertices. 3n

Render a triangle from the first three vertices in the


GL_TRIANGLE_STRIP list, and then create a new triangle with the last two n+2
rendered vertices, and the new vertex.

Create triangles by using the first vertex in the list,


GL_TRIANGLE_FAN n+2
and pairs of successive vertices.

7. Clipping and Projection


Once a primitive has been assembled, it is subject to arbitrary clipping via user definable
clip planes. An OpenGL implementation must provide at least six, and they may be turned on and
off independently by the user.
Points are either clipped in our out, depending on whether they fall inside or outside the
half-space defined by the clip planes. Lines and polygons, however, may either be 100% clipped,
100% unclipped, or they may fall partially within the clip space. In this latter case, new vertices
are automatically place on the clip boundary between pre-existing vertices. Vertex attributes are
interpolated.
After clipping, vertices are transformed by the projection matrix (either perspective or
orthogonal), and then clipped to the frustum (view space), following the same process as above.
Finally, the vertices are mapped to the viewport (screen space).
8. Rasterization
Rasterization converts the above viewport-mapped primitives into fragments. Fragments
consist of pixel location in frame buffer, color, texture coordinates, and depth (z buffer).
Depending on the shading mode, vertex attributes are either interpolated across the primitive to
all fragments (smooth shading), or all fragments are assigned the same values based on one
vertex's attributes (flat shading).
Rasterization is affected by the point and line widths, the line stipple sequence, and the
polygon stipple pattern. Anti-aliasing may be enabled or disabled for each primitive type. If
enabled, the alpha color value (if in RGBA mode) or color index (if in CI mode) are modified to
reflect sub-pixel coverage.
Pixel rectangles and bitmaps are also rasterized, but they bypass the lighting and
geometrical transformations. They are groups of values heading for the frame buffer. They can be
scaled, offset, and mapped via lookup tables. The rasterization process produces a rectangle of
fragments at a location controlled by the current raster position state variable. The size may be
affected by the pixel zoom setting.
Bitmaps are similar to pixel rectangles, but the data is binary, only producing fragments
when on. This is useful for drawing text in 3D space as part of a scene.
9. Frame Buffer
Fragments produced by rasterization go to the frame buffer where they may be displayed.
The frame buffer is a rectangular array of n bit planes. The bit planes are organized into several
logical buffers -- Color, Depth, Stencil, and Accumulation.
 The color buffer contains the fragment's color info.
 The depth buffer contains the fragment's depth info, typically used for z-buffering
hidden surface removal.
 The stencil buffer can be associated with fragments that pass the conditional tests
described below and make it into the frame buffer. It can be useful for multiple-pass
algorithms.
 The accumulation buffer is also used for multiple-pass algorithms. It can average the
values stored in the color buffer. Full-screen anti aliasing can be achieved by jittering
the viewpoint. Depth of Field can be achieved by jittering the view angle. Motion blur
can be achieved by stepping the scene in time.

Stereo and double-buffering may be supported under OpenGL, depending on the


implementation. These would further divide the frame buffer into up to 4 sections -- front and
back buffer, left and right. Other auxiliary buffers may be available on some implementations.
10. Per-fragment Operations
Before being placed into the framebuffer, each fragment may be subjected to a series of
tests and modifications, each of which may be individually enabled, disabled, and controlled.
These include stencil test, depth test, and blending.
The stencil test compares the value in the stencil buffer associated with the fragment with a
reference value. If successful, the stencil value may be updated and the fragment proceeds to the
next test. If it fails, the fragment is discarded, and the stencil value may be updated with another
value.
The depth test is similar. It compares the fragment's depth with that currently in the depth
buffer. If successful, the depth buffer is updated and the fragment proceeds to the next test.
Otherwise, the fragment is discarded and the depth buffer is unchanged.
Blending mixes the fragment's color with the color already in the color buffer based on
some blend function. This is used for anti aliasing and transparency.
11. Evaluators
Evaluators allow the specification of polynomial functions of 1 or 2 variables which may be
used to determine a primitive's vertex coordinates, normal coordinates, texture coordinates,
and/or color. A polynomial map based on a Bezier basis may be specified for any of these
attributes individually.
Evaluators may either be used within primitives (generating individual vertices) or outside
of primitives (generating entire primitives).
12. Display Lists
Display lists encapsulate a group of commands so that they may be later issued as many
times as desired simply by calling the list by name. This allows increased optimization, server-
side command caching, and simplified user programming. Display lists may be redefined, but may
not be edited. They can be nested, however.
13. Feedback and Selection
The default OpenGL mode is render mode, by which primitives are rendered to the frame
buffer. There are two other modes -- feedback and selection.
In feedback mode, primitives are intercepted after processing but before rasterization. It
returns info about the primitives, such as vertex coordinates, texture coordinates, and color. This
is useful for rendering to vector devices, such as pen plotters.
In selection mode, OpenGL returns a "hit" whenever a clipped primitive lies within the view
frustum. This can be useful for picking primitives via the cursor.
14. OpenGL State
OpenGL can be viewed as a state–machine. “Setting state” is the process of initializing the
internal data that OpenGL uses to render the primitives. It can be as simple as setting up the size
of points and color that you want a vertex to be, to initializing multiple mipmap levels for texture
mapping. The state can be changed using OpenGL functions which are of two types.
i. Primitive generating functions: These can cause the machine to produce a visible output.
The state controls how vertices are processed and primitives appear.
ii . State changing functions: These either change state inside the machine or return state
information. Eg. Transformation functions, attribute functions.

15. Commonly Required OpenGL Functions


a. Specifying Simple Geometry

void glVertex[2/3/4][sifd] (TYPE xcoordinate, TYPE ycoordinate, …)


void glVertex[2/3/4]v (TYPE *coordinates)
Specifies the position of a vertex in 2,3, or 4 dimensions. The coordinates can be specified as short
s, int i, float f, or double d. If the v is present, the argument is a pointer to n array containing the
coordinates.
glVertex commands are used within glBegin/glEnd pairs to specify point, line, and polygon
vertices. The current color, normal, texture coordinates, and fog coordinate 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 glBegin(GLenum mode);
Delimits the vertices of a primitive or a group of like primitives.
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, andGL_POLYGON
void glEnd() terminates a list of vertices
void glRect[sifd] (TYPE x1, TYPE y1, TYPE x2, TYPE y2)
void glRect[sifd]v(TYPE *v1, TYPE *v2)
Specify a two dimensional axis-aligned rectangle by the x, y coordinates of the diagonally
opposite vertices (or pointers to the vertices) using the standard data types.

b. Specify Color
void glColor[34][b i f d ub us ui] (TYPE red,TYPE green,TYPE blue,TYPE alpha)
void glColor[34][b I f d ub us ui]v (TYPE *color)
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.
v: Specifies a pointer to an array that contains red, green, blue, and (sometimes) alpha values.
The initial value for the current color is (1, 1, 1, 1). The current color can be updated at any time.
In particular, glColor can be called between a call to glBegin and the corresponding call to glEnd.
void glClearColor(GLClampf r, GLClampf g, GLClampf b, GLClampf a)
specifies the red, green, blue, and alpha values used by glClear to clear the color buffers. The
initial values are all 0. Values specified by glClearColor are clamped to the range [0, 1].
void glIndexi[s i f d ub] (TYPE index)
set the current color index.
index : Specifies a pointer to a one-element array that contains the new value for the
current color index.
________________________________________________________________________________________________________
void glutSetColor(int cell,GLfloat red, GLfloat green, GLfloat blue);
cell: Color cell index (starting at zero).
Sets the cell color index colormap entry of the current window's logical colormap for the layer in
use with the color specified by red, green, and blue. The layer in use of the current window should
be a color index window. cell should be zero or greater and less than the total number of
colormap entries for the window. If the layer in use's colormap was copied by reference,
a glutSetColor call will force the duplication of the colormap.
void glPointSize(GLfloat size);
Size: Specifies the diameter of rasterized points. The initial value is 1.
glPointSize specifies the rasterized diameter of both aliased and antialiased points. Using a point
size other than 1 has different effects, depending on whether point antialiasing is enabled. To
enable and disable point antialiasing, call glEnable and glDisable with
argument GL_POINT_SMOOTH. Point antialiasing is initially disabled.

c. WORKING WITH WINDOW SYSTEM


void glFlush(void);
Different GL implementations buffer commands in several different locations, including network
buffers and the graphics accelerator itself. glFlush empties all of these buffers, causing all issued
commands to be executed as quickly as they are accepted by the actual rendering engine. Though
this execution may not be completed in any particular time period, it does complete in finite time.

void glutInit(int *argcp, char **argv);


glutInit is used to initialize the GLUT library.
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.
glutInit will initialize the GLUT library and negotiate a session with the window system. During
this process, glutInit may cause the termination of the GLUT program with an error message to
the user if GLUT cannot be properly initialized. Examples of this situation include the failure to
connect to the window system, the lack of window system support for OpenGL, and invalid
command line options.
glutInit also processes command line options, but the specific options parse are window system
dependent.

int glutCreateWindow(char *name);


name: ASCII character string for use as window name.
glutCreateWindow creates a top-level window. The name will be provided to the window system
as the window's name. The intent is that the window system will label the window with the name.
Implicitly, the current window is set to the newly created window.
Each created window has a unique associated OpenGL context. State changes to a window's
associated OpenGL context can be done immediately after the window is created. The display
state of a window is initially for the window to be shown. Until glutMainLoop is called, rendering
to a created window is ineffective because the window can not yet be displayed.
The value returned is a unique small integer identifier for the window. The range of allocated
identifiers starts at one. This window identifier can be used when calling glutSetWindow.

void glutInitDisplayMode(unsigned int mode);


glutInitDisplayMode sets the initial display mode.
mode: Display mode, normally the bitwise OR-ing of GLUT display mode bit masks below:

GLUT_RGBA: Bit mask to select an RGBA mode window. This is the default if either
GLUT_RGBA nor GLUT_INDEX are specified.
GLUT_RGB: An alias for GLUT_RGBA.
GLUT_INDEX: 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 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_ACCUM: Bit mask to select a window with an accumulation buffer.
GLUT_ALPHA: Bit mask to select a window with an alpha component to the color buffer(s).
GLUT_DEPTH: Bit mask to select a window with a depth buffer.
GLUT_STENCIL: Bit mask to select a window with a stencil buffer.
Also used are GLUT_MULTISAMPLE, GLUT_STEREO, GLUT_LUMINANCE

void glutInitWindowSize(int width, int height);


void glutInitWindowPosition(int x, int y);

glutInitWindowPosition and glutInitWindowSize set the initial position and size respectively.
Width: Width in pixels.
Height: Height in pixels.
X: Window X location in pixels.
Y: Window Y location in pixels.
Windows created by glutCreateWindow will be requested to be created with the current initial
window position and size. The initial value of the initial window position GLUT state is -1 and -1. If
either the X or Y component to the initial window position is negative, the actual window position
is left to the window system to determine. The initial value of the initial window size GLUT state is
300 by 300. The initial window size components must be greater than zero.
void glViewport(Glint x, GLint y, GLsizei width, GLsizei height);
Sets the viewport.
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.

void glutMainLoop(void);
glutMainLoop enters the GLUT event processing loop. This routine should be called at most once
in a GLUT program. Once called, this routine will never return. It will call as necessary any
callbacks that have been registered.

void glutDisplayFunc(void (*func)(void));


func: The new display callback function.
glutDisplayFunc sets the display callback for the current window. GLUT determines when the
display callback should be triggered based on the window's redisplay state. The redisplay state
for a window can be either set explicitly by calling glutPostRedisplay or implicitly as the result of
window damage reported by the window system. Multiple posted redisplays for a window are
coalesced by GLUT to minimize the number of display callbacks called.

void glutPostRedisplay(void);
Mark the normal plane of current window as needing to be redisplayed. The next iteration
through glutMainLoop, the window's display callback will be called to redisplay the window's
normal plane. Multiple calls to glutPostRedisplay before the next display callback opportunity
generates only a single redisplay callback.

void glutSwapBuffers(void);
glutSwapBuffers swaps the buffers of the current window if double buffered.
Specifically, glutSwapBuffers promotes the contents of the back buffer of the layer in use of
the current window to become the contents of the front buffer. The contents of the back buffer
then become undefined.
void glutSetWindow(int win);
int glutGetWindow(void);
win: Identifier of GLUT window to make the current window.
glutSetWindow sets the current window; glutGetWindow returns the identifier of the current
window.
If no windows exist or the previously current window was destroyed, glutGetWindow returns
zero.

d. INTERACTION
void glutMouseFunc(void (*func)(int button, int state, int x, int y));
func:The new mouse callback function.
glutMouseFunc sets the mouse callback for the current window. When a user presses and releases
mouse buttons in the window, each press and each release generates a mouse callback.
The button parameter is one of GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON,
or GLUT_RIGHT_BUTTON.
The state parameter is either GLUT_UP or GLUT_DOWN indicating whether the callback was due
to a release or press respectively. The x and y callback parameters indicate the window relative
coordinates when the mouse button state changed.
Passing NULL to glutMouseFunc disables the generation of mouse callbacks.
void glutReshapeFunc(void (*func)(int width, int height));
glutReshapeFunc sets the reshape callback for the current window. The reshape callback is
triggered when a window is reshaped, immediately before a window's first display callback after a
window is created. The width and height parameters of the callback specify the new window size
in pixels. Before the callback, the current windowis set to the window that has been reshaped.
If a reshape callback is not registered for a window or NULL is passed to glutReshapeFunc (to
deregister a previously registered callback), the default reshape callback is used. This default
callback will simply call glViewport(0,0,width,height) on the normal plane (and on the overlay if
one exists).
void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y));
glutKeyboardFunc sets the keyboard callback for the current window. When a user types into the
window, each key press generating an ASCII character will generate a keyboard callback.
The x and y callback parameters indicate the mouse location in window relative coordinates when
the key was pressed. When a new window is created, no keyboard callback is initially registered,
and ASCII key strokes in the window are ignored. During a keyboard
callback, glutGetModifiers may be called to determine the state of modifier keys when the
keystroke generating the callback occurred.

void glutIdleFunc(void (*func)(void));


glutIdleFunc sets the global idle callback to be func so a GLUT program can perform background
processing tasks or continuous animation when window system events are not being received.

void glutTimerFunc(unsigned int msecs, void (*func)(int value), value);


glutTimerFunc registers the timer callback func to be triggered in at least msecs milliseconds.
The value parameter to the timer callback will be the value of the value parameter
to glutTimerFunc. GLUT attempts to deliver the timer callback as soon as possible after the
expiration of the callback's time interval.

e. TRANSFORMATIONS
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.
glMatrixMode sets the current matrix mode. mode can assume one of four values:
GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE, GL_COLOR.
To find out which matrix stack is currently the target of all matrix operations, call glGet with
argument GL_MATRIX_MODE. The initial value is GL_MODELVIEW.
void glLoadIdentity(void):
glLoadIdentity replaces the current matrix with the identity matrix. It is semantically equivalent
to calling glLoadMatrix with the identity matrix but in some cases it is more efficient.
void glPushMatrix (void);
void glPopmatrix(void);
Push and pop the current matrix. There is a stack of matrices for each of the matrix modes. In
GL_MODELVIEW mode, the stack depth is at least 32. In the other modes, GL_COLOR,
GL_PROJECTION, and GL_TEXTURE, the depth is at least 2. The current matrix in any mode is the
matrix on the top of the stack for that mode. Initially, each of the stacks contains one matrix, an
identity matrix.
void glRotate[df] (GLDouble angle, GLDouble x, GLDouble y, GLDouble z);
multiply the current matrix by a rotation matrix
angle - Specifies the angle of rotation, in degrees.
x, y, z- Specify the x, y, and z coordinates of a vector, respectively.
glRotate produces a rotation of angle degrees around the vector x y z .
void glScale[df] ( GLDouble x, GLDouble y, GLDouble z);
glScale multiply the current matrix by a general scaling matrix
x, y, z Specify scale factors along the x, y, and z axes, 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 glTranslate[df] ( GLDouble x, GLDouble y, GLDouble z);
glTranslate multiply the current matrix by a translation matrix. x, y, z: Specify the x, y,
and z coordinates of a translation vector.
void glMultMatrixd(const GLdouble m);
void glMultMatrixf(const GLfloat m);
glMultMatrix multiplies the current matrix with the one specified using m, and replaces the
current matrix with the product.
void glLoadMatrixd(const GLdouble m);
void glLoadMatrixf(const GLfloat m);
glLoadMatrix replace the current matrix with the specified matrix. m specifies a pointer to 16
consecutive values, which are used as the elements of a 4 x 4 column-major matrix. The current
matrix is the projection matrix, modelview matrix, or texture matrix, depending on the current
matrix mode.
13.6 VIEWING
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble
nearVal, GLdouble farVal);
glOrtho describes a transformation that produces a parallel projection. It multiplies the current
matrix with an orthographic matrix. 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. nearVal, farVal specify the distances to the nearer and farther depth clipping planes. These
values are negative if the plane is to be behind the viewer.
void gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
define a 2D orthographic projection matrix. 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. gluOrtho2D sets up a two-dimensional orthographic viewing region.
This is equivalent to calling glOrtho with near = -1 and far = 1.
void gluLookAt(GLdouble eyeX, eyeY,eyeZ, centerX, centerY, centerZ, upX, upY, 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.
gluLookAt creates a viewing matrix derived from an eye point, a reference point indicating the
center of the scene, and an UP vector.
void gluPerspective(GLDouble fovy, GLDouble aspect, GLDouble zNear, GLDouble zFar);
gluPerspective specifies a viewing frustum into the world coordinate system and sets up a
perspective projection matrix. 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).

You might also like