0% found this document useful (0 votes)
60 views54 pages

Complete Report

The document discusses the basics of OpenGL and GLUT for computer graphics, explaining that OpenGL is a software interface for graphics hardware that allows specification of 3D objects and operations through commands, while GLUT is a library that handles window creation and event handling to simplify OpenGL programming. It provides an overview of how OpenGL works based on state variables and transformation matrices to map 3D objects to 2D screens.

Uploaded by

Dhushanth S
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)
60 views54 pages

Complete Report

The document discusses the basics of OpenGL and GLUT for computer graphics, explaining that OpenGL is a software interface for graphics hardware that allows specification of 3D objects and operations through commands, while GLUT is a library that handles window creation and event handling to simplify OpenGL programming. It provides an overview of how OpenGL works based on state variables and transformation matrices to map 3D objects to 2D screens.

Uploaded by

Dhushanth S
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/ 54

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

“JNANA SANGAMA”, BELGAUM - 590018

2021-22

COMPUTER GRAPHICS AND VISUALIZATION [18CS62]


Mini Project Report
On

AEROPLANE LAUNCH

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT IN 6TH SEMESTER


COMPUTER GRAPHICS AND VISUALIZATION (18CS62) OF BACHELOR OF ENGINEERING
IN

By
ABDULLAH 4VM19CS003
AIMAN SHIFA 4VM19CS005

UNDER THE GUIDANCE OF

Ms. Kavya R Mr. Madhusudhana GK


Assistant Professor Assistant Professor
Dept. of CSE, VVIET Dept. of CSE, VVIET

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

VIDYA VIKAS INSTITUTE OF ENGINEERING & TECHNOLOGY


#127-128, Mysore - Bannur Road, Alanahally, Mysuru, Karnataka -570028
Vidya Vikas Educational Trust ®
VIDYA VIKAS INSTITUTE OF ENGINEERING &
TECHNOLOGY
#127-128, Mysore - Bannur Road, Alanahally, Mysuru, Karnataka 570028

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

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.

[Ms. Kavya R] [Mr. MADHUSUDHANA GK]


Assistant Professor Assistant Professor

Dept. of CSE Dept. of CSE

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.

This project “AEROPLANE LAUNCH” is done using OpenGL libraries


and functions that generate the environment for run time of application.
We can generate simple geometric figures like triangle, square, circle and
various polygons by giving the number of sides from users input. Polygons like
triangle, square, pentagon and so on can be generated with ease. We also include
tilting and moving properties for the various polygons.
The code implemented makes use of various OpenGL functions for
translation, rotation and keyboard callback function, built-in functions for solids
and many more. The concepts of computer graphics stand a backbone to achieve
the aforementioned idea. Primitive drawing, event driven interactions and basic
animation have been the important concepts brought out by this application.

ii
TABLE OF CONTENTS

Acknowledgement i

Abstract ii

Table of contents iii

List of Figures 5

1. Introduction 1-2

1.1 Aim 2

1.2 Problem statement 2

1.3 Scope and its applications 2

2 Literature Survey 3-3

2.1 Related work 3

3. System Analysis 4-11

3.1 System development 4

3.2 Language platform 5

3.3 Existing Systems 6

3.4 Proposed System 6

3.5 Flowchart and process description 7

3.6 Requirement specifications 9

3.7 Hardware requirements 9

3.8 Software requirements 9

3.9 Functional requirements 10

iii
4. Design and Analysis 12-14

4.1 System Design 11

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.

How does OpenGL work?


OpenGL bases on the state variables. There are many values, for example the color, that remain after
being specified. That means, you can specify a color once and draw several polygons, lines or what
ever with this color then. There are no classes like in DirectX. However, it is logically structured.
Before we come to the commands themselves, here is another thing:
To be hardware independent, OpenGL provides its own data types. They all begin with "GL". For
example, GLfloat, GLint and so on. There are also many symbolic constants, they all begin with
"GL_", like GL_POINTS, GL_POLYGON. Finally the commands have the prefix "gl" like

Dept. of CSE, 2021-22 Page 1


