Opengl Project
Opengl Project
HAWK-EYE
Submitted in partial fulfillment of requirements
of
VI semester, Computer
Science
Submitted by:
PAVAN S (1DB06CS033)
&
GURU PRASAD P (1DB06CS015)
Ms. Hemapriya
Lecturer, Dept of CSE
DBIT
CERTIFICATE
This is to certify that PAVAN S(1DB06CS033) and GURU PRASAD P(1DB06CS015) have
successfully completed the project work on ‘HAWK-EYE’ and submitted in partial
fulfillment of the requirements of 6 semester B.E., Computer Science and Engineering,
prescribed by the VISVESVARAYA TECHNOLOGICAL UNIVERSITY during the
academic year 2006-2007.
Signature of examiners:
1……………………..
2……………………..
sincere thanks to Prof. Mr.Murulidhar the principal of our institution for having
our project.
PAVAN.S
GURU PRASAD.P
1. Introduction
2. Requirement Specifications
3. System Design
3.1 Algorithms
3.2 Modules and their descriptions
4.2.1 Inbuilt Functions
4.2.2 User defined functions
3.3 Source code
4.Conclusion
5.Bibliography
It provide a tool for producing pictures not only of concrete, ”real-world” objects but
also of abstract ,synthesis of objects.
• It as an ability to show moving pictures, and thus it is possible to produce animations.
• With the use of interactive graphics we can control the movement of an object. The
interactive graphics provides tool called motion dynamics. With this tool user can
move and tumble objects with respect to stationary observer, or he can make object
stationary and the viewer moving around them.
• Interactive graphics provides facility called update dynamics.
• With the recent development of digital signal processing (DSP) and audio synthesis
chip the interactive graphics can now provide audio feed back along with the
graphical feed backs to make the simulated environment even more realistic
• User interfaces
• Plotting of graphs and charts
• Office automation and Desktop publishing
• Computer aided Drafting and designs
• Process control
• Cartography
2D TRANSFORMATIONS [Translation]
• glClearColor()
• glClear()
• glPushMatrix()
• glTranslatef()
• glColor3f()
• glPopMatrix()
• glutSwapBuffers()
• glLoadIdentity()
• glRasterPos2f()
• glutBitmapCharacter()
• glutPostRedisplay()
• glOrtho2D()
• glutInit()
• glutInitDisplayMode()
• Sprint()
• display()
• spindisplay()
• spindisplayy()
We have used the function Sprint() to print the message the display using
bitmap characters.
#include<GL/glut.h>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int l,i;
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,
st[i]); // Print a character on the screen
void display()
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex2f(20.0,1.0);
glVertex2f(10.0,50.0);
glVertex2f(10.0,50.0);
glVertex2f(1.0,200.0);
glVertex2f(1.0,200.0);
glVertex2f(1.0,350.0);
glVertex2f(1.0,350.0);
glVertex2f(10.0,475.0);
glVertex2f(30.0,525.0);
glVertex2f(30.0,525.0);
glVertex2f(70.0,525.0);
glVertex2f(70.0,525.0);
glVertex2f(85.0,475.0);
glVertex2f(85.0,475.0);
glVertex2f(95.0,350.0);
glVertex2f(95.0,350.0);
glVertex2f(95.0,100.0);
glVertex2f(95.0,100.0);
glVertex2f(85.0,1.0);
glVertex2f(85.0,1.0);
glVertex2f(20.0,1.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(10.0,475.0);
glVertex2f(1.0,350.0);
glVertex2f(95.0,350.0);
glVertex2f(85.0,475.0);
glEnd();
glColor3f(0.0,0.7,0.0);
glBegin(GL_POLYGON);
glVertex2f(10.0,50.0);
glVertex2f(3.0,175.0);
glVertex2f(95.0,175.0);
glVertex2f(95.0,100.0);
glVertex2f(90.0,50.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(10.0,475.0);
glVertex2f(30.0,525.0);
glVertex2f(30.0,1.0);
glVertex2f(20.0,1.0);
glVertex2f(10.0,50.0);
glEnd();
glColor3f(0.0,0.6,0.0);
glBegin(GL_POLYGON);
glVertex2f(10.0,50.0);
glVertex2f(30.0,50.0);
glVertex2f(30.0,175.0);
glVertex2f(10.0,175.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(10.0,475.0);
glVertex2f(30.0,475.0);
glVertex2f(30.0,350.0);
glVertex2f(10.0,350.0);
glEnd();
glColor3f(0.0,0.7,0.0);
glBegin(GL_POLYGON);
glVertex2f(65.0,525.0);
glVertex2f(70.0,525.0);
glVertex2f(85.0,475.0);
glVertex2f(85.0,1.0);
glVertex2f(65.0,1.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(65.0,475.0);
glVertex2f(85.0,475.0);
glVertex2f(85.0,350.0);
glVertex2f(65.0,350.0);
glEnd();
glColor3f(0.0,0.6,0.0);
glBegin(GL_POLYGON);
glVertex2f(65.0,50.0);
glVertex2f(85.0,50.0);
glVertex2f(85.0,175.0);
glVertex2f(65.0,175.0);
glEnd();
glColor3f(0.5,0.7,0.0);
glVertex3f(45.0,405.0,0.0);
glVertex3f(45.0,132.0,0.0);
glVertex3f(55.0,132.0,0.0);
glVertex3f(55.0,405.0,0.0);
glEnd();
glColor3f(1.5,1.5,0.0);
glBegin(GL_POLYGON);
glVertex2f(49.0,187.0);
glVertex2f(51.0,187.0);
glVertex2f(51.0,370.0);
glVertex2f(49.0,370.0);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINES);
glVertex2f(60.0,350.0);
glVertex2f(40.0,187.0);
glVertex2f(60.0,187.0);
glVertex2f(45.0,370.0);
glVertex2f(55.0,370.0);
glVertex2f(45.0,157.0);
glVertex2f(55.0,157.0);
glVertex2f(45.0,405.0);
glVertex2f(45.0,350.0);
glVertex2f(55.0,405.0);
glVertex2f(55.0,350.0);
glVertex2f(45.0,132.0);
glVertex2f(45.0,187.0);
glVertex2f(55.0,132.0);
glVertex2f(55.0,187.0);
glEnd();
glBegin(GL_LINES);
//FIRST WICKET
glColor3f(0.9,0.9,0.9);
glVertex2f(51.0,410.0);
glVertex2f(51.0,370.0);
glColor3f(0.0,0.0,0.0);
glVertex2f(51.0,370.0);
glVertex2f(49.0,390.0);
//SECOND WICKET
glColor3f(0.9,0.9,0.9);
glVertex2f(50.0,410.0);
glVertex2f(50.0,370.0);
glColor3f(0.0,0.0,0.0);
glVertex2f(50.0,370.0);
glVertex2f(48.0,390.0);
//THIRD WICKET
glVertex2f(49.0,410.0);
glVertex2f(49.0,370.0);
glColor3f(0.0,0.0,0.0);
glVertex2f(49.0,370.0);
glVertex2f(47.0,390.0);
glEnd();
glBegin(GL_LINES);
//FIRST WICKET
glColor3f(0.9,0.9,0.9);
glVertex2f(51.0,157.0);
glVertex2f(51.0,197.0);
glColor3f(0.0,0.0,0.0);
glVertex2f(51.0,157.0);
glVertex2f(49.0,177.0);
//SECOND WICKET
glVertex2f(50.0,157.0);
glVertex2f(50.0,197.0);
glColor3f(0.0,0.0,0.0);
glVertex2f(50.0,157.0);
glVertex2f(48.0,177.0);
//THIRD WICKET
glColor3f(0.9,0.9,0.9);
glVertex2f(49.0,157.0);
glVertex2f(49.0,197.0);
glColor3f(0.0,0.0,0.0);
glVertex2f(49.0,157.0);
glVertex2f(47.0,177.0);
glEnd();
glColor3f(1.0,1.0,1.0);
glLineWidth(1.0);
glVertex2f(49.0,197.0);
glVertex2f(49.2,197.0);
glEnd();
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex2f(49.2,197.0);
glVertex2f(49.8,197.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(49.8,197.0);
glVertex2f(50.0,197.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(50.0,197.0);
glEnd();
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex2f(50.2,197.0);
glVertex2f(50.8,197.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(50.8,197.0);
glVertex2f(51.0,197.0);
glEnd();
if(bail==1.0)
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(49.0,410.0);
glEnd();
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex2f(49.2,410.0);
glVertex2f(49.8,410.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(49.8,410.0);
glVertex2f(50.0,410.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(50.0,410.0);
glVertex2f(50.2,410.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(50.2,410.0);
glVertex2f(50.8,410.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(50.8,410.0);
glVertex2f(51.0,410.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(47.0,177.0);
glVertex2f(47.2,177.0);
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex2f(47.2,177.0);
glVertex2f(47.8,177.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(47.8,177.0);
glVertex2f(48.0,177.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(48.0,177.0);
glVertex2f(48.2,177.0);
glEnd();
glLineWidth(5.0);
glVertex2f(48.2,177.0);
glVertex2f(48.8,177.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(48.8,177.0);
glVertex2f(49.0,177.0);
glEnd();
if(bail==1.0)
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(47.0,390.0);
glVertex2f(47.2,390.0);
glEnd();
glLineWidth(5.0);
glVertex2f(47.2,390.0);
glVertex2f(47.8,390.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(47.8,390.0);
glVertex2f(48.0,390.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(48.0,390.0);
glVertex2f(48.2,390.0);
glEnd();
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex2f(48.2,390.0);
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
glVertex2f(48.8,390.0);
glVertex2f(49.0,390.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(1.0,350.0);
glVertex2f(0.0,410.0);
glVertex2f(10.0,550.0);
glVertex2f(10.0,475.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1.0,350.0);
glVertex2f(10.0,475.0);
glVertex2f(10.0,525.0);
glVertex2f(1.0,400.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(10.0,475.0);
glVertex2f(10.0,550.0);
glVertex2f(30.0,550.0);
glEnd();
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(10.0,475.0);
glVertex2f(30.0,550.0);
glVertex2f(10.0,525.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(70.0,550.0);
glVertex2f(85.0,540.0);
glVertex2f(85.0,525.0);
glEnd();
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(70.0,525.0);
glVertex2f(70.0,555.0);
glVertex2f(85.0,525.0);
glVertex2f(85.0,475.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(85.0,525.0);
glVertex2f(85.0,540.0);
glVertex2f(95.0,425.0);
glVertex2f(95.0,350.0);
glEnd();
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(85.0,525.0);
glVertex2f(85.0,475.0);
glVertex2f(95.0,350.0);
glVertex2f(95.0,400.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(30.0,550.0);
glVertex2f(70.0,550.0);
glVertex2f(70.0,525.0);
glVertex2f(30.0,525.0);
glEnd();
glColor3f(0.0,0.0,1.0);
glColor3f(1.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(95.0,350.0);
glVertex2f(95.0,435.0);
glVertex2f(98.0,150.0);
glVertex2f(95.0,100.0);
glEnd();
glColor3f(1.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(1.0,350.0);
glVertex2f(0.0,400.0);
glVertex2f(0.0,200.0);
glVertex2f(1.0,200.0);
glEnd();
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(0.0,200.0);
glVertex2f(1.0,200.0);
glVertex2f(10.0,50.0);
glVertex2f(6.0,80.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(10.0,50.0);
glVertex2f(6.0,80.0);
glVertex2f(15.0,10.0);
glVertex2f(20.0,0.0);
glEnd();
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(95.0,100.0);
glVertex2f(85.0,1.0);
glVertex2f(90.0,30.0);
glVertex2f(98.0,150.0);
glEnd();
glColor3f(0.0,0.5,0.0);
glBegin(GL_LINES);
glVertex2f(10.0,230.0);
glVertex2f(10.0,280.0);
glVertex2f(10.0,280.0);
glVertex2f(11.0,300.0);
glVertex2f(11.0,300.0);
glVertex2f(15.0,300.0);
glVertex2f(15.0,300.0);
glVertex2f(15.0,290.0);
glVertex2f(10.0,230.0);
glVertex2f(11.0,210.0);
glVertex2f(11.0,210.0);
glVertex2f(15.0,210.0);
glVertex2f(15.0,210.0);
glVertex2f(15.0,245.0);
glVertex2f(15.0,245.0);
glVertex2f(17.0,210.0);
glVertex2f(17.0,300.0);
glVertex2f(20.0,300.0);
glVertex2f(20.0,210.0);
glVertex2f(17.0,210.0);
glVertex2f(20.0,210.0);
glVertex2f(22.0,208.0);
glVertex2f(22.0,300.0);
glVertex2f(22.0,300.0);
glVertex2f(25.0,300.0);
glVertex2f(25.0,300.0);
glVertex2f(25.0,250.0);
glVertex2f(25.0,250.0);
glVertex2f(22.0,250.0);
glVertex2f(23.0,250.0);
glVertex2f(25.0,208.0);
glVertex2f(27.0,300.0);
glVertex2f(27.0,210.0);
glVertex2f(30.0,210.0);
glVertex2f(30.0,210.0);
glVertex2f(30.0,300.0);
glEnd();
//MESSAGE DISPLAY
glColor3f(0.0,0.0,0.0);
glColor3f(0.0,0.5,0.0);
glLineWidth(10.0);
glBegin(GL_LINES);
glVertex2f(66.0,208.0);
glVertex2f(66.0,300.0);
glVertex2f(69.3,300.0);
glVertex2f(69.3,300.0);
glVertex2f(69.3,250.0);
glVertex2f(69.3,250.0);
glVertex2f(66.0,250.0);
glVertex2f(70.0,208.0);
glVertex2f(72.0,303.0);
glVertex2f(72.0,303.0);
glVertex2f(74.0,208.0);
glVertex2f(71.0,245.0);
glVertex2f(73.0,245.0);
glVertex2f(74.0,300.0);
glVertex2f(76.0,208.0);
glVertex2f(76.0,208.0);
glVertex2f(78.0,300.0);
glVertex2f(80.0,303.0);
glVertex2f(80.0,303.0);
glVertex2f(82.0,208.0);
glVertex2f(79.0,245.0);
glVertex2f(81.0,245.0);
glVertex2f(83.0,208.0);
glVertex2f(83.0,303.0);
glVertex2f(83.0,303.0);
glVertex2f(86.0,208.0);
glVertex2f(86.0,208.0);
glVertex2f(86.0,303.0);
glEnd();
if(ball==1.0)
glPushMatrix();
glColor3f(1.0,0.0,0.0);
glutSolidSphere(1.00000,400,421);//ball
glPopMatrix();
glutSwapBuffers();
glFlush();
void spindisplay()
spin=spin+0.04;
spin1=spin1+1.0;
glutPostRedisplay();
void spindisplayy()
ball=0.0;
if(spinx>=49.0&&spinx<=51.0)
glColor3f(0.0,0.0,0.0);
Sprint(53,310,"pitched inside");
else
glColor3f(0.0,0.0,0.0);
Sprint(30,260,"pitched outside");
glPushMatrix();
glTranslatef(spinx,spiny,-15.0);
glColor3f(1.0,0.0,0.0);
glutSolidSphere(1.00000,400,421);
glutSwapBuffers();
spiny=spiny+0.5;
if(spinx>=49.0&&spinx<=51.0&&spiny>=410.0)
glutPostRedisplay();
switch(button)
case GLUT_LEFT_BUTTON:
if(state==GLUT_DOWN)
break;
case GLUT_MIDDLE_BUTTON:
if(state==GLUT_DOWN)
glutIdleFunc(NULL);
break;
case GLUT_RIGHT_BUTTON:
if(state==GLUT_DOWN)
glutIdleFunc(spindisplayy);
break;
default:
break;
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(30,30);
glutCreateWindow("ppp");
glClearColor(0.0,0.6,0.0,0.0);
glOrtho(0.0,100.0,0.0,550.0,-15.0,50.0);
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
return(0);
5. BIBILOGRAPHY
Books referred
• Interactive Computer graphics A Top Down Approach with OpenGL-Edward
Angel,5th Editon, Addison Wesley,2008.
** OpenGL programming guide. The official guide to learning OpenGL Version 2.1. 6th
edition (2007).