Catch Report
Catch Report
Chapter 1
INTRODUCTION
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
Dept. of CSE,CEC 2010-2011
Catch me if you Can
OpenGL is the premier environment for developing portable, interactive 2D and 3D graphics
applications. Since its introduction in 1992, OpenGL has become the industry's most widely
used and supported 2D and 3D graphics application programming interface (API), bringing
thousands of applications to a wide variety of computer platforms.
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.
2
Dept. of CSE,CEC 2010-2011
Catch me if you Can
Chapter 2
LITERATURE OVERVIEW
The basic functions like glcolor3f(…..); glrotatef(…..); gltranslate(…..) etc. that are most commoly
Used in the code are taken form the prescribed VTU text book “INTERACTIVE COMPUTER
GRAPHICS” 5th edition by Edward Angel.[1].
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.
3
Dept. of CSE,CEC 2010-2011
Catch me if you Can
Chapter 3
It should give details of how to maintain, test, verify and what all the actions to be carried out
through life cycle of project.
Definition
References
OpenGL tutorials
4
Dept. of CSE,CEC 2010-2011
Catch me if you Can
User Requirement:
Software Requirements:
Ubuntu Os.
Eclipse compiler.
Hardware Requirements:
RAM- 512MB(minimum)
Hard Disk-1MB(minimum)
Mouse
Keyboard
Monitor
5
Dept. of CSE,CEC 2010-2011
Catch me if you Can
Chapter 4
DESIGN
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():
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.
6
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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
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:
7
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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
GL_MODELVIEW Applies subsequent matrix operations to the
modelview matrix stack.
glLoadIdentity Function
The glLoadIdentity function replaces the current matrix with the identity matrix.
SYNTAX:
void glLoadIdentity(void);
8
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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.
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));
9
Dept. of CSE,CEC 2010-2011
Catch me if you Can
5.4MAIN FUNCTION
glutInit Function
glutInit is used to initialize the GLUT library.
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);
10
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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();
int x,y,w,f=0,i,j,k,v,wwh=1024;
int
hitFlag=0,messageTrue=0,startFlag=0,backFlag=0,controlsFlag=0,aboutFlag=0,dirFlag=0,upFlag=0,o
verFlag=0,levFlag;
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 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()
{
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;
12
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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]);
glFlush();
}
if(controlsFlag==1)
//to go controls window
{
controls1();
}
if(aboutFlag==1)
//to go about game window
{
aboutf();
13
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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();
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);
14
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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]);
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
{
15
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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]);
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();
}
16
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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]);
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]);
17
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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]);
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++)
18
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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();
}
x=mx;
y=wwh-my;
glutPostRedisplay();
}
void reshape(int ww,int wh)
{
wwh=wh;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,ww,0,wh);
19
Dept. of CSE,CEC 2010-2011
Catch me if you Can
mypos();
}
initfun();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
20
Dept. of CSE,CEC 2010-2011
Catch me if you Can
Chapter-7
SNAP SHOTS
21
Dept. of CSE,CEC 2010-2011
Catch me if you Can
22
Dept. of CSE,CEC 2010-2011
Catch me if you Can
23
Dept. of CSE,CEC 2010-2011
Catch me if you Can
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.
24
Dept. of CSE,CEC 2010-2011
Catch me if you Can
BIBLIOGRAPHY
25
Dept. of CSE,CEC 2010-2011
Catch me if you Can
26
Dept. of CSE,CEC 2010-2011