You are on page 1of 35

lOMoARcPSD|20328656

CG Miniproject Report

computer graphics laboratory (Visvesvaraya Technological University)

Studocu is not sponsored or endorsed by any college or university


Downloaded by Siddesh AV (siddesh1876@gmail.com)
lOMoARcPSD|20328656

VISVESVARAYA TECHNOLOGICAL
UNIVERSITY
JNANA SANGAMA, BELAGAVI – 590018
KARNATAKA

A Mini-Project
ReportOn
“TOLL BOOTH”
SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS
FOR THE MAD LABORATORY WITH MINI PROJECT (18CSMP68) COURSE
OF VI SEMESTER

Submitted by

PUNEETHKUMAR M
[1CG18CS068]

RAHUL G C [1CG18CS069]

Guide: HOD:
Mr. Mahesh N MTech Dr. Shantala C P PhD
Coordinator, Dept. of CSE Vice Principal & Head,
CIT, Gubbi. Dept. of CSE
CIT, Gubbi

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Channabasaveshwara Institute of Technology


(Affiliated to VTU, Belgaum & Approved by AICTE, New
Delhi) (NAAC Accredited &ISO 9001:2015 Certified
Institution)
NH 206 (B.H. Road), Gubbi, Tumkur – 572 216. Karnataka.
2021-22

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

Channabasaveshwara Institute of
Technology
(Affiliated to VTU, Belgaum & Approved by AICTE, New
Delhi) (NAAC Accredited &ISO 9001:2015 Certified
Institution)

DEPARTMENT OF COMPUTER SCIENCE &


ENGINEERING
2021-22

CERTIFICATE
This is to certify that the project entitled “TOLL BOOTH” has been successfully carried out by
PUNEETHKUMAR M[1CG18CS068] and RAHULGC[1CG18CS033] in partial fulfillment for the VI
semester during the academic year 2021 - 22. It is certified that all the corrections / suggestions indicated
for internal assessment have been incorporated in the report. The project report has been approved as it
satisfies theacademic requirements in respect of project work prescribed for the VI semester.

Guide HOD

Mr. Mahesh N M.Tech., Dr. Shantala C PPh. D,


Coordinator, Dept. of CSE Vice Principal &Head,
CIT, Gubbi. Dept. of CSE,
CIT, Gubbi.

Principal
Dr. Suresh D S Ph. D,
Principal
CIT, Gubbi.

External Viva

Name of Examiners Signature with date

1.

2.

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

Channabasaveshwara Institute of
Technology
(Affiliated to VTU, Belgaum & Approved by AICTE, New
Delhi) (NAAC Accredited &ISO 9001:2015 Certified
Institution)

DEPARTMENT OF COMPUTER SCIENCE &


ENGINEERING
2021-22

DECLARATION

We, PUNEETHKUMAR M and RAHUL G C, students of VI Semester ,B.E, in Computer Science


andEngineering ,C.I.T, Gubbi, hereby declare that the project work entitled “TOLL BOOTH”,
embodies the report of our project work carried out independently by us under the guidance of Mr.
MAHESH N,Assistant Professor, Department of CSE, CIT, Gubbi, as partial fulfillment of requirements for
the VI Semester during the academic year 2021-22. We further declare that the project has not been submitted
for the award of any other degree.

Place: GUBBI PUNEETHKUMAR M


Date: USN: 1CG18CS068

RAHUL G C
USN: 1CG18CS069

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

ACKNOWLEDGEMENT
A great deal of time and lot of effort has gone into completing this project report and
documenting it.The number of hours spent in getting through various books and other materials
related to this topic chosen by me have reaffirmed its power and utility in doing this project.

Several special people have contributed significantly to this effort. First, we are grateful to our
institution Channabasaveshwara Institute of Technology, Gubbi, which provides us an
opportunity infulfilling our most cherished desire of reaching the goal.

We acknowledge and express our sincere thanks to our beloved Principal & Director
Dr. Suresh D S for his many valuable suggestions and continuous encouragement and
support in the academic endeavors.

We express our sincere gratitude to Dr. Shantala C P, Vice Principal & Head, Department of
CSE, forproviding her constructive criticisms and suggestions.

