Catch Report
Catch Report
Catch Report
Chapter 1
INTRODUCTION
1.1 Computer Graphics
• Graphics provides one of the most natural means of communicating with a computer,
since our highly developed 2D Or 3D pattern-recognition abilities allow us to
perceive and process pictorial data rapidly.
• Computers have become a powerful medium for the rapid and economical production
of pictures.
• Graphics provide a so natural means of communicating with the computer that they
have become widespread.
• Interactive graphics is the most important means of producing pictures since the
invention of photography and television .
• We can make pictures of not only the real world objects but also of abstract objects
such as mathematical surfaces on 4D and of data that have no inherent geometry.
• 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.
1|Page
Downloaded from WWW.VTULOOP.COM
Catch me
OpenGL fosters innovation and speeds application development by incorporating a broad set
of rendering, texture mapping, special effects, and other powerful visualization functions.
Developers can leverage the power of OpenGL across all popular desktop and workstation
platforms, ensuring wide application deployment.
OpenGL runs on every major operating system including Mac OS, OS/2, UNIX, Windows
95/98, Windows 2000, Windows NT, Linux, Open Step, and BeOS; it also works with every
major windowing system, including Win32, MacOS, Presentation Manager, and X-Window
System. OpenGL is callable from Ada, C, C++, Fortran, Python, Perl and Java and offers
complete independence from network protocols and topologies.
Chapter 2
LITERATURE OVERVIEW
2|Page
Downloaded from WWW.VTULOOP.COM
Catch me
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 the book named Yeshwant Kanitkar.
Some concepts like constructing bowl and fountain are taken from the search results in the
codecolony.com.
Chapter 3
REQUIREMENTS AND SPECIFICATIONS
3.1 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.
3|Page
Downloaded from WWW.VTULOOP.COM
Catch me
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.
Definition
References
OpenGL tutorials
User Requirement:
• Easy to understand and should be simple.
Software Requirements:
• Ubuntu Os.
• Eclipse compiler.
Hardware Requirements:
• Processor- Intel or AMD(Advanced Micro Devices)
4|Page
Downloaded from WWW.VTULOOP.COM
Catch me
• RAM- 512MB(minimum)
• Hard Disk-1MB(minimum)
• Mouse
• Keyboard
• Monitor
Chapter 4
DESIGN
4.1 User Defined Functions
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():
5|Page
Downloaded from WWW.VTULOOP.COM
Catch me
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.
Chapter 5
IMPLEMENTATION
5.1 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.
6|Page
Downloaded from WWW.VTULOOP.COM
Catch me
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.
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
7|Page
Downloaded from WWW.VTULOOP.COM
Catch me
glLoadIdentity Function
The glLoadIdentity function replaces the current matrix with the identity matrix.
SYNTAX:
void glLoadIdentity(void);
glOrtho
This function defines orthographic viewing volume with all parameters measured from the
centre of projection.
SYNTAX:
void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble near, GLdouble far)
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.
8|Page
Downloaded from WWW.VTULOOP.COM
Catch me
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));
5.4MAIN FUNCTION
SYNTAX:
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
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:
glutMainLoop Function
glutMainLoop enters the GLUT event processing loop.
SYNTAX:
void glutMainLoop(void);
Chapter-6
APPENDIX -A
SOURCE CODE
#include<GL/glut.h>
#include<stdlib.h>
#include<string.h>
void controls1();
void startmenu();
void aboutf(); void
lev();
void over();
char control2[200]="YOU HAVE TO 'CATCH' THAT OBJECT BY CLICKING LEFT BUTTON OF THE
MOUSE ON THAT OBJECT.";
char control3[200]="THERE WILL BE TEN CHANCES AND EACH CHANCE CARRIES 10 POINTS.";
char control4[200]="AND YOU CAN CHOOSE DIFFERENT LEVELS IN THE GAME."; char
control5[200]="press '1' to START GAME and '3' to go 'ABOUT GAME' or LEFT CLICK to go
back.";
char control6[100]="********** ALL THE BEST **********";
char about1[100]="WELL, THE GAME NAME IS 'CATCH ME IF U CAN!!!'."; char
about2[100]="THIS GAME IS DEVELOPED BY DHEERAJ KUMAR & JIV RAJANI VAIBHAV "; char
about3[100]="FROM 6TH SEM CS USING OPENGL AS PART OF MINIPROJECT."; char
10 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
about4[100]="press '1' to START GAME or '2' to go 'HOW TO PLAY GAME' or LEFT CLICK to go
back.";
char lev1[100]="CHOOSE THE LEVEL U WANT TO PLAY...";
char lev2[100]="a: EASY"; char lev3[100]="b: MEDIUM"; char
lev4[100]="c: HARD";
char lev5[100]="LEFT CLICK to go back."; char
over1[100]="GAME OVER!!!"; char well[100]="WELL
DONE!!!"; char yourscore[100]="YOUR SCORE IS:"; char
hardluck[100]="WELL, HARD LUCK, TRY AGAIN...";
char hundred[100]="100";
char max[100]="(please maximise the window before u start the game..)"; char
key1;
char sco[10]="SCORE:"; int
score=0,rem,vs1=0,vs2=0;
int yy1=660,yy2=750;
int level1=0,level2=0,level3=0;
struct lag
{
float x1,x2,y1,y2;
float color;
}o;
void mypos()
{
o.x1=90;
o.y1=100;
o.x2=o.x1+40;
o.y2=o.y1+40;
}
void initfun()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); gluOrtho2D(0,1280,0,1024);
mypos();
}
void moveRight()
{
if(level1==0&&level2==0&&level3==0) v=5;
if(level1==1)
v=5;
else if(level2==1)
v=10;
else if(level3==1)
v=15;
o.x1=o.x1+v;
o.y1=o.y1;
o.x2=o.x1+40;
o.y2=o.y1+40;
glutPostRedisplay();
}
void randomGenerate()
11 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
f++;
if(f<10)
{
int num=rand()%620;
if(num<90) num=num+100;
o.x1=90;
o.y1=num;
o.x2=o.x1+40;
o.y2=o.y1+40;
hitFlag=0;
glutPostRedisplay();
}
else
over();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
if(startFlag==0)
{
glColor3f(1,1,1);
glRectf(0,0,800,600); glColor3f(0,0,0);
glRectf(10,10,1270,1014);
glColor3f(0.6,0.7,0.8);
glRasterPos2f(300,900);
for(w=0;w<sizeof(wel);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,wel[w]);
glRasterPos2f(250,850);
for(w=0;w<sizeof(max);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,max[w]);
glColor3f(0.5,0.1,0.7);
glRasterPos2f(200,700);
for(w=0;w<sizeof(start);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,start[w]);
glColor3f(0.7,0.8,0.9);
glRasterPos2f(200,600);
for(w=0;w<sizeof(controls);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,controls[w]);
glColor3f(0.2,0.5,0.7);
glRasterPos2f(200,500);
for(w=0;w<sizeof(levels);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,levels[w]);
glColor3f(1.0,0.8,0.3);
glRasterPos2f(200,400);
for(w=0;w<sizeof(about);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,about[w]);
12 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
glFlush();
}
if(controlsFlag==1)
//to go controls window
{
controls1();
}
if(aboutFlag==1)
//to go about game window
{
aboutf();
}
if(levFlag==1)
{
lev();
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,1280,0,1024);
glColor3f(1.0,100.0/256.0, 0.0);
glRectf(0,0,1280,1024);
glColor3f(220.0/256,150.0/256.0,0); //b1
glRectf(50,50,880,700);
glColor3f(0,100.0/256.0,0); //b2
glRectf(70,70,860,680);
glColor3f(0,0,0); //b3
glRectf(90,90,840,660);
vs2=score%10;
vs1=score/10;
glRasterPos2f(100,800);
for(i=0;i<sizeof(sco);i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,sco[i]);
glRasterPos2f(170,800);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,vs1+48);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,vs2+48);
if(hitFlag==0)
{
glColor3f(1.0,1.0,1.0); //object;
glRectf(o.x1,o.y1,o.x2,o.y2);
glFlush();
if(o.x2<=840)
moveRight();
if(o.x2>840)
randomGenerate();
13 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
glFlush();
glColor3f(0,0,1);
glPointSize(5);
glBegin(GL_POINTS);
glVertex2f(x,y); glEnd();
if(hitFlag==1)
{
hitFlag=0;
glColor4f(1.0,1.0,1.0,1.0);
char b[20]={"hit..."},c[20]={"lost.."};
glRasterPos2f(o.x1,o.y1);
if(messageTrue==1)
{
score+=10;
for(int i=0;i<7;i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,b[i]);
/*while(score!=0)
{
rem=score%10;
glColor3f(0,0,0);
glRasterPos2f(100,800);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,48+rem);
score=score/10;
}*/
glFlush();
}
for(int t=0;t<1000;t++)
for(int h=0;h<1000;h++)
for(int y=0;y<100;y++)
{}
randomGenerate();
}
}
glFlush();
}
void over()
{
overFlag=0;
glColor3f(0.56,0.40,0.8);
glRectf(0,0,1280,1024);
glColor3f(0.0,0.0,0.0);
glRasterPos2f(500,700);
for(w=0;w<sizeof(over1);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,over1[w]);
14 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
if(score==100)
{
glRasterPos2f(400,600);
for(i=0;i<sizeof(well);i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,well[i]);
glRasterPos2f(400,400);
for(i=0;i<sizeof(yourscore);i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,yourscore[i]);
glRasterPos2f(570,400);
for(i=0;i<sizeof(hundred);i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,hundred[i]);
}
else
{
glRasterPos2f(400,600);
for(i=0;i<sizeof(yourscore);i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,yourscore[i]);
glRasterPos2f(570,600);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,vs1+48);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,vs2+48);
if(score==0)
{
glRasterPos2f(570,500);
for(i=0;i<sizeof(hardluck);i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,hardluck[i]);
}
}
glFlush();
for(i=0;i<50000;i++)
for(j=0;j<50000;j++)
//for(k=0;k<1000;k++)
{}
exit(1);
}
glColor3f(0.3,0.45,0.76);
glRectf(20,20,1260,1004);
glColor3f(0.0,0.0,0.0);
glRasterPos2f(100,800);
for(w=0;w<sizeof(control1);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,control1[w]);
glRasterPos2f(90,700);
for(w=0;w<sizeof(control2);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,control2[w]);
glRasterPos2f(100,600);
for(w=0;w<sizeof(control3);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,control3[w]);
15 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
glRasterPos2f(100,500);
for(w=0;w<sizeof(control4);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,control4[w]);
glRasterPos2f(100,400);
for(w=0;w<sizeof(control5);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,control5[w]);
glRasterPos2f(200,300);
for(w=0;w<sizeof(control6);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,control6[w]);
controlsFlag=0;
glFlush();
}
void aboutf()
//function for about game
{
glColor3f(1.0,0.40,1.0);
glRectf(0,0,1280,1024);
glColor3f(0.7,0.45,0.36);
glRectf(20,20,1260,1004);
glColor3f(0.0,0.0,0.0);
glRasterPos2f(100,800);
for(w=0;w<sizeof(about1);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,about1[w]);
glRasterPos2f(100,700);
for(w=0;w<sizeof(about2);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,about2[w]);
glRasterPos2f(100,600);
for(w=0;w<sizeof(about3);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,about3[w]);
glRasterPos2f(100,500);
for(w=0;w<sizeof(about4);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,about4[w]);
aboutFlag=0;
glFlush();
}
void startmenu()
{
if(dirFlag==1)
{
dirFlag=0;upFlag=0;
yy1-=100;
yy2-=100;
glColor3f(0.6,0.7,0.8);
glRasterPos2f(300,900);
for(w=0;w<sizeof(wel);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,wel[w]);
16 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
glRasterPos2f(250,850);
for(w=0;w<sizeof(max);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,max[w]);
glColor3f(0.5,0.1,0.7);
glRasterPos2f(200,700);
for(w=0;w<sizeof(start);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,start[w]);
glColor3f(0.7,0.8,0.9); glRasterPos2f(200,600);
for(w=0;w<sizeof(controls);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,controls[w]);
glColor3f(0.2,0.5,0.7);
glRasterPos2f(200,500);
for(w=0;w<sizeof(levels);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,levels[w]);
glColor3f(1.0,0.8,0.3); glRasterPos2f(200,400);
for(w=0;w<sizeof(about);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,about[w]);
glFlush();
if(upFlag==1)
{
upFlag=0;dirFlag=0;
yy1+=100;
yy2+=100;
glColor3f(0.6,0.7,0.8);
glRasterPos2f(300,900);
for(w=0;w<sizeof(wel);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,wel[w]);
glColor3f(0.5,0.1,0.7);
glRasterPos2f(200,700);
for(w=0;w<sizeof(start);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,start[w]);
glColor3f(0.7,0.8,0.9);
glRasterPos2f(200,600);
for(w=0;w<sizeof(controls);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,controls[w]);
glColor3f(0.2,0.5,0.7);
glRasterPos2f(200,500);
for(w=0;w<sizeof(levels);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,levels[w]);
glColor3f(1.0,0.8,0.3);
glRasterPos2f(200,400);
for(w=0;w<sizeof(about);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,about[w]);
17 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
glFlush();
}
void lev()
{
glColor3f(0.5,0.5,0.5);
glRectf(0,0,1280,1024);
glColor3f(0,0,0);
glRasterPos2f(300,800); for(w=0;w<sizeof(lev1);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,lev1[w]);
glRasterPos2f(300,700);
for(w=0;w<sizeof(lev2);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,lev2[
w]);
glRasterPos2f(300,600);
for(w=0;w<sizeof(lev3);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,lev3[w]);
glRasterPos2f(300,400);
for(w=0;w<sizeof(lev5);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,lev5[w]);
glRasterPos2f(300,500);
for(w=0;w<sizeof(lev4);w++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,lev4[w]);
levFlag=0;
glFlush();
}
glutPostRedisplay();
18 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
x=mx;
y=wwh-my;
glutPostRedisplay();
}
void reshape(int ww,int wh)
{
wwh=wh;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,ww,0,wh); mypos();
}
initfun();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
19 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
20 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
21 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
22 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
Chapter-8
Conclusion
The project was started with the designing phase in which I figured the requirements needed,
the layout design, then comes the detail designing of each function after which, was the
testing and debugging stage.
We have tried to implement the project making it as user-friendly and error free as possible.
We regret any errors that may have inadvertently crept in.
23 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
BIBLIOGRAPHY
24 | P a g e
Downloaded from WWW.VTULOOP.COM
Catch me
25 | P a g e
Downloaded from WWW.VTULOOP.COM