Car Park Report
Car Park Report
Car Park Report
BELGAUM-590014
CHANDRASHEKAR.G (1DT18CS031)
AND
LEELAVATHI.B (1DT19CS05)
CERTIFICATE
This is to certify that the Mini-Project on Computer Graphics and Visualization work entitled
“CAR PARK” has been successfully carried out by CHANDRASHEKAR.G (1DT18CS031)
And LEELAVATHI.B (1DT19CS405) a bonafide students of Dayananda Sagar Academy
of Technology and Management in partial fulfilment of the requirements for the award of
degree in Bachelor of Engineering in Computer Science and Engineering of Visvesvaraya
Technological University, Belgaum during academic year 2020-2021. 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 project work for the said degree.
Anoop G L Rashmi K S
Asst. Professor Asst. Professor
Dr. C. NANDINI
(Vice Principal & HOD, Dept. of CSE)
Examiners: Signature with Date
1:
2:
ABSTRACT
The aim of this project is to create a 3-D/VIRTUAL CAR PARK. The viewer is allowed
to roam around in the parking area and see the cars closely and to drive a car and park it in the
car park area. The parking area is surrounded by a number of houses. First the co-ordinates of the
car is calculated and then using the OPENGL PRIMITIVES the car is constructed.
The PRIMITIVES used are:-
1. GL_LINES
2. GL_POLYGON
3. GL_QUADS
4. GL_TRIANGLE
In a similar way the 3D house is constructed. A display list is constructed for each of these
objects. These display lists are used everytime a car or house has to be constructed. So, to create
the 36 cars in the parking lot the “carr_display_list “ is called 36 times from within a loop and
are translated each time by suitable values to place them correctly. Similarly, to construct the
houses “house_display_list” is called and are suitably translated, scaled and rotated to place them
properly.
ACKNOWLEDGEMENT
While presenting this Graphics Project on “CAR PARK”, I feel that it is our duty to
acknowledge the help rendered to us by various persons.
Firstly I thank God for showering his blessings on me. I am grateful to my institution
Dayananda Sagar Academy of Technology for providing me a congenial atmosphere to carry out
the project successfully.
I would also like to express my heartfelt gratitude to Dr.C Nandini, Prof. Vice
Principal & HOD, Computer Science and Engineering Department, whose guidance and
support was truly invaluable.
I would also indebted to my Parents and Friends for their continued moral and material
support throughout the course of project and helping me in finalize the presentation.
My heartful thanks to all those have contributed bits, bytes and words to accomplish this
Project.
Thanking you all,
CHANDRASHEKAR.G (1DT18CS031)
LEELAVATHI.B (1DT19CS405)
TABLE OF CONTENTS
CHAPTER NO. CHAPTER NAME PAGE NO.
1. INTRODUCTION ………………… 1
1.1 Introduction To OpenGL…………………… 1
1.2 Computer Graphics ………………………..…. 1
1.3 A Brief History of OpenGL……………………. 2
1.3.1 What is OpenGL…………………………..3
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION TO OPEN-GL
The totality of computer graphics software encompasses the concepts from data
structures, from data base design and management, from the psychology, ergonometric of the
man-machine interface, from programming languages and operating system.
Numerous computer graphics standards can be grouped following categories.
• First is the graphics application interface, where ideas are translated into a form that is
understandable by a computer system. Current representative standards are the GKS,
• The Second is concerned with the storage and transmission of data between graphics
manufacturing systems. The current standard in this area is the Initial Graphics Exchange
Specification (IGES).
A computer graphics system is a computer system with all the components of the general
purpose computer system. There are five major elements in system: input devices, processor,
memory, frame buffer, output devices.
In 1992 the OpenGL Architectural Review Board (OpenGL ARB) was established. The OpenGL
ARB is a group of companies that maintain and update the OpenGL standard.
In 2003 the first OpenGL (Exchange Specification) ES specification was released. OpenGL ES is
a subset of OpenGL designed for mobile phones, embedded devices and video game systems.
In 2004 the OpenGL 2.0 specification was released, including the GLSL (OpenGL Shading
1.3.1 What is Open-GL?
OpenGL is an API …
Operations
OpenGL provides a powerful but primitive set of rendering commands, and all higher-level
drawing must be done in terms of these commands. Also, OpenGL programs have to use the
underlying mechanisms of the windowing system. A number of libraries exist to allow you to
simplify your programming tasks, including the following:
• The OpenGL Utility Library (GLU) contains several routines that use lower-level OpenGL
commands to perform such tasks as setting up matrices for specific viewing orientations and
projections, performing polygon tessellation, and rendering surfaces. GLU routines use the
prefix glu.
• The OpenGL Utility Toolkit (GLUT) is a window system-independent toolkit, written by
Mark Kilgard, to hide the complexities of differing window system APIs. GLUT is the
subject of the next section, and it’s described in more detail in Mark Kilgard’s book
OpenGL Programming for the X Window System (ISBN 0-201-48359-9). GLUT routines
use the prefix glut. "How to Obtain the Sample Code" in the Preface describes how to
obtain the source code for GLUT, using ftp.
CHAPTER 2
REQUIREMENTS SPECIFICATION
2.1 HARDWARE REQUIREMENTS
• Processor : Pentium PC
• RAM : 512MB
• Hard Disk : 20GB(approx)
• Display : VGA Color Monitor
CHAPTER 3
SYSTEM DESIGN
Design of any software depends on the architecture of the machine on which that software
runs, for which the designer needs to know the system architecture. Design process involves
design of suitable algorithms, modules, subsystems, interfaces etc.
CHAPTER 4
IMPLEMENTATION
The implementation stage of this model involves the following phases.
2.glutInitDisplayMode():
glutInitDisplayMode sets the initial display mode.
Usage:void glutInitDisplayMode (unsigned int mode);
Mode-Display mode, normally the bitwise OR-ing of GLUT display mode bit masks.
Description:The initial display mode is used when creating top-level windows, sub windows,
and overlays to determine the OpenGL display mode for the to-be-created window or overlay.
3.glutCreateWindow(): glutCreateWindow
creates a top-level window.
Usage:intglutCreateWindow(char *name);
Name - ASCII character string for use as window name.
Description:glutCreateWindow creates a top-level window. The name will be provided to the
window system as the window's name. The intent is that thewindow system will label the
window with the name. Implicitly, the currentwindowis set to thenewly created window. Each
created window has a unique associated OpenGL context.
4.glutDisplayFunc():
glutDisplayFunc sets the display callback for the current window.
5.glutMainLoop():
glutMainLoop enters the GLUT event processing loop.
Usage:void glutMainLoop(void);
Description: glutMainLoop enters the GLUT event processing loop. This routine should be
called at most once in a GLUT program. Once called, this routine will never return. It will call as
necessary any callbacks that have been registered.
6.glMatrixMode( ):
The two most important matrices are the model-view and projection matrix. At any time, the
state includes values for both of these matrices, which are initially set to identity matrices. There
is only a single set of functions that can be applied to any type of matrix. Select the matrix to
which the operations apply by first set in the matrix mode, a variable that is set to one type of
matrix and is also part of the state.
7.glutTimerFunc();
glutTimerFunc registers a timer callback to be triggered in a specified number of milliseconds.
milliseconds. The value parameter to the timer callback will be the value of the value parameter
to glutTimerFunc. Multiple timer callbacks at same or differing times may be registered
simultaneously. The number of milliseconds is a lower bound on the time before the callback is
generated. GLUT attempts to deliver the timer callback as soon as possible after the expiration of
the callback's time interval. There is no support for canceling a registered callback. Instead,
ignore a callback based on its value parameter when it is triggered.
3.void Sun():
Basically this function is used to draw Sun on the Screen by calling circle() function and we use
glColor3f() to give color to the sun.
4.void sky():
This function is the baground for sun and cloud using glBegin(QUADS).we have done sky the
light is incidented from sun which is traversed throw sky.
5.void river():
This function is used to draw river we have used glBegin(QUADS) up on which incident
refraction takes place in river.
6.void normal():
This functions is used to draw the cloud using combinations of circle() function and is moved
using glTranslate() function.
9.fish1(),fish2(),fish3():
This functions is used to draw the fishes using the combination of gl(QUADS) and
gl(TRIANGLES), and gl(POINTS) is used to draw the eyes for the fish.
10.DrawTrees():
This function is used to draw the tree in the water, the trees is drawn using
glBegin(GL_POLYGON);
12.void fonts():
This function contains one dimensional array the content of the array is the various font styles, in
which we have specified the various font styles used to display the Strings on the screen.
13.void menu():
This function is used to display the menu content using bitmap() function.
14.void discription():
This function is used to display the Snell’s law definition using bitmap() function.
This functions specify incident and refraction display respectively in this function we have called
the used defined functions based up on the requirement.
16.void menuset():
This function is used in the Display() function to diplay the content for each frame on the screen
based up on the key pressed in the keyboard using glMatrixMode(GL_PROJECTION); and
glMatrixMode(GL_MODELVIEW); .
17.Display():
In this function we have used the flag and depending on the flag the corresponding frame is
displayed on the screen.
This function has following parameters char which represents the the character on the keyboard
depending up the character we have pressed the corresponding flag bit is enabled and the content
is displayed accordingly x and y are the pixel position.
This is the function from where the execution of the program begins.
In this function we have certain “gl” functions used to initialize the basic glut window with
desired properties. After initialization the display function is called with respect to the window
and finally the last statement of this section is the glutMainLoop(). Which is an event processing
function that enters into an infinite loop.
CHAPTER 5
SNAPSHOTS
Fig 5.1
CHAPTER 6
FUTURE ENHANCEMENT
The currently developed project can improve in many areas. Time constraint and deficient
knowledge has been a major factor in limiting the features offered by this display model.
The following features were thought a propos, but not implemented.
• More interactive feature addition.
• Implementing the project in 3D.
• Adding arc to the Car park.
• Adding score to the Car park.
• Adding more features to the Car park.
• Adding more powers to the Car park.
• Making the view for different resolution
REFERENCES
APPENDIX
#include <GL/glut.h>
#include <math.h>
#include <stdlib.h>
float theta = 0.01, fxincr = 0.1, fzincr = 0, temp, theta1, fx = -10, fz = 80;
int
a[36] = { 55,97,44,152,55,171,108,86,168,99,147,207,238,55,233,167,105,80,134,29
,253,130,32,240,110,199,224,121,93,199,180,61,110,251,77,237 };
int
b[36] = { 102,194,110,152,153,184,137,113,55,138,104,43,240,255,203,8,100,53,88,
64,127,64,87,5,2,144,211,128,10,89,27,11,175,185,157,241 };
int
c[36] = { 159,243,133,253,233,228,141,18,46,195,75,52,253,204,169,30,78,94,68,11
,4,2,33,12,2,25,195,76,26,54,98,103,205,173,65,242 };
short
h = 1;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
void drawcarr()
glEnable(GL_BLEND); //TRANCPARENCY1
glBlendFunc(GL_ONE, GL_ZERO);//TRANCPARENCY2
glBegin(GL_LINE_LOOP);
glEnd();
glBegin(GL_LINE_LOOP);
glEnd();
glBegin(GL_LINES);
glEnd();
glEnd();
glBegin(GL_POLYGON);
glEnd();
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glEnd();
glEnd();
glEnd();
glEnd();
glBegin(GL_POLYGON);//front**
glEnd();
glTranslatef(-1.68, 0.0, 0.0); //translate to 4th tyre which is behind 1st tyrerearback
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glBegin(GL_POLYGON);
glEnd();
glEnd();
glEnd();
glEnd();
glEnd();
glBegin(GL_POLYGON); //front**
glEnd();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//TRANCPARENCY3
//windscreen
glBegin(GL_POLYGON);
glEnd();
glEnd();
glEnd();
glEnd();
glEnd();
glEnd();
glEnd();
glEnd();
void drawhouse()
glBegin(GL_LINE_LOOP);
glEnd();
glBegin(GL_LINES);
glEnd();
glBegin(GL_LINE_LOOP);
glEnd();
glBegin(GL_LINES);
glEnd();
glBegin(GL_QUADS);
glEnd();
glBegin(GL_TRIANGLES);
glEnd();
glBegin(GL_QUADS);
glEnd();
glBegin(GL_QUADS);
glEnd();
GLuint createDL()
GLuint carrDL;
glEndList(); // endList
return(carrDL);
GLuint houseDL;
glEndList(); // endList
return(houseDL);
} //**************
void initScene()
glEnable(GL_DEPTH_TEST);
carr_display_list = createDL();
void renderScene(void)
int i, j;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glEnd();
glPushMatrix();
glCallList(carr_display_list);
glPopMatrix();
if (housevisible)
glPushMatrix();
glCallList(house_display_list);
glCallList(house_display_list);
glCallList(house_display_list);
glCallList(house_display_list);
glCallList(house_display_list);
glCallList(house_display_list);
glPopMatrix();
glPushMatrix();
glCallList(house_display_list);
glCallList(house_display_list);
glPopMatrix();
glPushMatrix();
glCallList(house_display_list);
glCallList(house_display_list);
glCallList(house_display_list);
glPopMatrix();
if (fxincr != 0)
theta1 = -90.0;
theta1 = -theta1;
theta1 = -theta1;
glPushMatrix();
glTranslatef(fx, 0, fz);
glRotatef(theta1, 0, 1, 0);
glCallList(carr_display_list);
glPopMatrix();
glutSwapBuffers();
lx = sin(ang);
lz = -cos(ang);
glLoadIdentity();
void moveMeFlat(int i)
if (xxxx == 1)
if (yyyy == 1)
x = x + i * (lz) * .1;
else
z = z + i * (lz) * 0.5;
x = x + i * (lx) * 0.5;
glLoadIdentity();
glLoadIdentity();
if (key == 'q')
exit(0);
if (key == 't')
if (key == 'a')
moveMeFlat(4);xxxx = 1, yyyy = 0;
if (key == 's')
moveMeFlat(-4);xxxx = 1, yyyy = 0;
if (key == 'w')
moveMeFlat(4);yyyy = 1;xxxx = 0;
if (key == 'd')
moveMeFlat(-4);yyyy = 1;xxxx = 0;
switch (key)
switch (key)
fx += fxincr;
fz += fzincr;
break;
theta);
fx += fxincr;
fz += fzincr;
break;
fz += fzincr;break;
fz -= fzincr; break;
glutPostRedisplay();
glutPostRedisplay();
switch (value)
housevisible = 1;
else
housevisible = 0;
glutPostRedisplay();
break;
glutSpecialFunc(movecar);
movecarvar = 1;
else
glutSpecialFunc(inputKey);
movecarvar = 0;
break;
void menu()
int control;
int control1;
control = glutCreateMenu(ProcessMenu);
glutAddMenuEntry("**CONTROLS**", 1);
glutAttachMenu(GLUT_RIGHT_BUTTON);
control1 = glutCreateMenu(ProcessMenu1);
glutAddMenuEntry("HOUSE", 1);
glutAttachMenu(GLUT_LEFT_BUTTON);
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(1010, 710);
glutCreateWindow("car lot");
initScene();
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(inputKey);
menu();
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);
glutReshapeFunc(changeSize);
glutMainLoop();
return(0);
A. 2 User Manual
Enter any key on the visualizer window, you will be asked for options
USN: 1DT18CS031
NAME: LEELAVATHI.B
USN:1DT19CS405