We wish to express our deep sense of gratitude to Mr. Mahesh N, Department of Computer
Science and Engineering for all the guidance and who still remains a constant driving force and
motivated through innovative ideas with tireless support and advice during the course of project
to examine and helpful suggestions offered, which has contributed immeasurably to the quality
of the finalreport.

Project Associates:

PUNEETHKUMAR M[1CG18CS068]
RAHUL G C[1CG18CS069]

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

(i)

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

ABSTRACT

This is a Manually Controlled Toll Booth System used for demonstrating real time traffic movement virtually
in 2 D animation using OpenGl.

It has two virtual Gates and two virtual lanes thus facilitating two cars to move in different lanes
simultaneously.

The main aim of this Mini Project is to show the simulation of a Toll booth and illustrate the
concepts and usage of pre-built functions in OpenGL. We can manually control the opening and closing of the
Toll gates.
We can increase and decrease the speed of car.
We have used input device keyboard to interact with the program.

Using OpenGL, we thus created and implemented a Toll Booth virtually. This project
witnesses the fact using OpenGL, we can develop complete 2D objects and we can animate them.
This project is called TOLL BOOTH ,it is an implementation to demonstrate the skills I have learnt while
executing the graphics laboratory programs.

While working out with the project, I came out with various aspects and interesting facts about OpenGL
functions & the relevant way of using those functions.

(ii)

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

CHAPTER 1

INTRODUCTION

As a software interface for graphics hardware, OpenGL's main purpose is to render two- and three-
dimensional objects into a frame buffer.
These objects are described as sequences of vertices or pixels.
OpenGL performs several processing steps on this data to convert it to pixels to form the final desired
image in the frame buffer.

1.1 OpenGL Fundamentals

This section explains some of the concepts inherent in OpenGL.


Primitives and Commands
OpenGL draws primitives—points, line segments, or polygons—subject to several selectable modes.
You can control modes independently of each other; that is, setting one mode doesn't affect whether other
modes are set .Primitives are specified, modes are set, and other OpenGL operations are described by
issuing commands in the form of function calls.[1]
Primitives are defined by a group of one or more vertices. A vertex defines a point, an endpoint of a line,
or a corner of a polygon where two edges meet. Data is associated with a vertex, and each vertex and its
associated data are processed independently, in order, and in the same way. The type of clipping depends
on which primitive the group of vertices represents.[2]
Commands are always processed in the order in which they are received, although there may be an
indeterminate delay before a command takes effect. This means that each primitive is drawn completely
before any subsequent command takes effect. It also means that state-querying commands return data that's
consistent with complete execution of all previously issued OpenGL commands.[2]

DEPT OF CSE, CIT 1

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

1.2 Basic OpenGL Operation

The figure shown below gives an abstract, high-level block diagram of how OpenGL processes data. In the
diagram, commands enter from the left and proceed through what can be thought of as a processing
pipeline. Some commands specify geometric objects to be drawn, and others control how the objects are
handled during the various processing stages. [3]
Figure 1: OpenGL Block Diagram.

As shown by the first block in the diagram, rather than having all commands proceeds immediately through
the pipeline, you can choose to accumulate some of them in a display list for processing later.
Rasterization produces a series of frame buffer addresses and associated values using a two-dimensional
description of a point, line segment, or polygon.[3]
Each fragment so produced is fed into the last stage,
Per-Fragment operations, which performs the final operations on the data before it's stored as pixels in the
frame buffer. These operations include conditional updates to the frame buffer based on incoming and
previously stored z-value s (for z-buffering) and blending of incoming pixel colors with stored colors,
as well as masking and other logical operations on pixel values.[3]
All elements of OpenGL state, including the contents of the texture memory and even of the frame buffer,
can be obtained by an OpenGL application.[3]

DEPT OF CSE, CIT 2

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

Chapter 2
REQUIREMENTS SPECIFICATION

2.1 HARDWARE REQUIREMENTS:


• 4 GB of RAM recommended.
• 10GB of hard disk space required; 40 MB additional hard disk space required for installation

2.2 SOFTWARE REQUIREMENTS:

Development Platform: Windows


Language: C ++
Environment: Dev C++
Library: OpenGL

DEPT OF CSE, CIT 3

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

Chapter 3
IMPLEMENTATION

This chapter documents a detailed description of the implementation of our project. We have
incorporated several inbuilt OpenGL functions in this project. The following code snippet enables the
easy rendering of solid sphere with different colors and makes them to rotate and translate.