AEROPLANE LAUNCH
glVertex3f(). There is a utility library called GLU, here the prefixes are "GLU_" and "glu". GLUT
commands begin with "glut", it is the same for every library. You want to know which libraries
coexist with the ones called before? There are libraries for every system, Windows has the wgl*-
Functions, Unix systems glx* and so on.
A very important thing is to know, that there are two important matrices, which affect the
transformation from the 3d-world to the 2d-screen: The projection matrix and the modelview matrix.
The projection matrix contains information, how a vertex – let's say a "point" in space – shall be
mapped to the screen. This contains, whether the projection shall be isometric or from a perspective,
how wide the field of view is and so on. Into the other matrix you put information, how the objects are
moved, where the viewer is and so on.
Don't like matrices? Don't be afraid, you probably won't really see them, at least at the beginning.
There are commands that do all the maths for you.
Some basic commands are explained later in this tutorial.

How can I use GLUT?


GLUT provides some routines for the initialization and creating the window (or fullscreen
mode, if you want to). Those functions are called first in a GLUT application:
In your first line you always write glutInit(&argc, argv). After this, you must tell GLUT, which
display mode you want – single or double buffering, color index mode or RGB and so on. This is done
by calling glutInitDisplayMode(). The symbolic constants are connected by a logical OR, so you
could use glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE). In later tutorials we will use some
more constants here.
After the initialization you call glCreateWindow() with the window name as parameter.Then
you can (and should) pass some methods for certain events. The most important ones are "reshape"
and "display". In reshape you need to (re)define the field of view and specify a new area in the
window, where OpenGL is allowed to draw to.
Display should clear the so called color buffer – let's say this is the sheet of paper – and draw
our objects.
You pass the methods by glut*Func(), for example glutDisplayFunc(). At the end of the main function
you call glutMainLoop(). This function doesn't return, but calls the several functions passed by
glut*Func.

Dept. of CSE, 2021-22 Page 2


AEROPLANE LAUNCH

OPENGL RENDERING PIPELINE


Most implementations of OpenGL have a similar order of operations, a series of processing
stages called the OpenGL rendering pipeline. This ordering, as shown in Figure 1-2, is not a strict
rule of how OpenGL is implemented but provides a reliable guide for predicting what OpenGL will
do.
If you are new to three-dimensional graphics, the upcoming description may seem like
drinking water out of a fire hose. You can skim this now, but come back to Figure 1-2 as you go
through each chapter in this book.
The following diagram shows the Henry Ford assembly line approach, which OpenGL takes
to processing data. Geometric data (vertices, lines, and polygons) follow the path through the row of
boxes that includes evaluators and per-vertex operations, while pixel data (pixels, images, and
bitmaps) are treated differently for part of the process. Both types of data undergo the same final
steps (rasterization and per-fragment operations) before the final pixel data is written into the
framebuffer.

Figure 1.1: Order Of Operations

Dept. of CSE, 2020-21 Page 3


AEROPLANE LAUNCH

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

1.2 Problem statement


The project is designed for supporting different transformation functions and event driven functions of
OpenGL on primary objects. The project implements by providing powerful but primitive set of
commands.

1.3 Scope and Applications

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.

Dept. of CSE, 2020-21 Page 4


AEROPLANE LAUNCH

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

Purpose of the requirements document


The software requirement specification is the official statement of what is required for development of particular
project. It includes both user requirements and system requirements. This requirement document is utilized by
variety of users starting from project manager who gives project to the engineer responsible for development of
project. It should give details of how to maintain, test, verify and what all the actions to be carried out through life
cycle of project.

Dept. of CSE, 2020-21 Page 5


AEROPLANE LAUNCH

CHAPTER 3

SYSTEM ANALYSIS

Analysis involves requirement determination and specification. It is basically establishingthe


requirements for all system elements and then mapping these requirements to softwareforms. It should
address issues such as: -

• Profile of people who are operating on the system.

• Software on which the application is going to function.

• Existing system problems.

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.

3.1 System Development


The incremental build model is a method of software development where the product is designed,
implemented and tested incrementally (a little more is added each time) until the product is finished.
It involves both development and maintenance. The product is defined as finished when it satisfies all
of its requirements. This model combines the elements of the waterfall model with the iterative
philosophy of prototyping.

Dept. of CSE, 2020-21 Page 6


AEROPLANE LAUNCH

3.2 Language platform


C++:

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!

