Complete Report
Complete Report
2021-22
AEROPLANE LAUNCH
By
ABDULLAH 4VM19CS003
AIMAN SHIFA 4VM19CS005
CERTIFICATE
Certified that the DBMS Mini Project Work entitled “AEROPLANE CRASH” carried outby
AIMAN SHIFA[4VM19CS005]and ABDULLAH[4VM18CS003], Bonafede
students of VVIET in partial fulfillment for the award of degree Bachelor of Engineering in
COMPUTER SCIENCE and ENGINEERING as prescribed by VISVESVARAYA
TECHNOLOGICAL UNIVERSITY, BELGAUM during the academic year 2021-22. It is
certified that all corrections/suggestions indicated for internal assessment have been
incorporated in the report deposited in the departmental library. The project report has
been approved as it satisfies the academic requirements in respect of mini project work
prescribed for the said degree.
EXTERNAL VIVA
Name of the examiners Signature with date
1.
2.
ACKNOWLEDGEMENT
We would like to thank and express our heartfelt gratitude to God almighty for the
abundant blessings without which this project would not have been successful.
We would like to express our sincere gratitude to Sri. Vasu, Chairman of VVIET,
Mr. Kaveesh Gowda V, Secretary of VVIET and all management members of VVIET, for their
constant support.
We acknowledge and express our sincere thanks to our beloved Principal
Dr. Ravishankar M, VVIET, Mysuru who is the source of inspiration.
We would like to express our deepest sense of gratitude towards Dr. Madhu B K,
Head of the Department, CSE, VVIET, Mysuru for his valuable suggestions, support and
encouragement.
We would like to extend our heartfelt gratitude to Ms. Kavya R, Assistant Professor,
and Dept. of CSE, and Mr. MADHUSUDHANA GK, Assistant Professor, and Dept. of CSE
for the valuable guidance and advice. We would also like to thank him for his guidance and
useful suggestions, which helped us in completing the project work on time.
We would also thank all other teaching and non-teaching staffs of the computer
Science Department who has directly or indirectly helped us in completion of this project.
Our thanks and appreciation also go to our family and friends who have willingly
helped us out with their abilities.
Regards,
AIMAN SHIFA
ABDULLAH
ABSTRACT
Computer Graphics has grown into a very important topic in the branch of
Computer Science. This is due to an effective and rapid communication formed
between man and the machine. Human eye can absorb the information in a
displayed diagram or perspective diagram much faster than it can scan a page or a
table of contents.
ii
TABLE OF CONTENTS
Acknowledgement i
Abstract ii
List of Figures 5
1. Introduction 1-2
1.1 Aim 2
iii
4. Design and Analysis 12-14
4.2 Methodology 13
5. Implementation 14-21
6. Snapshots 22-24
References 27
iv
AEROPLANE LAUNCH
CHAPTER 1
INTRODUCTION
What is OpenGL?
OpenGL is a software interface to graphics hardware. This interface consists of about150 distinct
commands that you use to specify the objects and operations needed to produce interactive three-
dimensional applications.
OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many
different hardware platforms. To achieve these qualities, no commands for performing windowing
tasks or obtaining user input are included in OpenGL; instead, you must work through whatever
windowing system controls the particular hardware you're using. Similarly, OpenGL doesn't provide
high-level commands for describing models of three-dimensional objects. Such commands might
allow you to specify relatively complicated shapes such as automobiles, parts of the body, airplanes,
or molecules. With OpenGL, you must build up your desired model from a small set of geometric
primitives - points, lines, and polygons.
What is 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.
1.1 AIM
This project “ AEROPLANE CRASH ” is created to demonstrate OpenGL’s concepts. It encompasses
some of the skills learnt in our OpenGL classes such as pushmatrix(),translate() ,popmatrix(),timer function
The scope is to use the basic primitives defined in openGL library creating complex objects. We make use
of different concepts such as pushmatrix(),translate(),popmatrix(),timer function.
CHAPTER 2
LITERATURE SURVEY
The basic functions like glcolor3f(…); gltotatef(..),gltranslate(..) etc that are most commonly used in
the code are taken from the prescribed VTU Text book “INTERACTIVE COMPUTER GRAPHICS” 5th edition
by Edward Angel.[1].
The lab programs in the syllabus also serve as a basic template for creating a project. The usage of colors and
specifications are taken from the various programs that were taught in the lab.[1]. The VTU prescribed text book
serves as a huge database of functions and they are used in the project.
The C++ concepts which are used are being taken from “object oriented programming” by Sourav Sahay.[2]. Some
concepts like constructing bowl and fountain are taken from the search results in codecolony.com
CHAPTER 3
SYSTEM ANALYSIS
Analysis encompasses requirements gathering at the system level with small amount of top-level
design. The data obtained from the requirement determination phase are documented in Software
Requirement Specification (SRS) document. During analysis, a great deal of relatively unstructured
data is collected through procedural manuals and through websites. The traditional approach is to
organize and convert the data through system flowcharts, which support future developments of the
system and simplify communication with users. But the system flowcharts represent the physical
system ratherthan the logical system. Hence, it makes it difficult to distinguish between what happens
and how it happens in the system. Because of this drawback it is necessary to have something, which
is analogous to the architect's blueprint as a starting point for.
C++ is a cross-platform language that can be used to create high-performance applications.C++ was
developed by Bjarne Stroustrup, as an extension to the C language.C++ gives programmers a high
level of control over system resources and memory.The language was updated 3 major times in 2011,
2014, and 2017 to C++11, C++14, and C++17.
Microsoft Visual C++ is a integrated development environment (IDE) used to create Windows
applications in the C, C++, and C++/CLI programming languages. It was originally a standalone
product, but is now included as part of Microsoft Visual Studio. It offers developers a single
application in which they can write, edit, test, and debug their code. The programming environment
includes access to a lot of shared code libraries, which let developers use already-developed code for
specific procedures instead of having to write their own from scratch. That shared code takes the form
of dynamic link libraries (DLLs), a term most Windows users have come across at some point or
other.
Codeblocks 17.12:
Code::Blocks is a free C/C++ and Fortran IDE built to meet the most demanding needs of its users. It
is designed to be very extensible and fully configurable. Built around a plugin framework,
Code::Blocks can be extended with plugins. Any kind of functionality can be added by
installing/coding a plugin. For instance, event compiling and debugging functionality is provided by
plugins!
where the user has to draw the number of input points on asheet of paper and start playing with arithmetic
figures. In times where the user needs immediate or quick response the,Requires manual properties to work.
Availability of the property is not sure.Takes an internet to work
OpenGL on primary objects. The scope is to use the basic primitives defined in openGL library
creating complex objects. We make use of different concepts such as pushmatrix(),translate()
,popmatrix(),timer function.
• The project is developed using the software CodeBlocks 17.12and the OpenGL library.
• It attempts to creates a aeroplane game on the given order of the code snippets.
• The scope is to use basic primitives defined in openGl library .
User Requirement:
myinit(): This function initializes light source for ambient, diffuse and specular types.
display(): This function creates and translates all the objects in a specified location in a particular
order and also rotates the objects in different axes.
➢ glClear(GL_COLOR_BUFFER_BIT);
glFlush();
timerfunc(): This function starts a timer in the event loop that delays the event loop for delay
miiliseconds.
MainLoop(): This function whose execution will cause the program to begin an event processing
loop.
PushMatrix(): Save the present values of attributes and matrices placing ,or pushing on the top of the
stack.
PopMatrix(): We can recover them by removing them from stack;
Translated(); In translate func the variables are components of the displacement vector.
main():The execution of the program starts from this function. It initializes the graphics system and
includes many callback functions.
PostRedisplay(): It ensures that the display will be drawn only once each time the program goes
through the event loop
➢ Non-functional requirements
CHAPTER 4
4.1.System Design
System design is the process of defining the architecture, components, modules, interfaces, and data
for a system to satisfy the specified requirements. Here, the design functions and operations are
described in detail, including screen layouts, business rules, process diagrams and other
documentation. The output of this stage will describe the new system as a collection of modules or
subsystems. Having a design methodology enforces consistency in the work as it helps in achieving
the deadlines timely.
The design stage takes as its initial input the requirements identified in the approved requirements
document. For each requirement, a set of one or more design elements will be produced that describe
the desired software features in detail. They generally include functional hierarchy diagrams, screen
layout diagrams, tables of business rules, business process diagrams, pseudo code, and a complete
entity relationship diagram with a full structure of the database.
Systems design implies a systematic approach to the design of a system. It may take a bottom-up or
top-down approach, but either way the process is systematic wherein it takes into account all related
variables of the system that needs to be created — from the architecture, to the required hardware and
software, right down to the data and how it travels and transforms throughout its travel through the
system. Systems design then overlaps with systems analysis, systems engineering and systems
architecture.
Design begins with requirements model. The team works to transform this model into four level of
design detail and they are,
• The data structure
The data design transforms the information domain model created during analysis into thedata
structure that is required for the implementation. The data objects and relationships defined in the
entity relationship diagram and detailed data content depicted provide the basis for the data design
activity. Part of data design may occur in conjunction with the design of software architecture.
The importance of software design can be stated with a single word - Quality. Design provides the
representations of software that can be assessed for quality. Design is an iterative process through
which requirements are translated into a "blueprint" for constructing the software. The design
represented at a high level of abstraction - a level that can be directly traced to the specific system
objective and more detailed data, functional and behavioral requirements. There are three
characteristics that serve as a guide for the evaluation of a good design. Each of these characteristics
is actually a goalof the design process. They are:
• The design must implement all of the explicit requirements contained in theanalysis model and also
accommodate the desired implicit requirements.
• The design must be readable and understandable for coding, testing andsubsequently support the
software.
• The design should provide a complete picture for addressing the data, functionaland behavioral
domains from an implementation perspective.
The Software design includes different design materials. The designs are Architectural, Work flow,
Use case, Activity, Sequence, Database, Form Design. These designs are usedin software
development of a web-application and provides details of how the web- application should be created.
1. Requirement analysis: In the first phase of the incremental model, the product analysis
expertise identifies the requirements. And the system functional requirements areunderstood by the
requirement analysis team. To develop the software under the incremental model, this phase performs
a crucial role.
2. Design & Development: In this phase of the Incremental model of SDLC, the design of the
system functionality and the development method are finished with success. When software develops
new practicality, the incremental model uses style and development phase.
3. Testing: In the incremental model, the testing phase checks the performance of each existing
function as well as additional functionality. In the testing phase, the various methods are used to test
the behavior of each task.
CHAPTER 5
IMPLEMENTATION
Implementation is the carrying out, execution, or practice of a plan, a method, or any design for doing
something. It encompasses all the processes involved in getting new software or hardwareoperating
properly in its environment, including installation, configuration, running, testing, andmaking
necessary changes. The word deployment is sometimes used to mean the same thing.
This section will investigate the distinctive viewpoints concerned about the implementation ofthe
developed system.
HEADER FILES:
The <stdlib.h> Header File
# include <stdlib.h>
The ISO C standard introduced this header file as a place to declare certain standard library
functions. These include the Memory management functions (malloc, free, et. al.) communication
with the environment (abort, exit) and others. Not yet all the standard functions of this header file are
supported. If a declaration is present in the supplied header file, then uCR supports it and will
continue to support it. If a function is not there, it will be added in time.
The <stdio.h> Header File
# include <stdio.h>
Load the file SIMPLEIO.C for our first look at a file with standard I/O. Standard I/O refers to
the most usual places where data is either read from, the keyboard, or written to, the video monitor.
Since they are used so much, they are used as the default I/O devices and do not need to be named in
the Input/Output instructions. This will make more sense when we actually start to use them so lets
look at the file in front of you.
The first thing you will notice is the second line of the file, the #include "stdio.h" line. This is
very much like the #define we have already studied, except that instead of a simple substitution, an
entire file is read in at this point. The system will find the file named "stdio.h" and read its entire
contents in, replacing this statement. Obviously then, the file named "stdio.h" must contain valid C
source statements that can be compiled as part of a program. This particular file is composed of
several standard #defines to define some of the standard I/O operations. The file is called a header file
and you will find several different header files on the source disks that came with your C compiler.
Each of the header files has a specific purpose and any or all of them can be included in any program.
FUNCTIONS:
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_LOOP - 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 N lines are drawn.
Basic Functions
glBegin, glEnd
Function The glBegin and glEnd functions delimit the vertices of a primitive or a group of like primitives.
PARAMETERS:
• mode - The primitive or primitives that will be created from vertices presented between glBegin and the
subsequent glEnd. The following are accepted symbolic constants and their meanings: Transformation Functions
glTranslate Function
The glTranslated and glTranslatef functions multiply the current matrix by a translation matrix. SYNTAX: void
glTranslate( x, y, z);
PARAMETERS:
• x, y, z - The x, y, and z coordinates of a translation vector.
Functions used to display
glMatrixMode Function
The glMatrixMode function specifies which matrix is the current matrix.
SYNTAX: void glMatrixMode(GLenum mode);
PARAMETERS:
mode - The matrix stack that is the target for subsequent matrix operations. The mode parameter can assume
one of three values:
Value Meaning
GL_MODELVIEW Applies subsequent matrix operations to the modelview matrix stack.
glLoadIdentity Function
The glLoadIdentity function replaces the current matrix with the identity matrix.
SYNTAX: void glLoadIdentity(void);
glOrtho
This function defines orthographic viewing volume with all parameters measured from the centre of projection.
multiply the current matrix by a perspective matrix.
SYNTAX: void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble near, GLdouble far) AEROPLANE CRASH
PARAMETERES:
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.
glutReshapeFunc Function glutReshapeFunc sets the reshape callback for the current window.
SYNTAX: void glutReshapeFunc(void (*func)(int width, int height));
MAIN FUNCTION
glutInit Function glutInit is used to initialize the GLUT library.
SYNTAX: glutInit(int *argcp, char **argv);
PARAMETERS:
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 AEROPLANE
CRASH be updated because glutInit extracts any command line options understood by the GLUT library.
• glutInit(&argc,argv);
glutInitDisplayMode Function glutInitDisplayMode sets the initial display mode.
SYNTAX: void glutInitDisplayMode(unsigned int mode);
PARAMETERS:
mode - Display mode, normally the bitwise OR-ing of GLUT display mode bit masks. See values below:
GLUT_RGB: An alias for GLUT_RGBA. GLUT_DOUBLE:Bit mask to select a double buffered window. This
overrides GLUT_SINGLE. GLUT_DEPTH: Bit mask to select a window with a depth buffer. glutMainLoop
Function glutMainLoop enters the GLUT event processing loop. SYNTAX: void glutMainLoop(void);
SOURCE CODE:
#include<stdio.h>
#include<GL/glut.h>
GLfloat a=0,b=0,c=0,d=0,e=0;
void building();
void building2();
void outline();
void blast();
void road();
void display2();
void display3();
void build_outline();
void build_outline2();
void trees();
void mountain();
int i;
char texta[]={"BOOOOOM!!"};
int j;
int flag=0;
glutPostRedisplay();
glutTimerFunc(200,update,0);//delay
}
void trees()
{
glBegin(GL_POLYGON);
glColor3f(1.0,0.3,0.0);
glVertex2i(312,310);
glVertex2i(312,333);
glVertex2i(309,333);
glVertex2i(309,310);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0,1.0,0.0);
glVertex2i(290,330);
glVertex2i(330,330);
glVertex2i(310,380);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0,1.0,0.0);
glVertex2i(190,330);
glVertex2i(230,330);
glVertex2i(210,380);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,0.3,0.0);
glVertex2i(112,310);
glVertex2i(112,333);
glVertex2i(109,333);
glVertex2i(109,310);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0,1.0,0.0);
glVertex2i(90,330);
glVertex2i(130,330);
glVertex2i(110,380);
glEnd();
glBegin(GL_POLYGON);
glBegin(GL_POLYGON);
glColor3f(0.0,1.0,0.0);
glVertex2i(-10,330);
glVertex2i(30,330);
glVertex2i(10,380);
glEnd();
}
void mountain()
{
glBegin(GL_POLYGON);
glColor3f(0.8,0.8,0.8);
glVertex2i(-60,310);
glVertex2i(110,325);
glVertex2i(30,366);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.8,0.8,0.8);
glVertex2i(40,310);
glVertex2i(230,325);
glVertex2i(150,366);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.8,0.8,0.8);
glVertex2i(140,310);
glVertex2i(350,325);
glVertex2i(270,366);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.9,0.9,0.9);
glVertex2i(240,313);
glVertex2i(470,325);
glVertex2i(390,366);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.8,0.8,0.8);
glVertex2i(440,313);
glVertex2i(570,325);
glVertex2i(490,346);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.9,0.9,0.9);
glVertex2i(540,313);
glVertex2i(670,325);
glVertex2i(590,360);
glEnd();
}
glRasterPos3f(58,58,0);
for(i=0;s[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s[i]);
glRasterPos3f(45,450,0);
for(i=0;s1[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s1[i]);
glRasterPos3f(90,358,0);
for(i=0;s2[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s2[i]);
glRasterPos3f(70,338,0);
for(i=0;s3[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s3[i]);
glRasterPos3f(218,218,0);
for(i=0;s4[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s4[i]);
glRasterPos3f(350,218,0);
for(i=0;s5[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s5[i]);
glRasterPos3f(250,150,0);
for(i=0;s6[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s6[i]);
glColor3f(1.0,1.0,0.0);
glRasterPos3f(250,130,0);
for(i=0;s7[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s7[i]);
glRasterPos3f(250,100,0);
for(i=0;s8[i]!='\0';i++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s8[i]);
glRasterPos3f(58,28,0);
for(i=0;s9[i]!='\0';i++)
}
else
{
road();
mountain();
//green
glBegin(GL_POLYGON);
glColor3f(0.0,1.0,0.0);
glVertex2i(-10,300);
glVertex2i(645,310);
glVertex2i(940,100);
glVertex2i(-10,100);
glEnd();
trees();
//plane construction
glPushMatrix();
glTranslated(a,c,0.0);
glColor3f(1,1,1);
glBegin(GL_POLYGON);//rectangular body
glVertex2f(0.0,30.0);
glVertex2f(0.0,55.0);
glVertex2f(135.0,55.0);
glPushMatrix();
glTranslated(a,c,0.0);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);//upper triangle construction plane
glVertex2f(135.0,55.0);
glVertex2f(150.0,50.0);
glVertex2f(155.0,45.0);
glVertex2f(160.0,40.0);
glVertex2f(135.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(a,c,0.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);//outline of upper triangle plane
glVertex2f(135.0,55.0);
glVertex2f(150.0,50.0);
glVertex2f(155.0,45.0);
glVertex2f(160.0,40.0);
glVertex2f(135.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(a,c,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);//lower triangle
glVertex2f(135.0,40.0);
glVertex2f(160.0,40.0);
glVertex2f(160.0,37.0);
glPushMatrix();
glTranslated(a,c,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);//back wing
glVertex2f(0.0,55.0);
glVertex2f(0.0,80.0);
glVertex2f(10.0,80.0);
glVertex2f(40.0,55.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(a,c,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);//left side wing
glVertex2f(65.0,55.0);
glVertex2f(50.0,70.0);
glVertex2f(75.0,70.0);
glVertex2f(90.0,55.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(a,c,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);//rightside wing
glVertex2f(70.0,40.0);
glVertex2f(100.0,40.0);
glVertex2f(80.0,15.0);
glVertex2f(50.0,15.0);
glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void building()
{
glColor3f(0.60,0.40,0.70);
glBegin(GL_POLYGON);
glVertex2f(350.0,80.0);
glVertex2f(350.0,480.0);
glVertex2f(400.0,400.0);
glVertex2f(400.0,0.0);
glEnd();
glColor3f(0.75,0.75,0.75);
glBegin(GL_POLYGON);
glVertex2f(400.0,0.0);
glVertex2f(400.0,400.0);
glVertex2f(450.0,400.0);
glVertex2f(450.0,0.0);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(400.0,400.0);
glVertex2f(350.0,480.0);
glVertex2f(400.0,480.0);
glVertex2f(450.0,400.0);
glEnd();
glColor3f(0.60,0.40,0.70);
glBegin(GL_POLYGON);//upper triangle of building
glVertex2f(400.0,400.0);
glVertex2f(350.0,480.0);
glVertex2f(400.0,480.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);//seperation line of floors
glVertex2f(350.0,180);
glVertex2f(400.0,100);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(350.0,280);
glVertex2f(400.0,200);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(350.0,380);
glVertex2f(400.0,300);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(450.0,100);
glVertex2f(400.0,100);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(450.0,200);
glVertex2f(400.0,200);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(450.0,300);
glVertex2f(400.0,300);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
build_outline();
}
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(400.0,0.0);
glVertex2f(400.0,400.0);
glVertex2f(450.0,400.0);
glVertex2f(450.0,0.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(400.0,400.0);
glVertex2f(350.0,480.0);
glVertex2f(400.0,480.0);
glVertex2f(450.0,400.0);
glEnd();
}
void building2()
{
glColor3f(0.80,0.20,0.30);
glColor3f(0.75,0.75,0.75);
glBegin(GL_POLYGON);
glVertex2f(30.0,0.0);
glVertex2f(30.0,30.0);
glVertex2f(35.0,30.0);
glVertex2f(35.0,0.0);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(30.0,20.0);
glVertex2f(25.0,38.0);
glVertex2f(30.0,38.0);
glVertex2f(35.0,30.0);
glEnd();
glColor3f(0.60,0.40,0.70);
glBegin(GL_POLYGON);//upper triangle of building
glVertex2f(30.0,30.0);
glVertex2f(25.0,38.0);
glVertex2f(30.0,38.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);//seperation line of floors
glVertex2f(25.0,18);
glVertex2f(30.0,10);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(25.0,18);
glEnd();
build_outline2();
}
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(30.0,0.0);
glVertex2f(30.0,30.0);
glVertex2f(35.0,30.0);
glVertex2f(35.0,0.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(30.0,30.0);
glVertex2f(25.0,38.0);
glVertex2f(30.0,38.0);
glVertex2f(35.0,30.0);
glEnd();
}
glColor3f(0.0,0.0,0.0);
glRasterPos3f(380,350,0);
for(j=0;texta[j]!='\0';j++)
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24, texta[j]);
void road()
{
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);//black road
glVertex2f(0.0,0.0);
glVertex2f(0.0,100.0);
glVertex2f(500.0,100.0);
glVertex2f(500.0,0.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(b,0.0,0.0);
glColor3f(0.9,0.7,0.0);
glBegin(GL_POLYGON);//yellow strips on road
glVertex2f(0.0,40.0);
glVertex2f(8.0,60.0);
glVertex2f(58.0,60.0);
glVertex2f(50.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(b,0.0,0.0);
glColor3f(0.9,0.7,0.0);
glBegin(GL_POLYGON);
glVertex2f(100.0,40.0);
glVertex2f(108.0,60.0);
glVertex2f(158.0,60.0);
glVertex2f(150.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(b,0.0,0.0);
glColor3f(0.9,0.7,0.0);
glBegin(GL_POLYGON);
glPushMatrix();
glTranslated(b,0.0,0.0);
glColor3f(0.9,0.7,0.0);
glBegin(GL_POLYGON);
glVertex2f(300.0,40.0);
glVertex2f(308.0,60.0);
glVertex2f(358.0,60.0);
glVertex2f(350.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(b,0.0,0.0);
glColor3f(0.9,0.7,0.0);
glBegin(GL_POLYGON);
glVertex2f(400.0,40.0);
glVertex2f(408.0,60.0);
glVertex2f(458.0,60.0);
glVertex2f(450.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(b,0.0,0.0);
glColor3f(0.9,0.7,0.0);
glBegin(GL_POLYGON);
glVertex2f(500.0,40.0);
glVertex2f(508.0,60.0);
glVertex2f(558.0,60.0);
glPushMatrix();
glTranslated(b,0.0,0.0);
glColor3f(0.9,0.7,0.0);
glBegin(GL_POLYGON);
glVertex2f(600.0,40.0);
glVertex2f(608.0,60.0);
glVertex2f(658.0,60.0);
glVertex2f(650.0,40.0);
glEnd();
glPopMatrix();
void display2()
{
glClear(GL_COLOR_BUFFER_BIT);
mountain();
//green
glBegin(GL_POLYGON);
glColor3f(0.0,1.0,0.0);
glVertex2i(-10,300);
glVertex2i(645,310);
glVertex2i(940,0);
glVertex2i(-10,0);
glEnd();
glPushMatrix();
glTranslated(d,300.0,0.0);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(0.0,30.0);
glVertex2f(0.0,55.0);
glVertex2f(135.0,55.0);
glVertex2f(135.0,30.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(d,300.0,0.0);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(135.0,55.0);
glVertex2f(150.0,50.0);
glVertex2f(155.0,45.0);
glVertex2f(160.0,40.0);
glVertex2f(135.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(d,300.0,0.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(135.0,55.0);
glVertex2f(150.0,50.0);
glVertex2f(155.0,45.0);
glVertex2f(160.0,40.0);
glVertex2f(135.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(d,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(135.0,40.0);
glVertex2f(160.0,40.0);
glVertex2f(160.0,37.0);
glVertex2f(145.0,30.0);
glVertex2f(135.0,30.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(d,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(0.0,55.0);
glVertex2f(0.0,80.0);
glVertex2f(10.0,80.0);
glVertex2f(40.0,55.0);
//glVertex2f(165.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(d,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(65.0,55.0);
glVertex2f(50.0,70.0);
glVertex2f(75.0,70.0);
glVertex2f(90.0,55.0);
glEnd();
glPopMatrix();
glEnd();
glPopMatrix();
void display3()
{
glClear(GL_COLOR_BUFFER_BIT);
road();
mountain();
//brown
glBegin(GL_POLYGON);
glColor3f(0.9,0.3,0.0);
glVertex2i(-10,300);
glVertex2i(645,310);
glVertex2i(940,100);
glVertex2i(-10,100);
glEnd();
building();
glPushMatrix();
glTranslated(e,300.0,0.0);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glPushMatrix();
glTranslated(e,300.0,0.0);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(135.0,55.0);
glVertex2f(150.0,50.0);
glVertex2f(155.0,45.0);
glVertex2f(160.0,40.0);
glVertex2f(135.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(e,300.0,0.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(135.0,55.0);
glVertex2f(150.0,50.0);
glVertex2f(155.0,45.0);
glVertex2f(160.0,40.0);
glVertex2f(135.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(e,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(135.0,40.0);
glPushMatrix();
glTranslated(e,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(0.0,55.0);
glVertex2f(0.0,80.0);
glVertex2f(10.0,80.0);
glVertex2f(40.0,55.0);
//glVertex2f(165.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(e,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(65.0,55.0);
glVertex2f(50.0,70.0);
glVertex2f(75.0,70.0);
glVertex2f(90.0,55.0);
//glVertex2f(165.0,40.0);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(e,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(70.0,40.0);
glEnd();
glPopMatrix();
glutSwapBuffers();
}
void myinit()
{
glClearColor(0.0f,0.0f,1.0f,0.0f);
glColor3f(1.0,0.0,0.0);
glPointSize(1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,499.0,0.0,499.0);
if(key=='s')
flag=1;
if(key=='q') exit(0);
if(key=='m')
{
a+=5.0; //Plane position takeoff on x axis
display();
BIBLIOGRAPHY
1) OpenGL Programming Guide (Addison-Wesley Publishing Company)
2) The OpenGL Utility Toolkit (GLUT)Programming Interface -API Version 3 BY MARK J. KILGARD
3) Interactive computer graphics -A top down approach by using Open GL by EDWARD ANGEL