3.1 Various functions used in this program.

• glutInit( ) : interaction between the windowing system and OPENGL is initiated


• glutInitDisplayMode( ) : used when double buffering is required and depth information is required

• glutCreateWindow( ) : this opens the OPENGL window and displays the title at top of the window

• glutInitWindowSize( ) : specifies the size of the window

• glutInitWindowPosition( ) : specifies the position of the window in screen co-ordinates

• glutKeyboardFunc( ) : handles normal ASCII symbols

• glutSpecialFunc( ) : handles special keyboard keys

• glutReshapeFunc( ) : sets up the callback function for reshaping the window

• glutIdleFunc( ) : this handles the processing of the background

• glutDisplayFunc( ) : this handles redrawing of the window

• glutMainLoop ( ): this starts the main loop, it never returns

• glViewport ( ): used to set up the viewport

• glVertex3fv ( ): used to set up the points or vertices in three dimensions

• glColor3fv ( ): used to render color to faces

DEPT OF CSE, CIT 4

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

• glutPostRedisplay() : used to trigger an automatic redrawal of the object

• glMatrixMode() : used to set up the required mode of the matrix

• glLoadIdentity () : used to load or initialize to the identity matrix

• glTranslatef () : used to translate or move the rotation centre from one point to another in three

dimensions

• glRotatef() : used to rotate an object through a specified rotation angle

• glFlush( ) : used to flush the pipeline

3.2 Interaction with Program

• We can have an interaction with this project using popular input device like mouse and key board
are used to interact with this program.

• Some keys of key board and mouse have specific function, we mentioned them below,

• Num key (1) is used to go form Welcome page to Main page.

• Num key (2) is used to go from Main page to Executing page

• For car BMW

Key L :- Open barrier

Key z :- Speed Up

Key x :- Speed Down

• For Car NANO

Key r: - Open barrier

Key n: - Speed Up

Key m: - Speed Down

DEPT OF CSE, CIT 5

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

• Help - PRESS 'H'

• Escape - PRESS 'ENTER'

• With these above-mentioned keys, we can interact with the program.

DEPT OF CSE, CIT 6

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

Chapter 4

SOURCE CODE

#include<windows.h>
#include<GL/glut.h>
#include<stdio.h>
#include<math.h>
//display variables
GLfloat w = 500, h = 500, zy1 = 65, zy2 = 430;
// car nano variables
GLfloat ay = 0, by1 = 480, by2 = 480, by3 = 460, by4 = 460, by5 = 460, by6 = 460, by7 = 420, by8 = 420, by9 =
420, by10 = 420, by11 = 400, by12 = 400, ax = 0, bx = 0;
GLfloat by13 = 403, by14 = 403, by15 = 416, by16 = 416, by17 = 403, by18 = 403, by19 = 416, by20 = 416, by21
= 463, by22 = 463, by23 = 476, by24 = 476, by25 = 463, by26 = 463, by27 = 476, by28 = 476;
//car bmw variavles
GLfloat ay1 = 20, ay2 = 20, ay3 = 40, ay4 = 40, ay5 = 40, ay6 = 40, ay7 = 90, ay8 = 90, ay9 = 90, ay10 = 90, ay11
= 130, ay12 = 130;
GLfloat ay13 = 25, ay14 = 25, ay15 = 38, ay16 = 38, ay17 = 25, ay18 = 25, ay19 = 38, ay20 = 38, ay21 = 95, ay22
= 95, ay23 = 108, ay24 = 108, ay25 = 95, ay26 = 95, ay27 = 108, ay28 = 108;
//flag variables
GLint flagd = 0, flaga = 0, flagc = 0, color1 = 0, flagl = 0, flag2 = 0, flagr = 0, flag3 = 0;
GLfloat size = 0.05, sizer = 0.04, sizec = 0.03;
//car 3 variables
GLfloat cy1 = -20, cy2 = -20, cy3 = -40, cy4 = -40, cy5 = -40, cy6 = -40, cy7 = -90, cy8 = -90, cy9 = -90, cy10 = -
90, cy11 = -110, cy12 = -110, cy = 5;//CAR 3
GLfloat cy13 = -25, cy14 = -25, cy15 = -38, cy16 = -38, cy17 = -25, cy18 = -25, cy19 = -38, cy20 = -38, cy21 = -
95, cy22 = -95, cy23 = -108, cy24 = -108, cy25 = -95, cy26 = -95, cy27 = -108, cy28 = -108;
static void key(unsigned char key, int x, int y);
void display();
void drawstring(float x, float y, float z, char* string)
{
char* c;
glRasterPos3f(x, y, z);
for (c = string; *c != '\0'; c++)
{
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *c);
}
}
void drawstring1(float x, float y, float z, char* string)
DEPT OF CSE, CIT 7

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


{
char* c;
glRasterPos3f(x, y, z);
for (c = string; *c != '\0'; c++)
{
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *c);
}
}
void drawstring2(float x, float y, float z, char* string)
{
char* c;
glRasterPos3f(x, y, z);
for (c = string; *c != '\0'; c++)
{
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *c);
}
}

void mov()
{
if (flagl == 0)
{

if (by9 > 380 || by10 > 380 || by11 > 380 || by12 > 380)
{

by1 = by1 - sizer;


by2 = by2 - sizer;
by3 = by3 - sizer;
by4 = by4 - sizer;
by5 = by5 - sizer;
by6 = by6 - sizer;
by7 = by7 - sizer;
by8 = by8 - sizer;
by9 = by9 - sizer;
by10 = by10 - sizer;
by11 = by11 - sizer;
by12 = by12 - sizer;
by13 = by13 - sizer;//wheels
by14 = by14 - sizer;
by15 = by15 - sizer;
by16 = by16 - sizer;
by17 = by17 - sizer;
by18 = by18 - sizer;
by19 = by19 - sizer;
by20 = by20 - sizer;
by21 = by21 - sizer;
by22 = by22 - sizer;
by23 = by23 - sizer;
by24 = by24 - sizer;
by25 = by25 - sizer;

DEPT OF CSE, CIT 8

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


by26 = by26 - sizer;
by27 = by27 - sizer;
by28 = by28 - sizer;
zy2 = zy2 - sizer;
}
}
if (flagl == 1)
{

if (by9 > 1 || by10 >= 1 || by11 >= 1 || by12 >= 1)


{
if (by1 < 270)
flag2 = 0;
by1 = by1 - sizer;
by2 = by2 - sizer;
by3 = by3 - sizer;
by4 = by4 - sizer;
by5 = by5 - sizer;
by6 = by6 - sizer;
by7 = by7 - sizer;
by8 = by8 - sizer;
by9 = by9 - sizer;
by10 = by10 - sizer;
by11 = by11 - sizer;
by12 = by12 - sizer;
by13 = by13 - sizer;//wheel
by14 = by14 - sizer;
by15 = by15 - sizer;
by16 = by16 - sizer;
by17 = by17 - sizer;
by18 = by18 - sizer;
by19 = by19 - sizer;
by20 = by20 - sizer;
by21 = by21 - sizer;
by22 = by22 - sizer;
by23 = by23 - sizer;
by24 = by24 - sizer;
by25 = by25 - sizer;
by26 = by26 - sizer;
by27 = by27 - sizer;
by28 = by28 - sizer;
zy2 = zy2 - sizer;
}
else
{

flagl = 0;

by1 = 480;
by2 = 480;
by3 = 460;

DEPT OF CSE, CIT 9

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


by4 = 460;
by5 = 460;
by6 = 460;
by7 = 420;
by8 = 420;
by9 = 420;
by10 = 420;
by11 = 400;
by12 = 400;
by13 = 403;//wheel
by14 = 403;
by15 = 416;
by16 = 416;
by17 = 403;
by18 = 403;
by19 = 416;
by20 = 416;
by21 = 463;
by22 = 463;
by23 = 476;
by24 = 476;
by25 = 463;
by26 = 463;
by27 = 476;
by28 = 476;
zy2 = 430;
}

//second car move

if (flagr == 0)
{

if (ay9 < 300 || ay10 < 300 || ay11 < 300 || ay12 < 300)
{

ay1 = ay1 + size;


ay2 = ay2 + size;
ay3 = ay3 + size;
ay4 = ay4 + size;
ay5 = ay5 + size;
ay6 = ay6 + size;
ay7 = ay7 + size;
ay8 = ay8 + size;

DEPT OF CSE, CIT 10

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


ay9 = ay9 + size;
ay10 = ay10 + size;
ay11 = ay11 + size;
ay12 = ay12 + size;
ay13 = ay13 + size;//wheel
ay14 = ay14 + size;
ay15 = ay15 + size;
ay16 = ay16 + size;
ay17 = ay17 + size;
ay18 = ay18 + size;
ay19 = ay19 + size;
ay20 = ay20 + size;
ay21 = ay21 + size;
ay22 = ay22 + size;
ay23 = ay23 + size;
ay24 = ay24 + size;
ay25 = ay25 + size;
ay26 = ay26 + size;
ay27 = ay27 + size;
ay28 = ay28 + size;
cy = cy + size;
zy1 = zy1 + size;

}
}
if (flagr == 1)
{
if (ay1 < 500 || ay2 < 500 || ay3 < 500 || ay4 < 500)
{
if (ay1 > 370)
flag3 = 0;
ay1 = ay1 + size;
ay2 = ay2 + size;
ay3 = ay3 + size;
ay4 = ay4 + size;
ay5 = ay5 + size;
ay6 = ay6 + size;
ay7 = ay7 + size;
ay8 = ay8 + size;
ay9 = ay9 + size;
ay10 = ay10 + size;
ay11 = ay11 + size;
ay12 = ay12 + size;
ay13 = ay13 + size;
ay14 = ay14 + size;
ay15 = ay15 + size;
ay16 = ay16 + size;
ay17 = ay17 + size;
ay18 = ay18 + size;
ay19 = ay19 + size;
ay20 = ay20 + size;
ay21 = ay21 + size;

DEPT OF CSE, CIT 11

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


ay22 = ay22 + size;
ay23 = ay23 + size;
ay24 = ay24 + size;
ay25 = ay25 + size;
ay26 = ay26 + size;
ay27 = ay27 + size;
ay28 = ay28 + size;
cy = cy + size;
zy1 = zy1 + size;
}

}
if (flagc == 0)
{
if (cy1 < 330 && cy1 < cy)
{

cy1 = cy1 + sizec;


cy2 = cy2 + sizec;
cy3 = cy3 + sizec;
cy4 = cy4 + sizec;
cy5 = cy5 + sizec;
cy6 = cy6 + sizec;
cy7 = cy7 + sizec;
cy8 = cy8 + sizec;
cy9 = cy9 + sizec;
cy10 = cy10 + sizec;
cy11 = cy11 + sizec;
cy12 = cy12 + sizec;
cy13 = cy13 + sizec;//wheel
cy14 = cy14 + sizec;
cy15 = cy15 + sizec;
cy16 = cy16 + sizec;
cy17 = cy17 + sizec;
cy18 = cy18 + sizec;
cy19 = cy19 + sizec;
cy20 = cy20 + sizec;
cy21 = cy21 + sizec;
cy22 = cy22 + sizec;
cy23 = cy23 + sizec;
cy24 = cy24 + sizec;
cy25 = cy25 + sizec;
cy26 = cy26 + sizec;
cy27 = cy27 + sizec;
cy28 = cy28 + sizec;
}
}
if (flagc == 1)
{
if (cy1 > 270)
flag3 = 0;
if (cy1 <= 499 && cy1 < cy)

DEPT OF CSE, CIT 12

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


{
if (cy12 > 370)
flag3 = 0;
cy1 = cy1 + sizec;
cy2 = cy2 + sizec;
cy3 = cy3 + sizec;
cy4 = cy4 + sizec;
cy5 = cy5 + sizec;
cy6 = cy6 + sizec;
cy7 = cy7 + sizec;
cy8 = cy8 + sizec;
cy9 = cy9 + sizec;
cy10 = cy10 + sizec;
cy11 = cy11 + sizec;
cy12 = cy12 + sizec;
cy13 = cy13 + sizec;//wheel
cy14 = cy14 + sizec;
cy15 = cy15 + sizec;
cy16 = cy16 + sizec;
cy17 = cy17 + sizec;
cy18 = cy18 + sizec;
cy19 = cy19 + sizec;
cy20 = cy20 + sizec;
cy21 = cy21 + sizec;
cy22 = cy22 + sizec;
cy23 = cy23 + sizec;
cy24 = cy24 + sizec;
cy25 = cy25 + sizec;
cy26 = cy26 + sizec;
cy27 = cy27 + sizec;
cy28 = cy28 + sizec;
}

else
{
flagc = 1;
flag3 = 0;
color1 = 1;
cy1 = -20;
cy2 = -20;
cy3 = -40;
cy4 = -40;
cy5 = -40;
cy6 = -40;
cy7 = -90;
cy8 = -90;
cy9 = -90;
cy10 = -90;
cy11 = -110;
cy12 = -110;
cy13 = -25;//wheel
cy14 = -25;

DEPT OF CSE, CIT 13

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


cy15 = -38;
cy16 = -38;
cy17 = -25;
cy18 = -25;
cy19 = -38;
cy20 = -38;
cy21 = -95;
cy22 = -95;
cy23 = -108;
cy24 = -108;
cy25 = -95;
cy26 = -95;
cy27 = -108;
cy28 = -108;

}
}

glutPostRedisplay();
}

void mouse(int btn, int state, int x, int y)


{
if (btn == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
flagr = 1;
flag3 = 1;

if (btn == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)


flagl = 1;
flag2 = 1;

void reshape(int w, int h)


{

glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
gluOrtho2D(0.0, 500.0, 0.0 * (GLfloat)h / (GLfloat)w, 500.0 * (GLfloat)h / (GLfloat)w);
else
gluOrtho2D(0.0 * (GLfloat)w / (GLfloat)h, 500.0 * (GLfloat)w / (GLfloat)h, 0.0, 500.0);
glMatrixMode(GL_MODELVIEW);

void init(void)
{

DEPT OF CSE, CIT 14

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


glClearColor(0.1, 0.5, 0.1, 0.0);
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 500, 0, 500);
glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitWindowSize(500, 500);
glutInitWindowPosition(300, 200);
glutCreateWindow("Toll collecting booth");
init();
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutReshapeFunc(reshape);
glutIdleFunc(mov);
glutKeyboardFunc(key);
glutMainLoop();

static void key(unsigned char key1, int x, int y)


{
switch (key1)
{
case 'Q':
case 'q':
exit(0);

break;

case 'r':
case 'R':
flagl = 1;
flag2 = 1;
break;

case 'l':
case 'L':
flagr = 1;
flag3 = 1;
break;
case 'z':
case 'Z':
size = size * 2;
break;
case 'x':
case 'X':

DEPT OF CSE, CIT 15

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


size = size / 2;
break;
case 'n':
case 'N':
sizer = sizer * 2;
break;
case 'm':
case 'M':
sizer = sizer / 2;
break;
case 'v':
case 'V':
sizec = sizec * 2;
break;
case 'b':
case 'B':
sizec = sizec / 2;
break;
case '1':flaga = 1;
break;
case '2':flagd = 1;
break;
case '0':flagc = 1;
break;
}
}
void welcome()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 0.0);
drawstring(150, 400, 0.0, "WEL-COME");
glColor3f(0.0, 1.0, 1.0);
drawstring1(100, 300, 0.0, "Mini Project created by:");
glColor3f(0.0, 0.0, 1.0);
drawstring(180, 260, 0.0, "Puneethkumar and Rahul ");
glColor3f(1.0, 1.0, 0.0);
drawstring2(300, 20, 0.0, "For Next Press:1");

void frontscreen()
{
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(0.0, 0.0, 0.0);


drawstring(130, 470, 0.0, "computer grapics");
drawstring(190, 470, 0.0, "mini");
drawstring(260, 470, 0.0, "project");
glColor3f(1.0, 0.5, 0.5);
drawstring(70, 410, 0.0, "[TOLL");
drawstring(170, 410, 0.0, "COLLECTING");

DEPT OF CSE, CIT 16

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


drawstring(350, 410, 0.0, "BOOTH]");
glColor3f(1.0, 1.0, 1.0);
drawstring1(10, 350, 0.0, "submitted");
drawstring1(115, 350, 0.0, "by: Puneethkmar , Rahul");
glColor3f(0.0, 0.0, 0.0);
drawstring1(20, 320, 0.0, "students name usn");
glColor3f(0.0, 0.0, 1.0);
drawstring2(20, 265, 0.0, "Puneethkumar , 1cg18cs068");
drawstring2(20, 290, 0.0, "rahul , 1cg18cs069");
glColor3f(1.0, 1.0, 1.0);
drawstring1(10, 230, 0.0, "Under the Guidance of Mahesh
N");
glColor3f(0.0, 1.0, 0.0);
drawstring2(20, 200, 0.0, "Prof.mahesh ");
glColor3f(0.0, 0.0, 0.0);
drawstring1(20, 90, 0.0, "Year:-2021");
glColor3f(1.0, 0.0, 0.0);
drawstring1(300, 90, 0.0, "For Next press: 2");

glFlush();
}
void color()
{
glColor3f(0.0, 0.0, 1.0);
if (color1 == 1)
glColor3f(0.7, 0.2, 0.5);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
if (flaga == 0)
{
welcome();
}
else
{

if (flagd == 0)
frontscreen();
else
{

glClearColor(0.0, 0.6, 0.0, 1.0);

glColor3f(0.658824, 0.658824, 0.658824);


glBegin(GL_POLYGON);
glVertex2f(100, 500);
glVertex2f(400, 500);
glVertex2f(400, 0);
glVertex2f(100, 0);
glEnd();
glColor3f(1.0, 0.0, 0.0);

DEPT OF CSE, CIT 17

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

glBegin(GL_POLYGON);
glVertex2f(100, 365);
glVertex2f(110, 365);
glVertex2f(110, 330);
glVertex2f(100, 330);
glEnd();
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(390, 365);
glVertex2f(400, 365);
glVertex2f(400, 330);
glVertex2f(390, 330);
glEnd();
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(245, 365);
glVertex2f(260, 365);
glVertex2f(260, 330);
glVertex2f(245, 330);
glEnd();

glColor3f(0.5, 0.5, 1.0);


glBegin(GL_QUADS);

glVertex2f(bx + 290,
by1);
glVertex2f(bx + 340,
by2);
glVertex2f(bx + 340,
by3);
glVertex2f(bx + 290,
by4);
glEnd();
glBegin(GL_QUADS);
glVertex2f(bx + 280,
by5); glVertex2f(bx +
350, by6); glVertex2f(bx
+ 350, by7);
glVertex2f(bx + 280,
by8); glEnd();
glBegin(GL_QUADS);
glVertex2f(bx + 290,
by9);
glVertex2f(bx + 340,
by10);
glVertex2f(bx + 340,
by11);
glVertex2f(bx + 290,
by12);
glEnd();

DEPT OF CSE, CIT 18

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(bx + 285, by13);//rt cr tp lft wl
glVertex2f(bx + 290, by14);
glVertex2f(bx + 290, by15);
glVertex2f(bx + 285, by16);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(bx + 340, by17);//rt cr tp rt wl
glVertex2f(bx + 345, by18);
glVertex2f(bx + 345, by19);
glVertex2f(bx + 340, by20);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(bx + 285, by21);//rt cr btm lft wel
glVertex2f(bx + 290, by22);
glVertex2f(bx + 290, by23);
glVertex2f(bx + 285, by24);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(bx + 340, by25);//rt cr btm rt wel
glVertex2f(bx + 345, by26);
glVertex2f(bx + 345, by27);
glVertex2f(bx + 340, by28);
glEnd();

DEPT OF CSE, CIT 19

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22


//car name
glColor3f(1.0, 1.0, 1.0);
drawstring1(bx + 300, zy2, 0, "NANO");

//left side car


glColor3f(1.0, 1.0, 1.0);
glBegin(GL_QUADS);

glVertex2f(ax + 140, ay1);


glVertex2f(ax + 190, ay2);
glVertex2f(ax + 190, ay3);
glVertex2f(ax + 140, ay4);
glEnd();
glBegin(GL_QUADS);
glVertex2f(ax + 130, ay5);
glVertex2f(ax + 200, ay6);
glVertex2f(ax + 200, ay7);
glVertex2f(ax + 130, ay8);
glEnd();
glBegin(GL_QUADS);
glVertex2f(ax + 140, ay9);
glVertex2f(ax + 190, ay10);
glVertex2f(ax + 190, ay11);
glVertex2f(ax + 140, ay12);
glEnd();
//left car name
glColor3f(1.0, 0.0, 1.0);
drawstring1(ax + 155, zy1, 0, "BMW");

//wheel
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 135, ay13);//lft cr btm
glVertex2f(ax + 140, ay14);//lt wel
glVertex2f(ax + 140, ay15);
glVertex2f(ax + 135, ay16);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 190, ay17);//lft cr btm rt wel
glVertex2f(ax + 195, ay18);
glVertex2f(ax + 195, ay19);
glVertex2f(ax + 190, ay20);
glEnd();
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 190, ay17);//lft cr btm rt wel
glVertex2f(ax + 195, ay18);
glVertex2f(ax + 195, ay19);
glVertex2f(ax + 190, ay20);
glEnd();

DEPT OF CSE, CIT 20

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 135, ay21);//left cr top
glVertex2f(ax + 140, ay22);//lft wel
glVertex2f(ax + 140, ay23);
glVertex2f(ax + 135, ay24);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 190, ay25);//lft car top rt wel
glVertex2f(ax + 195, ay26);
glVertex2f(ax + 195, ay27);
glVertex2f(ax + 190, ay28);
glEnd();
// car3
//color();

DEPT OF CSE, CIT 21

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

// display instruction for left car

//display instructions for car nano


glColor3f(0.0, 0.0, 0.0);
drawstring1(ax + 0, 60, 0, "Car BMW");
drawstring1(ax + 0, 50, 0, "instructions:");
drawstring1(ax + 0, 40, 0, "l:open barrier");
drawstring1(ax + 0, 30, 0, "z:speed up");
drawstring1(ax + 0, 20, 0, "x:speed down");
// display instruction for left car

glColor3f(0.0, 0.0, 0.0);


drawstring1(ax + 390, 60, 0, "Car nano");
drawstring1(ax + 390, 50, 0, "instructions:");
drawstring1(ax + 390, 40, 0, "r:open barrier");
drawstring1(ax + 390, 30, 0, "n:speed up");
drawstring1(ax + 390, 20, 0, "m:speed down");

if (flagl == 0 || flag2 == 0)
{

//BARRIER 1
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(260, 355);
glVertex2f(390, 355);
glVertex2f(390, 345);
glVertex2f(260, 345);
glEnd();
glPointSize(20.0);
glColor3f(1.0, 0.0, 0.0);

glBegin(GL_POINTS); glVertex2f(420, 345); glEnd();

drawstring(437, 340, 0, "STOP");

}
else
{
glColor3f(0.0, 1.5, 0.0);
glPointSize(20.0);

glBegin(GL_POINTS);
glVertex2f(420, 345);
glEnd();
drawstring(450, 340, 0, "GO");
}

DEPT OF CSE, CIT 22

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

//BARRIER 2

if (flagr == 0 || flag3 == 0)
{
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(110, 355);
glVertex2f(245, 355);
glVertex2f(245, 345);
glVertex2f(110, 345);
glEnd();
glPointSize(20.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POINTS);
glVertex2f(80, 345);
glEnd();
drawstring(8, 330, 0, "STOP");
}
else
{
glPointSize(20.0);
glColor3f(0.0, 1.5, 0.0);
glBegin(GL_POINTS);
glVertex2f(80, 345);
glEnd();

drawstring(10, 330, 0, "GO");


}
}
}
glFlush();

DEPT OF CSE, CIT 23

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

CHAPTER 5:
SNAPSHOTS

Fig.1 :- FIRST PAGE: In This Page Details of Developers is provided

DEPT OF CSE, CIT 24

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

Page 2: In This Page USN and Name of Project is displayed

DEPT OF CSE, CIT 25

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

Fig.3 :- Red signal : In This Fig the vehicles are in stationary position

DEPT OF CSE, CIT 26

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

Fig.4 :- Yellow signal : In This Fig The vehicles are in movement

DEPT OF CSE, CIT 27

Downloaded by Siddesh AV (siddesh1876@gmail.com)


lOMoARcPSD|20328656

TOLL BOOTH 2021-22

CHAPTER 6

BIBLIOGRAPHY

We have obtained information from many resources information from many resources to design
and implement our project successively. We have acquired most of the knowledge from related
websites. The following are some of the resources :

1] Text books :
interactive computer graphics a top-down approach
-by Edward Angel.

2] Computer graphics, principles & practices

- Foley van dam


- Finer Hughes

3] Web references:
http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson3.php
http://google.com
http://opengl.org

DEPT OF CSE, CIT 28

Downloaded by Siddesh AV (siddesh1876@gmail.com)

You might also like