Dept. of CSE, 2020-21 Page 7


AEROPLANE LAUNCH

3.3 The existing system is the manual system

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

3.4 Proposed System


The project is designed for supporting different transformation functions and event driven function of

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.

Dept. of CSE, 2020-21 Page 8


AEROPLANE LAUNCH

3.5.1 Process description

The main objectives of our project are:

• 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 .

Dept. of CSE, 2021-22 Page 9


AEROPLANE LAUNCH

3.5 Requirement Specification

User Requirement:

• Easy to understand and should be simple.


• The built-in functions should be utilized to maximum extent.
• OpenGL library facilities should be used.

3.6 Hardware Requirements

• Intel or AMD(Advanced Micro Devices)


• RAM- 512MB(minimum)
• Hard Disk-1MB(minimum)
• Mouse
• Keyboard
• Monitor

3.7 Software Requirements

Operating System : Ubuntu OS

Software Used : Codeblocks 17.12

Library Used : OPENGL Library

Dept. of CSE, 2021-22 Page 10


AEROPLANE LAUNCH

3.8 Functional and non-functional requirements

➢ User Defined Functional requirements

 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

In systems engineering and requirements engineering, a non-functional requirement (NFR) is a


requirement that specifies criteria that can be used to judge the operation of asystem, rather than
specific behaviors. They are contrasted with functional requirementsthat define specific behavior or
functions. The plan for implementing functional requirements is detailed in the system design. The
plan for implementing non-functionalrequirements is detailed in the system architecture, because they
Dept. of CSE, 2021-22 Page 11
AEROPLANE LAUNCH
are usually architecturally significant requirements. Broadly, functional requirements define what a
system is supposed to do and non-functional requirements define how a system is supposed to be.
Non-functional requirements are often called “quality attributes” of a system. Other terms for Non-
functional requirements are “qualities”, “quality goals” "quality of service requirements",
"constraints" and "non-behavioral requirements”.

Dept. of CSE, 2021-22 Page 12


AEROPLANE LAUNCH

CHAPTER 4

DESIGN AND ANALYSIS

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 system architecture

• The interface representation

• The component level detail


Dept. of CSE, 2021-22 Page 13
AEROPLANE LAUNCH

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.

Dept. of CSE, 2021-22 Page 14


AEROPLANE LAUNCH

4.2 MethodologyIncremental Model


Incremental Model is a process of software development where requirements divided into multiple
standalone modules of the software development cycle. In this model, each module goes through the
requirements, design, implementation and testing phases. Every subsequent release of the module
adds function to the previous release. The process continues until the complete system achieved.

The various phases of incremental model are as follows:

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.

4. Implementation: Implementation phase enables the coding phase of the development


system. It involves the final coding that design in the designing and development phase and tests the
functionality in the testing phase. After completion of this phase, the number of the product working
is enhanced and upgraded up to the final system product

Dept. of CSE, 2021-22 Page 15


AEROPLANE LAUNCH

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

Dept. of CSE, 2021-22 Page 16


AEROPLANE LAUNCH

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

glPushMatrix, glPopMatrix Function


The glPushMatrix and glPopMatrix functions push and pop the current matrix stack. SYNTAX: void
glPushMatrix(); void glPopMatrix(void);

glBegin, glEnd
Function The glBegin and glEnd functions delimit the vertices of a primitive or a group of like primitives.

SYNTAX: void glBegin, glEnd(GLenum mode);

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.

Dept. of CSE, 2021-22 Page 17


AEROPLANE LAUNCH

glLoadIdentity Function
The glLoadIdentity function replaces the current matrix with the identity matrix.
SYNTAX: void glLoadIdentity(void);

FUNCTIONS USED TO SET THE VIEWING VOLUME

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.

CALL BACK FUNCTIONS


glutDisplayFunc Function
glutDisplayFunc sets the display callback for the current window.
SYNTAX: void glutDisplayFunc(void (*func)(void));

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);

Dept. of CSE, 2021-22 Page 18


AEROPLANE LAUNCH

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 s[20]="PRESS S TO START";


