1. P a g e | 1
Dept .of Computer science & engineering UBDTCE
Serial no. CONTENTS Page no.
Acknowledgement 2
1.
1.1
1.2
1.3
Project Description
3Purpose
Scope
Objects used
2.
2.1
Introduction to Graphics
4
Introduction to OpenGL
3. Requirements 5
4. Implementation 6-11
5. Snapshots 12-15
6. Conclusion 16
2. P a g e | 2
Dept .of Computer science & engineering UBDTCE
ACKNOWLEDGEMENT
The satisfaction that accompanies the successful completion of any task
would be incomplete without mentioning the people who made it possible,
whose constant guidance and encouragement crowned my effort with success.
First and foremost, I would like to express our sincere words of gratitude
and respect to the organization “University B.D.T. COLLEGE OF
ENGINEERING, DAVANGERE” for providing us an opportunity to carry out
my project work.
I thank the principal, Dr.Shivaprasad B Dandegi, U.B.D.T. College of
Engineering, for providing us with all the facilities that helped us to carry out
the work easily.
I would like to express my deepest thanks to Dr. K S Shreedhara , PhD
in DOS, H.O.D, Department of Computer Science & Engineering, for his
encouragement.
I am very grateful to our guide Srinivas Naik C L Professor, Department of
Computer Science & Engineering, for their insightful comments and for sharing
with us his knowledge and experience. I really appreciate his help to improve
the quality of my report.
Last but not the least; I extend my thanks to all the people in the department of
Computer Science & Engineering, for always being helpful over the years. I am
very grateful to my parents and well wishers for their continuous moral support
and encouragement.
3. P a g e | 3
Dept .of Computer science & engineering UBDTCE
AIM:-
Program to display The Rotating effect on TEAPOT by using Keyboard
and Mouse.
1. PROJECT DESCRIPTION:-
The example program provides a simple application of the Rotate
primitives of OpenGL. The graphics image consists of TEAPOT.
1.1 PURPOSE:-
The purpose of this document is to explain the functionality of Rotating
in OpenGL, the study of requirement specification is focused specifically on
functioning, it allows the developer or analyst to understand the Rotation
options in OpenGL system.
1.2 SCOPE:-
This project used to understand and modified the developed Rotation
system without much complication. Hence it can be used for better convenience
and learning without any bearing effect on the system or the data contained in it.
The project helps in understanding true Rotating in graphics
1.3 OBJECT USED:-
1) Rotation
2) Display list
3) GLUT manage windows call back
4) Mouse and Keyboard to simulate rotation of Teapot .
4. P a g e | 4
Dept .of Computer science & engineering UBDTCE
2.INTRODUCTION TO GRAPHICS
Graphics provides one of the most natural means of communicating with a
computer, since our highly developed 2D and 3D pattern-recognition abilities
allows us to perceive and process pictorial data rapidly and a efficiently.
Interactive computer graphics is the most important means of producing
pictures since the invention of photography and television. It has the added
advantage that, with the computer, we can pictures not only of concrete real
world objects but also of abstract, synthetic objects, such as mathematical
surfaces and of data that have no inherent geometry, such as survey results.
Pictorial synthesis of real/imaginary objects from computer based
models is computer graphics. 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 wide spread. Today, we find computer graphics
used routinely in such diverse areas such as science, engineering, medicine,
business, industry, government, art, entertainment, advertising, education and
training.
Because of the wide use of computer graphics in all the fields, we developed a
game to exploit all the features of graphics and understand it in a better way.
Here we have attempted to design a game which we have named Lighting
Spheres, incorporating as many features of a simple lighting as possible and
adding a few of our own using the algorithms and skills that we have learnt in
class. It is our first insight into the vast world of interactive graphics.
2.1 INTRODUCTION TO OPENGL
OpenGL is a software interface to graphics hardware. This interface consists of
about 120 distinct commands, which you use to specify the objects and
operations needed to produce interactive three dimensional applications.
OpenGL is designed to work efficiently even if the computer displays the
graphics you create is not the computer that runs your graphics program. This
5. P a g e | 5
Dept .of Computer science & engineering UBDTCE
might be the case if you work in a networked computer environment where
many computers are connected to one another by wires cable of carrying digital
data.
3. REQUIREMENTS
REQUIREMANT SPECIFICATION:-
The hardware and software requirement for the efficient working of our project
are specified as follows:
3.1Hardware specification:-
Pentium 3 processor.
Standard QWERTY serial or PS/2 keyboard.
AT&T Compatible mouse.
Processor speed of 300MHz and above.
128Mb of RAM.
200Mb of minimum disk space.
VGA 256 color video with min 16bit color qualitity.
3.2 Software specification:-
Windows XP operating system.
A visual C++ compiler [Microsoft Visual Studio].
OpenGL libraries- gl, glut, OpenGL and glaux
6. P a g e | 6
Dept .of Computer science & engineering UBDTCE
4. IMPLEMENTATION
#include<GLUT/glut.h>
#include<gl.h>
#include<glut.h>
#include<stdlib.h>
void wall(double thickness)
{
//draw thin wall with top=xz-plane,corner at orgine
glPushMatrix();
glTranslated(0.5,0.5*thickness,0.5);
glScaled(1.0,thickness,1.0);
glutSolidCube(1.0);
glPopMatrix();
}
//draw one table leg
voidtableleg(double thick,doublelen)
{
glPushMatrix();
glTranslated(0,len/2,0);
glScaled(thick,len,thick);
glutSolidCube(1.0);
glPopMatrix();
}
11. P a g e | 11
Dept .of Computer science & engineering UBDTCE
}
int w=900,h=600;
void main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(w,h);
glutInitWindowPosition(300,50);
glutCreateWindow("TEAPOT PRAGRAM");
glutDisplayFunc(displaysolid);
glutMouseFunc(mouse);
glutKeyboardFunc(keys);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glClearColor(0.5,0.3,0.2,1.0);
glViewport(0,0,w,h);
glutMainLoop();
}
12. P a g e | 12
Dept .of Computer science & engineering UBDTCE
5.SNAPSHOTS
Fig5.1:Default view of object when it is executed
When the program is executed, the object is viewed as shown in fig 5.1.
13. P a g e | 13
Dept .of Computer science & engineering UBDTCE
Fig5.2:Perspective view of camera along X-axis.
This object is obtained by interfacing keyboard function keys to, which gives a perspective
view along X-axis as shown in fig 5.2.
Using ‘x’ and ‘a’ key the camera can be viewed along X-axis, if we consider ‘a’ key to
view camera along positive X-axis then ‘x’ key is used to camera along negative X-axis
14. P a g e | 14
Dept .of Computer science & engineering UBDTCE
Fig5.3:Rotation of Teapot.
In this fig5.3 Teapot is rotated along Y-axis by interfacing mouse functions. This image
is obtained by clicking RIGHT Mouse Button.
Here in this fig5.3 the complete image is rotated along Y-axis using ‘y’ and ‘b’ key. If we
consider ‘b’ to rotate the image along Positive Y-axis then ‘y’ is used to rotate the image
along Negative Y-axis.
Also in this fig5.3, the Teapot is also rotated using mouse buttons, where the Teapot is
rotated along Z-axis by clicking LEFT Mouse Button.
15. P a g e | 15
Dept .of Computer science & engineering UBDTCE
Fig5.4:Rotation of Teapot along Y-axis.
In this fig5.4 Teapot is rotated along X-axis by interfacing mouse functions. This image is
obtained by clicking RIGHT Mouse Button.
This image is same as previous image shown in fig5.3, where the Teapot is rotated along
Y-axis by clicking RIGHT Mouse Button.
Similarly, the same Teapot can be rotated along X-axis by clicking MIDDLE Mouse
Button.
16. P a g e | 16
Dept .of Computer science & engineering UBDTCE
6.CONCLUSION
After the completion of this project we came to know how to work with
Microsoft visual studio and how we can implement a project using an open
source OpenGL tool kit. By implementing a project using OpenGL, we came to
know how to use the functions like lighting, rotation, translation and scaling.
With the completion of this project we have achieved a sense of happiness and
we want to thank all those who helped us directly or indirectly to make this idea
come true.
17. P a g e | 17
Dept .of Computer science & engineering UBDTCE