Professional Documents
Culture Documents
1. INTRODUCTION
The term computer graphics includes almost everything on computers that is not
text or sound. Today nearly all computers use some graphics and users expect to control
their computer through icons and pictures rather than just by typing. The term Computer
Graphics has several meanings.
Today computers and computer-generated images touch many aspects of our daily
life. Computer imagery is found on television, in newspapers, in weather reports, and
during surgical procedures. A well-constructed graph can present complex statistics in
a form that is easier to understand and interpret. Such graphs are used to illustrate
papers, reports, theses, and other presentation material. A range of tools and facilities
are available to enable users to visualize their data, and computer graphics are used in
many disciplines.
1.2. VISUALIZATION
Models and frameworks for building visualizations include the data flow models
popularized by systems such as AVS,IRIS Explorer, and VTK toolkit, and data state
models in spreadsheet systems such as the spreadsheet for Visualization and Spreadsheet
for images.
2.1. SPECIFICATION:
At its most basic level OpenGL is specification, meaning it is simply a document that
describes a set of functions and the precise behaviors that they must perform, from this
specification, hardware vendors create implementations---libraries of functions created to
match the functions stated in the OpenGL specification, making use of hardware
acceleration where possible. Hardware vendors have to meet specific tests to be able to
qualify their implementation as an OpenGL implementation.
2.2 OVERVIEW:
2.3 GLUT
GLUT is a complete API written by Mark Kilgard which lets you create windows
and handle the messages. It exists for several platforms that means that a program which
uses GLUT can be compiled on many platforms without (or at least with very few)
changes in the code.
3.SYSTEM REQUIREMENTS
Functional Requirements
Non Functional Requirements are qualities or standards that the system under
development must have or comply with, but which are not tasks that will be automated by
the system
3.3 FLOWCHART
START
Interrup
Yes t
No
Z z
keyboa Airplane is
rd not moved
Rotate Rotate
clockwise anticlockwise
a c
keyboa
rd
animate Move
camera
1 keyboa 2
rd
ULF
UF
3 4
keyboa
rd
URF LF
5 6
keyboa
rd
F RF
7 keyboa 8
rd
D---- Down
DLF DF
9 q U----- Up
keyboa
rd L------- Left
DRF EXIT
R ----- Right
4.IMPLEMENTATION
4.1 MODULES
draw_airplane()
this function is used to airplane model having different regions
such as nose , tail, body 1/2 , body 2/2 ,left wing , right wing,left
wingtip , right wingtip , left flap , right flap,tailwing,rudder,cockpit
left front,cockpit right front,cockpit left back,cockpit right
back,cockpit top.
animate()
this function is used to animate the airplane model.
move_camera()
this function is used to move the airplane in all directions.
keyboard()
this function deals with normal events originating from keyboard.
display()
void animate(void);
void move_camera(void);
glEnable (GL_DEPTH_TEST);
//draw_ground();
draw_airplane ();
glClearDepth (1.0f);
glDepthFunc (GL_LEQUAL);
// The Type Of Depth Testing
glEnable (GL_DEPTH_TEST);
glEnable (GL_LINE_SMOOTH);
glDisable (GL_DEPTH_TEST);
glColor3f(.01,.01,.01);
glutSwapBuffers ();
void animate ()
glTranslatef(0,0,0.1);
glutPostRedisplay();
void move_camera()
glTranslatef(0,0,-0.1);
glutPostRedisplay();
int stencil;
glEdgeFlag (1);
glEdgeFlag (0);
glEdgeFlag (1);
glEdgeFlag (1);
glVertex3f ( 1, 0, -3);
glVertex3f ( 3, 0, -4);
glVertex3f ( 3, 0, -5);
glEdgeFlag (0);
glEnd ();
glEdgeFlag (0);
glVertex3f ( 2, 0, 4);
glEdgeFlag (1);
glVertex3f ( 2, 0, -.5);
glVertex3f ( 2, 0, -1);
glEdgeFlag (0);
glVertex3f ( 1, 0, -1);
glEdgeFlag (1);
glEdgeFlag (0);
glEdgeFlag (1);
glVertex3f ( 1, 0, -1);
glEdgeFlag (0);
glVertex3f ( 1, 0, -3);
glEdgeFlag (1);
glEdgeFlag (0);
glEnd ();
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
//glLoadIdentity ();
printf("\nControls\n");
printf("-------------------------------------------");
printf("-------------------------------------------");
printf("\n*******************************************");
printf("-------------------------------------------");
printf("-------------------------------------------");
printf("\n*******************************************");
char dummy;
scanf("%c",&dummy);
glutCreateWindow (argv[0]);
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutKeyboardFunc (keyboard);
if(animation)glutIdleFunc(animate);
if(mvcam)glutIdleFunc(move_camera);
glutFullScreen();
glutMainLoop ();
return EXIT
glColor3f()
o Sets the current color.
o Syntax: glColor3f(GLfloatred,GLfloatgreen,GLfloat blue);
glutBitmapCharacter()
o glutBitmapCharacter renders a bitmap character using OpenGL.
o Syntax: void glutBitmapCharacter(void *font, int character);
glClearColor()
o The glClearColor function specifies clear values for the color
buffers.
o Syntax: glClearColor(GLclampf red, GLclampf green, GLclampf
blue,GLclampf alpha);
glClear()
o The glClear function clears buffers to preset values.
o Syntax: glClear(GLbitfield mask);
glFlush()
o The glFlush function forces execution of OpenGL functions in
finite time.
o Syntax: glFlush(void);
glutPostRedisplay()
o glutPostRedisplay marks the current window as needing to be
redisplayed.
o Syntax: glutPostRedisplay(void);
glutSwapBuffers()
o glutSwapBuffers swaps the buffers of the current window if double
buffered.
o Syntax: glutSwapBuffers(void);
glPushMatrix()
o Used to push the current matrix onto stack
o Syntax: glPushMatrix(void);
glScaled()
o The glScaled function multiplies the current matrix by a general
scaling matrix.
o Syntax: glScaled(GLfloatx,GLfloaty,GLfloat z);
glBegin()
o The glBegin function delimits the beginning of vertices of a
primitive or a group of like primitives
o Syntax: glBegin(GLenum mode);
glVertex2f()
o Specifies a vertex on the screen
o Syntax: glVertex2f(GLfloatx,GLfloat y);
.glEnd()
o The glend function delimits the end of vertices of a primitive or a
group of like primitives
o Syntax: glEnd(void);
glPopMatrix()
o Pop the current matrix from the stack.
o Syntax: glPopMatrix(void);
glTranslated()
o The glTranslated function multiplies the current matrix by a
translation matrix.
o Syntax: glTranslated(GLfloatx,GLfloaty,GLfloat z);
5.TESTING
I modeled the scene using wings 3d; I used a flat rectangular surface. The models for the
scene and the plane were loaded as .obj files. To move the plane I used openGL
transformations namely glTranslatef(), the use of these transformations allowed
movement of the aircraft through the scene with respect to the x, y, and z axis there by
simulating plane.
To change the point of view of the camera when looking at the scene I used the
gluLookAt() function, this in a sense allowed for the positioning of the scene camera at
different points.
One camera was positioned directly above the scene and this was the global camera
which showed the entire scene and was static. Another point of view was also above the
scene, this camera was not static but moved with the plane. I also incorporated a first
person point of view that simulates the view from the cockpit of the plane. The last point
of view I implemented is of various views of the plane as it flies. I also added some
functionality that allows users to control the movement of the plane and the various points
view.
2. Click on key ‘a’ Plane move forward Should Plane move forward Is P
be displayed. displayed. a
s
s
displayed. Is displayed. s
6.SNAPSHOTS: