Professional Documents
Culture Documents
CG Miniproject Report
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
Channabasaveshwara Institute of
Technology
(Affiliated to VTU, Belgaum & Approved by AICTE, New
Delhi) (NAAC Accredited &ISO 9001:2015 Certified
Institution)
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
Principal
Dr. Suresh D S Ph. D,
Principal
CIT, Gubbi.
External Viva
1.
2.
Channabasaveshwara Institute of
Technology
(Affiliated to VTU, Belgaum & Approved by AICTE, New
Delhi) (NAAC Accredited &ISO 9001:2015 Certified
Institution)
DECLARATION
RAHUL G C
USN: 1CG18CS069
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]
(i)
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)
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.
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]
Chapter 2
REQUIREMENTS SPECIFICATION
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.
• glutCreateWindow( ) : this opens the OPENGL window and displays the title at top of the window
• glTranslatef () : used to translate or move the rotation centre from one point to another in three
dimensions
• 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,
Key z :- Speed Up
Key n: - Speed Up
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
void mov()
{
if (flagl == 0)
{
if (by9 > 380 || by10 > 380 || by11 > 380 || by12 > 380)
{
flagl = 0;
by1 = 480;
by2 = 480;
by3 = 460;
if (flagr == 0)
{
if (ay9 < 300 || ay10 < 300 || ay11 < 300 || ay12 < 300)
{
}
}
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;
}
if (flagc == 0)
{
if (cy1 < 330 && cy1 < cy)
{
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;
}
}
glutPostRedisplay();
}
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)
{
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':
void frontscreen()
{
glClear(GL_COLOR_BUFFER_BIT);
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
{
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();
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();
//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();
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();
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);
}
else
{
glColor3f(0.0, 1.5, 0.0);
glPointSize(20.0);
glBegin(GL_POINTS);
glVertex2f(420, 345);
glEnd();
drawstring(450, 340, 0, "GO");
}
//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();
CHAPTER 5:
SNAPSHOTS
Fig.3 :- Red signal : In This Fig the vehicles are in stationary position
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.
3] Web references:
http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson3.php
http://google.com
http://opengl.org