char s1[100]="Maximize window for better view----->>";
char s2[100]="VIDYA VIKAS INSTITUTE OF ENGINEERING AND TECHNOLOGY";
char s3[150]="DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING";
char s4[20]="A Mini Project On:-";
char s5[50]="AEROPLANE CRASH";
char s6[200]="BY- AIMAN SHIFA AND ABDULLAH";
char s7[200]="Under the Guidence of :ASS.PROF KAVYA ";
char s8[50]="Lecturer,Dept. of CSE";
char s9[100]="PRESS Q TO EXIT";

char texta[]={"BOOOOOM!!"};
int j;

int flag=0;

Dept. of CSE, 2021-22 Page 19


AEROPLANE LAUNCH

void update(int value)


{
a+=0.0; //Plane position takeoff on x axis
b-=0.0; //Road Strip backward movement
c+=0; //take off at certain angle on y axis

if(b<=-78.0)// moving of run way


b=0.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();

Dept. of CSE, 2021-22 Page 20


AEROPLANE LAUNCH
glBegin(GL_POLYGON);
glColor3f(1.0,0.3,0.0);
glVertex2i(212,310);
glVertex2i(212,333);
glVertex2i(209,333);
glVertex2i(209,310);
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);

Dept. of CSE, 2021-22 Page 21


AEROPLANE LAUNCH
glColor3f(1.0,0.3,0.0);
glVertex2i(12,310);
glVertex2i(12,333);
glVertex2i(9,333);
glVertex2i(9,310);
glEnd();

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();

Dept. of CSE, 2021-22 Page 22


AEROPLANE LAUNCH

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();
}

Dept. of CSE, 2021-22 Page 23


AEROPLANE LAUNCH
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
if(flag==0)
{

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++)

Dept. of CSE, 2021-22 Page 24


AEROPLANE LAUNCH
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_24,s9[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);

Dept. of CSE, 2021-22 Page 25


AEROPLANE LAUNCH
glVertex2f(135.0,30.0);
glEnd();
glPopMatrix();

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);

Dept. of CSE, 2021-22 Page 26


AEROPLANE LAUNCH
glVertex2f(145.0,30.0);
glVertex2f(135.0,30.0);
glEnd();
glPopMatrix();

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);

Dept. of CSE, 2021-22 Page 27


AEROPLANE LAUNCH

glEnd();

glPopMatrix();

if(c>390) //timer to jump to next display


{
display2();
d+=5;//plane takeoff on x in 2nd display
}

if(a>500.0)//window position during take off


{
a=0.0;
b=0.0;
}

if(c>800)//timer to jump to 3rd display


{
display3();
e+=5;//plane takeoff on x in 3rd display

if(e>250)//timer to call blast function


{
blast();
e=250;
}
}

glFlush();
glutSwapBuffers();
}

Dept. of CSE, 2021-22 Page 28


AEROPLANE LAUNCH

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);

Dept. of CSE, 2021-22 Page 29


AEROPLANE LAUNCH
glEnd();

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);

Dept. of CSE, 2021-22 Page 30


AEROPLANE LAUNCH
glVertex2f(350.0,180);
glEnd();

build_outline();
}

void build_outline()//building out lines


{
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(350.0,80.0);
glVertex2f(350.0,480.0);
glVertex2f(400.0,400.0);
glVertex2f(400.0,0.0);
glEnd();

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);

Dept. of CSE, 2021-22 Page 31


AEROPLANE LAUNCH
glBegin(GL_POLYGON);
glVertex2f(25.0,8.0);
glVertex2f(25.0,38.0);
glVertex2f(30.0,30.0);
glVertex2f(30.0,0.0);
glEnd();

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);

Dept. of CSE, 2021-22 Page 32


AEROPLANE LAUNCH
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(25.0,18);
glVertex2f(30.0,10);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(25.0,28);
glVertex2f(30.0,20);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(35.0,10);
glVertex2f(30.0,10);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(35.0,20);
glVertex2f(30.0,20);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(35.0,20);
glVertex2f(30.0,20);

glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(25.0,18);
glEnd();

build_outline2();
}

void build_outline2()//building out lines

Dept. of CSE, 2021-22 Page 33


AEROPLANE LAUNCH
{
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(25.0,8.0);
glVertex2f(25.0,38.0);
glVertex2f(30.0,30.0);
glVertex2f(30.0,0.0);
glEnd();

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();
}

