Uploaded by priyaannarao412

CGV REPORT 1015

advertisement
VISVESVARAYA TECHNOLOGICAL
UNIVERSITYBELAGAVI
A MINI PROJECT REPORT ON
Toll Collecting Using OpenGL
IN
COMPUTER SCIENCE & ENGINEERING
By
PRIYARANI A G
4AL20CS101
REKHA M S
4AL20CS115
Under the Guidance
of Dr.Madhushan S
Assistant Professor
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
ALVA’S INSTITUTE OF ENGINEERING AND
TECHNOLOGYMOODBIDRI-574225, KARNATAKA
2023–2024
ALVA’S INSTITUTE OF ENGINEERING AND TECHNOLOGY
MIJAR, MOODBIDRI D.K. -574225
KARNATAKA
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
CERTIFICATE
This is to certify that the Mini Project entitled Toll Collecting Using OpenGL has beensuccessfully
completed by
PRIYARANI A G
4AL20CS101
REKHA M S
4AL20CS115
The tudents of the Department of Computer Science & Engineering, Alva’s Institute of
Engineering and Technology in DEPARTMENT OF COMPUTER SCIENCE &
ENGINEERING of the VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELAGAVI
during the year 2021–2022. It is certified that all corrections/suggestions indicated for Internal
Assessment have been incorporated in the report deposited in the departmental library. The Mini
Project report has been approved as it satisfies the academic requirements in respect of the Mini
Projectwork prescribed for the Bachelor of Engineering Degree.
Dr.Madhusudhan S
Mini Project Guide
Dr Manjunath Kotari
HOD CSE
External Viva
Name of the Examiners
1.
2.
Signature with Date
ALVA’S INSTITUTE OF ENGINEERING AND TECHNOLOGY
MIJAR, MOODBIDRI D.K. -574225
KARNATAKA
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
Declaration
We,
PRIYARANI A G
REKHA M S
hereby declare that the dissertation entitled, Alva’s Event Management is completed and
written by us under the supervision of my guide Dr.Madhusudhan S, Assistant Professor,
Department of Computer Science and Engineering. Alva’s Institute of Engineering And
Technology, Moodbidri, DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
of the VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELAGAVI during the
academic year 2023-2024. The dissertation report is original and it has not been submitted
for any other degree in any university.
PRIYARANI A G
4AL20CS101
REKHA M
4AL20CS115
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany a successful completion of any task would
be incomplete without the mention of people who made it possible, success is the epitome
of hard work and perseverance, but steadfast of all is encouraging guidance.
So, with gratitude we acknowledge all those whose guidance and encouragement
served as beacon of light and crowned the effort with success.
The selection of this mini-project work as well as the timely completion is mainly
due to the interest and persuasion of our mini-project coordinator Dr.Madhusudhan S
Assistant Professor, Department of Computer Science & Engineering. We will remember
his contribution forever.
We sincerely thank Dr. Manjunath Kotari, Professor and Head, the Department
of Computer Science & Engineering who has been the constant driving force behind the
completion of the project.
We thank our beloved Principal Dr.Peter Fernandes, for his constant help and
support throughout.
We are indebted to the Management of Alva’s Institute of Engineering and
Technology, Mijar, Moodbidri for providing an environment that helped us in completing
our mini project.
Also, we thank all the teaching and non-teaching staff of the Department of
Computer Science & Engineering for the help rendered.
iv
PRIYARANI A G
4AL20CS101
REKHA M S
4AL20CS115
ABSTRACT
The main idea behind this project is to display the concept of a toll collecting
booth with computer graphics. This graphics package is based on the OpenGL library
functions. The programming language used here is C using OpenGL libraries.
The idea behind this project is to display the concept of toll collection booths
through computer graphics. This project will include a toll collecting booth where as soon
as the car comes the barrier is imposed. This barrier will then be lifted by the user.
There will be a two-way path in at both ways we have at toll collecting booth for
both directions. To open the left side barrier we use to press ‘L|l’ key, as soon as the key
is pressed the left side car will move. And in the same way, we have ‘R|r’ key to open the
barrier
and
allow
the
car
v
to
move
further.
TABLE OF CONTENTS
Chap no
Description
Page No
Acknowledgment
i
Abstract
ii
Contents
iii
List of Snapshots
iv
1
INTRODUCTION
1-2
2
REQUIREMENT ANALYSIS
3
2.1
Project Requirements
2.2
Software Requirements
2.3
Hardware Requirements
2.4
Languages Used
3
PROJECT DESIGN
3.1
Creating of Node
3.2
Searching of Node
3.3
Deleting of Node
4
4-5
IMPLEMENTATION
4.1
Pseudo Code
4.2
Glut Functions
4.3
Steps Involved
4.4
Flow Diagram
6-8
5
RESULT
9-13
6
CONCLUSION
14
REFERENCES
vi
List of Snapshots
Page No
1. Snapshot 5.1.1
9
2. Snapshot 5.1.2.
10
3. Snapshot 5.1.3
10
4. Snapshot 5.1.4
11
5. Snapshot 5.1.5
11
6. Snapshot 5.1.6
12
7. Snapshot 5.1.7
12
8. Snapshot 5.1.8
13
vii
Toll Collecting Using OpenGL
Chapter 1
INTRODUCTION
This chapter gives a brief introductiotout computer graphics, the features of glew
and glut and binary search trees.
1.1
COMPUTER GRAPHICS
Computers have become a powerful tool for the rapid and economical production
of pictures. There is virtually no area in which graphical displays cannot be used to some
advantage, and so it is not surprising to find the use of computer graphics so widespread.
Although early applications in engineering and science had to rely on expensive and
cumbersome equipment, advances in computer technology have made interactive
computer graphics a practical tool. Computer graphics are pictures and films created using
computers. Usually, the term refers to computer generated image data created with the
help of specialized graphical hardware and software.
1.2
OPENGL
Open Graphics Library (OpenGL) is a cross-language, cross-platform application
programming interface (API) for rendering 2D and 3D vector graphics. The API is
typically used to interact with a graphics processing unit (GPU), to achieve hardwareaccelerated rendering. Modern OpenGL has raised the entry threshold for computer
graphics programming.
1.3
GLUT
The OpenGL Utility Toolkit (GLUT) is a library of utilities for OpenGL programs, which
primarily perform system-level I/O with the host operating system. Functions performed
include window definition, window control, and monitoring of keyboard and mouse input.
Routines for drawing a number of geometric primitives (both in solid and wireframe
mode) are also provided, including cubes, spheres and the Utah teapot. GLUT also has
some limited support for creating pop-up menus.
Dept. of CSE, AIET, MOODBIDRI
Page 1
Toll Collecting Using OpenGL
1.4
FREEGLUT
FreeGLUT is a free-software/open-source alternative to the OpenGL Utility Toolkit
(GLUT) library. GLUT (and hence FreeGLUT) allows the user to create and manage
windows containing OpenGL contexts on a wide range of platforms and also read the
mouse, keyboard and joystick functions. FreeGLUT is intended to be a full replacement
for GLUT, and has only a few differences.
1.5
GLEW
The OpenGL Extension Wrangler Library (GLEW) is a cross-platform opensource C/C++
extension loading library. GLEW provides efficient run-time mechanisms for determining
which OpenGL extensions are supported on the target platform. OpenGL core and
extension
functionality
are
Dept. of CSE, AIET, MOODBIDRI
exposed
in
a
single
header
file.
Page 2
Toll Collecting Using OpenGL
Chapter 2
REQUIREMENT ANALYSIS
2.1 Project Requirements
The package is designed such that users with a computer having minimum configuration
can also use it. It doesn’t require many complex graphics packages.
The package requires simple in-built functions found in the Freeglut library. Some
basic functions found in the graphics package of Codeblocks compiler have also been
used.
2.2 Software Requirements
The minimum requirements are

Windows operating system.

Codeblocks Version 17.12.

Freeglut 3.0.0.
Hardware Requirements
The minimum requirements are

A computer with 333 MHz processor.

32 MB SD/DDR RAM.

100 MB of Hard disk space.

Monitor resolution - A color monitor with a minimum resolution of 640*480.
2.3 Languages Used



Opengl Functions
Data structure in cpp.
Object Oriented Concept
Dept. of CSE, AIET, MOODBIDRI
Page 3
Toll Collecting Using OpenGL
Chapter 3
PROJECT DESIGN
Binary Search Tree Visualizer basically implements creating, searching and
deleting .This Visualizer makes use of the fact that OpenGL provides the low-level
rendering routines allowing the programmer a great deal of control and flexibility. BSTV
also make use of the prominent library of OpenGL (i.e) GLUT.
BSTV is broadly classified into 3 major steps. They are:

Creating of Node

Searching of Node.

Deleting of Node.
3.1 Creating of Node:
In the creating phase we enter the node details in the terminal screen and to stop
entering node we enter zero ‘0’. Insertion in BST begins as a search would begin; if the
key is not equal to that of the root, we search the left or right subtrees as before.
Eventually, we will reach an external node and add the new key-value pair (here encoded
as a record 'newNode') as its right or left child, depending on the node's key. In other
words, we examine the root and recursively insert the new node to the left subtree if its
key is less than that of the root, or the right subtree if its key is greater than or equal to the
root.
3.2 Searching of Node:
We begin by examining the root node. If the tree is null, the key we are searching
for does not exist in the tree. Otherwise, if the key equals that of the root, the search is
successful and we return the node. If the key is less than that of the root, we search the left
subtree. Similarly, if the key is greater than that of the root, we search the right subtree.
This process is repeated until the key is found or the remaining subtree is null. If the
searched key is not found after a null subtree is reached, then the key is not present in the
tree.
Dept. of CSE, AIET, MOODBIDRI
Page 4
Toll Collecting Using OpenGL
If the order relation is only a total preorder, a reasonable extension of the
functionality is the following: also in case of equality search down to the leaves. Thereby
allowing to specify (or hard-wire) a direction, where to insert a duplicate, either to the
right or left of all duplicates in the tree so far. If the direction is hard-wired, both choices,
right and left, support a stack with insert duplicate as push operation and delete as the pop
operation
3.3 Deleting of Node:
When removing a node from a binary search tree it is mandatory to maintain the
in-order sequence of the nodes. There are many possibilities to do this. However, the
following method which has been proposed by T. Hibbard in 1962 guarantees that the
heights of the subject subtrees are changed by at most one. There are three possible cases
to consider:

Deleting a node with no children: simply remove the node from the tree.

Deleting a node with one child: remove the node and replace it with its child.

Deleting a node D with two children: choose either D's in-order predecessor or inorder successor E (see figure). Instead of deleting D, overwrite its key and value
with E's. If E does not have a child, remove E from its previous parent G. If E has a
child F, it is a right child, so that it is to replace E at E's parent.
Dept. of CSE, AIET, MOODBIDRI
Page 5
Toll Collecting Using OpenGL
Chapter 4
IMPLEMENTATION
This section gives information regarding the user defined functions and GLUT
functions used in the project.
4.1 Code
// car3
//color();
color();
glBegin(GL_QUADS);
glVertex2f(ax + 140, cy1);
glVertex2f(ax + 190, cy2);
glVertex2f(ax + 190, cy3);
glVertex2f(ax + 140, cy4);
glEnd();
glBegin(GL_QUADS);
glVertex2f(ax + 130, cy5);
glVertex2f(ax + 200, cy6);
glVertex2f(ax + 200, cy7);
glVertex2f(ax + 130, cy8);
glEnd();
glBegin(GL_QUADS);
glVertex2f(ax + 140, cy9);
glVertex2f(ax + 190, cy10);
glVertex2f(ax + 190, cy11);
glVertex2f(ax + 140, cy12);
glEnd();
//wheel
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 135, cy13);//lft cr btm
glVertex2f(ax + 140, cy14);//lt wel
Dept. of CSE, AIET, MOODBIDRI
Page 6
Toll Collecting Using OpenGL
glVertex2f(ax + 140, cy15);
glVertex2f(ax + 135, cy16);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 190, cy17);//lft cr btm rt wel
glVertex2f(ax + 195, cy18);
glVertex2f(ax + 195, cy19);
glVertex2f(ax + 190, cy20);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 135, cy21);//left cr top
glVertex2f(ax + 140, cy22);//lft wel
glVertex2f(ax + 140, cy23);
glVertex2f(ax + 135, cy24);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(ax + 190, cy25);//lft car top rt wel
glVertex2f(ax + 195, cy26);
glVertex2f(ax + 195, cy27);
glVertex2f(ax + 190, cy28);
glEnd();
Dept. of CSE, AIET, MOODBIDRI
Page 7
Toll Collecting Using OpenGL
4.2 GLUT Functions

glBegin(): Initiates a new primitive of type mode and starts the collection of
vertices. Values of mode include GL_POINTS, GL_LINES and GL_POLYGON.

glEnd(): Terminates a list of vertices

glutInit(&argc,argv): Initializes GLUT and processes any command line
arguments(for x, this would be options like display and geometry).

glutInit(): should be called before any other GLUT routine.

glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB): Specifies whether to use
an RGBA or color_index model. You can also specify whether you want a single
or double buffered window. If you are working in color_index mode,you will want
to load certain colors into the color map use glutSetColor() to do this. Finaly, you
can use this routine to indicate you want the window to have an associated depth,
stencil, and/or accumulation buffer.

glutCreatewindow(“Binary Search Tree”): Creates a window with an openGL
context.it returns a unique identifier for the new window. Until glutMainLoop() is
called the window is not displayed.

glutInitWindowSize(x_size,y_size): Specifies the size in pixels of your window.

glutInitWindowPosition(int x,int y): Specifies the screen location for the
upper_left corner of your window.

glutDisplayFunc(display): It is the first and most important event callback
function you will see. Whenever GLUT determines the contents of window,
sometimes you will have to call glutPostRedisplay(void), which gives
glutMainLoop() a nudge to call the registered display callback at its next
opportunity.
4.3 Steps Involved
1. Click on the Run Button in visual studio after the project is opened
2. Enter the elements to be inserted in the black screen and hit 0 when over
3. Click anywhere on the output window to see the tree
4. Click and hold on the buttons available for the features
Dept. of CSE, AIET, MOODBIDRI
Page 8
Toll Collecting Using OpenGL
5. Enter the element and press Enter. Based on the option selected
a. Insert: The entered element will be added to the tree as a new node
b. Delete: The entered element will be deleted from the tree
c. Search: The entered element will be searched and highlighted in the tree
6. To repeat any of the features repeat steps 4 and 5 accordingly
7. Close the window for stopping the execution of project.
4.4 Flow Diagram
Fig 4.4.1 flow diagram.
Dept. of CSE, AIET, MOODBIDRI
Page 9
Toll Collecting Using OpenGL
Chapter 5
RESULT
This section includes the snapshots of the possible test cases of the project and its
details.
5.1 Snapshots
Fig 5.1.1 Input Screen
The user can input the elements for insertion as shown in Fig 5.1.
It is a node-based binary tree data structure which has the following properties:

The left subtree of a node contains only nodes with keys lesser thanthe node’s key.

The right subtree of a node contains only nodes with keys greater than the node’s
key.

The left and right subtree each must also be a binary search tree.
Dept. of CSE, AIET, MOODBIDRI
Page 10
Toll Collecting Using OpenGL
F
i
g
5
.
1
.
2
O
u
t
p
u
t
W
i
n
d
ow
The user is redirected to the window shown in Fig 5.1.2 after he enters the elements
and enters 0.
Fig 5.1.3 Display of BST
Dept. of CSE, AIET, MOODBIDRI
Page 11
Toll Collecting Using OpenGL
Fig 5.1.4 Prompt message for option clicked
A prompt message is shown for the user when he clicks on the options given in order
to insert, delete or search an element as shown in Fig 5.1.4.
F
i
g
5
.
1
.
5
I
n
s
e
r
t
i
o
n
of a node
The insertion of nodes takes place as shown in Fig 5.1.5
Dept. of CSE, AIET, MOODBIDRI
Page 12
Toll Collecting Using OpenGL
F
i
g
5
.
1
.
6
s
e
a
r
c
h
i
n
g
a
node
Searching of the specified node takes place as shown in Fig 5.1.6
Dept. of CSE, AIET, MOODBIDRI
Page 13
Toll Collecting Using OpenGL
Chapter 6
CONCLUSION
The BINARY SEARCH TREE Graphics package has been developed Using
OpenGL. The illustration of graphical principles and OpenGL features areincluded and
application program is efficiently developed. The aim in developing this program was
to design a simple program using Open GL application software by applying the skills
we learnt in class, and in doing so, to understand the algorithms and the techniques
underlying interactive graphics better. The designed program will incorporate all the
basic properties that a simple program must possess. The program is user friendly as the
only skill required in executing this program is the knowledge of graphics. The main
idea of the program is to visualize the features of Binary Search Tree effectively
through computer graphics.
Dept. of CSE, AIET, MOODBIDRI
Page 14
REFERENCES
Textbooks Referred

Donald Hearn & Pauline Baker: Computer Graphics with OpenGL Version,
3rd / 4th Edition, Pearson Education, 2011

Edward Angel: Interactive Computer Graphics- A Top Down approach with
OpenGL, 5th edition. Pearson Education, 2008
Links Referred

https://learnopengl.com/Getting-started/OpenGL

https://www.geeksforgeeks.org/binary-search-tree-set-1-search-andinsertion/
Download