void blast(void)//blast polygon construction


{
b=0;
glPushMatrix();
glTranslated(-10.0,-60.0,0.0);
glColor3f(1.0,0.0,0.0);
b=0;
glBegin(GL_POLYGON);
glVertex2f(404.4,320.0);

Dept. of CSE, 2021-22 Page 34


AEROPLANE LAUNCH
glVertex2f(384.0,285.0);
glVertex2f(368.0,344.5);
glVertex2f(344.0,355.0);
glVertex2f(347.2,414.5);
glVertex2f(332.8,442.5);
glVertex2f(347.2,477.5);
glVertex2f(352.0,530.0);
glVertex2f(379.2,519.5);
glVertex2f(396.8,565.0);
glVertex2f(416.0,530.0);
glVertex2f(440.0,547.5);
glVertex2f(452.8,512.5);
glVertex2f(472.0,512.5);
glVertex2f(475.2,470.5);
glVertex2f(488.0,442.5);
glVertex2f(488.0,404.0);
glVertex2f(470.0,372.5);
glVertex2f(475.2,337.5);
glVertex2f(464.0,306.0);
glVertex2f(444.8,320.0);
glVertex2f(425.6,285.0);
glVertex2f(404.8,320.0);
glEnd();
glPopMatrix();

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()
{

Dept. of CSE, 2021-22 Page 35


AEROPLANE LAUNCH

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);

Dept. of CSE, 2021-22 Page 36


AEROPLANE LAUNCH
glVertex2f(200.0,40.0);
glVertex2f(208.0,60.0);
glVertex2f(258.0,60.0);
glVertex2f(250.0,40.0);
glEnd();
glPopMatrix();

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);

Dept. of CSE, 2021-22 Page 37


AEROPLANE LAUNCH
glVertex2f(550.0,40.0);
glEnd();
glPopMatrix();

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();

Dept. of CSE, 2021-22 Page 38


AEROPLANE LAUNCH
trees();

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();

Dept. of CSE, 2021-22 Page 39


AEROPLANE LAUNCH

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();

Dept. of CSE, 2021-22 Page 40


AEROPLANE LAUNCH
glPushMatrix();
glTranslated(d,300.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(70.0,40.0);
glVertex2f(100.0,40.0);
glVertex2f(80.0,15.0);
glVertex2f(50.0,15.0);

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);

Dept. of CSE, 2021-22 Page 41


AEROPLANE LAUNCH
glVertex2f(0.0,30.0);
glVertex2f(0.0,55.0);
glVertex2f(135.0,55.0);
glVertex2f(135.0,30.0);
glEnd();
glPopMatrix();

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);

Dept. of CSE, 2021-22 Page 42


AEROPLANE LAUNCH
glVertex2f(160.0,40.0);
glVertex2f(160.0,37.0);
glVertex2f(145.0,30.0);
glVertex2f(135.0,30.0);
glEnd();
glPopMatrix();

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);

Dept. of CSE, 2021-22 Page 43


AEROPLANE LAUNCH
glVertex2f(100.0,40.0);
glVertex2f(80.0,15.0);
glVertex2f(50.0,15.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);

void keys(unsigned char key,int x,int y)


{

if(key=='s')
flag=1;

if(key=='q') exit(0);

if(key=='m')
{
a+=5.0; //Plane position takeoff on x axis

Dept. of CSE, 2021-22 Page 44


AEROPLANE LAUNCH
b-=5.0; //Road Strip backward movement
c+=5; //take off at certain angle on y axis

if(b<=-78.0) // moving of run way


b=0.0;;//take off at certain angle on y axis
}

display();

int main(int argc, char* argv[])


{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(800.0,800.0);
glutInitWindowPosition(0,0);
glutCreateWindow("aero");
glutDisplayFunc(display);
myinit();
glutKeyboardFunc(keys);
glutTimerFunc(200,update,0);
glutMainLoop();
}

Dept. of CSE, 2021-22 Page 45


AEROPLANE LAUNCH
Snap shots:

Dept. of CSE, 2021-22 Page 46


AEROPLANE LAUNCH

Dept. of CSE, 2021-22 Page 47


AEROPLANE LAUNCH

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

Dept. of CSE, 2021-22 Page 48

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy