SlideShare a Scribd company logo
1 of 17
Download to read offline
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
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.
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 .
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
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
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();
}
P a g e | 7
Dept .of Computer science & engineering UBDTCE
void table(double topwid,double topthick,double legthick,double leglen)
{
glPushMatrix();
glTranslated(0,leglen,0);
glScaled(topwid,topthick,topwid);
glutSolidCube(1.0);
glPopMatrix();
doubledist=0.95*topwid/2.0-legthick/2.0;
glPushMatrix();
glTranslated(dist,0,dist);
tableleg(legthick,leglen);
glTranslated(0.0,0.0,-2.0*dist);
tableleg(legthick,leglen);
glTranslated(-2*dist,0,2*dist);
tableleg(legthick,leglen);
glTranslated(0,0,-2*dist);
tableleg(legthick,leglen);
glPopMatrix();
}
Static GLfloat theta[]={0.0,0.0,0.0};
Static GLint axis=2;
Static GLdouble viewer[]={0.0,0.0,5.0};
void displaysolid(void)
{
//set surface material properties
P a g e | 8
Dept .of Computer science & engineering UBDTCE
GLfloatmat_ambient[]={0.7f,0.7f,0.7f,1.0f};
GLfloatmat_diffuse[]={0.5f,0.5f,0.5f,1.0f};
GLfloatmat_specular[]={1.0f,1.0f,1.0f,1.0f};
GLfloatmat_shininess[]={50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
//set light source properties
GLfloatlightIntensity[]={0.7f,0.7f,0.7f,1.0f};
GLfloatlight_position[]={2.0f,6.0f,3.0f,0.0f};
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
//set camera
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
doublewinht=1.0; //half height of window
glOrtho(-winht*64/48.0,winht*64/48.0,-winht,winht,0.1,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(viewer[0],viewer[1],viewer[2],0.0,0.25,0.0,0.0,1.0,0.0);
//start drawing
P a g e | 9
Dept .of Computer science & engineering UBDTCE
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslated(0.4,0.4,0.6);
glRotated(45,0,0,1);
glScaled(0.08,0.08,0.08);
glPopMatrix();
glPushMatrix();
glTranslated(0.6,0.38,0.5);
glRotatef(theta[0],1,0,0);
glRotatef(theta[1],0,1,0);
glRotatef(theta[2],0,0,1);
glutSolidTeapot(0.08);
glPopMatrix();
glPushMatrix();
glTranslated(0.4,0,0.4);
table(0.6,0.02,0.02,0.3);
glPopMatrix();
wall(0.02);
glPushMatrix();
glRotated(90.0,0.0,0.0,1.0);
wall(0.02);
glPopMatrix();
P a g e | 10
Dept .of Computer science & engineering UBDTCE
glPushMatrix();
glRotated(-90.0,1.0,0.0,0.0);
wall(0.02);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void mouse(intbtn,intstate,intx,int y)
{
if(btn==GLUT_LEFT_BUTTON&&state==GLUT_DOWN)axis=0;
if(btn==GLUT_MIDDLE_BUTTON&&state==GLUT_DOWN)axis=1;
if(btn==GLUT_RIGHT_BUTTON&&state==GLUT_DOWN)axis=2;
theta[axis]+=2.0;
if(theta[axis]>360.0)theta[axis]-=360.0;
displaysolid();
}
void keys(unsigned char key,int x,int y)
{
if(key=='x')viewer[0]+=1.0;
if(key=='a')viewer[0]-=1.0;
if(key=='y')viewer[1]+=1.0;
if(key=='b')viewer[1]-=1.0;
if(key=='z')viewer[2]+=1.0;
if(key=='c')viewer[2]-=1.0;
displaysolid();
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();
}
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.
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
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.
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.
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.
P a g e | 17
Dept .of Computer science & engineering UBDTCE

More Related Content

What's hot

Screenless display report
Screenless display reportScreenless display report
Screenless display reportVikas Kumar
 
Brain Tumor Detection Using Image Processing
Brain Tumor Detection Using Image ProcessingBrain Tumor Detection Using Image Processing
Brain Tumor Detection Using Image ProcessingSinbad Konick
 
Screenless displays seminar report
Screenless displays seminar reportScreenless displays seminar report
Screenless displays seminar reportJeevan Kumar D
 
Computer Graphics Project on Sinking Ship using OpenGL
Computer Graphics Project on Sinking Ship using OpenGLComputer Graphics Project on Sinking Ship using OpenGL
Computer Graphics Project on Sinking Ship using OpenGLSharath Raj
 
Virtual Mouse using hand gesture recognition
Virtual Mouse using hand gesture recognitionVirtual Mouse using hand gesture recognition
Virtual Mouse using hand gesture recognitionMuktiKalsekar
 
screen less display documentation
screen less display documentationscreen less display documentation
screen less display documentationmani akuthota
 
Screenless display technology ppt
Screenless display technology pptScreenless display technology ppt
Screenless display technology pptKamal Krish
 
Diabetic Retinopathy.pptx
Diabetic Retinopathy.pptxDiabetic Retinopathy.pptx
Diabetic Retinopathy.pptxNGOKUL3
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notessmruti sarangi
 
Breakout Ball project presentation
Breakout Ball project presentationBreakout Ball project presentation
Breakout Ball project presentationMdThohidulIslam3
 
Seminar report on blue eyes
Seminar report on blue eyesSeminar report on blue eyes
Seminar report on blue eyesRoshmi Sarmah
 
Seminar report on cloud computing
Seminar report on cloud computingSeminar report on cloud computing
Seminar report on cloud computingJagan Mohan Bishoyi
 
Screenless Display PPT
Screenless Display PPTScreenless Display PPT
Screenless Display PPTVikas Kumar
 
Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...
Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...
Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...Universitat Politècnica de Catalunya
 
5 Pen PC technology seminar report
5 Pen PC technology seminar report5 Pen PC technology seminar report
5 Pen PC technology seminar reportRituraj Singh Panwar
 
Screenless Display
Screenless DisplayScreenless Display
Screenless DisplayNoveen555
 

What's hot (20)

Screenless display report
Screenless display reportScreenless display report
Screenless display report
 
Brain Tumor Detection Using Image Processing
Brain Tumor Detection Using Image ProcessingBrain Tumor Detection Using Image Processing
Brain Tumor Detection Using Image Processing
 
Screenless displays seminar report
Screenless displays seminar reportScreenless displays seminar report
Screenless displays seminar report
 
Computer Graphics Project on Sinking Ship using OpenGL
Computer Graphics Project on Sinking Ship using OpenGLComputer Graphics Project on Sinking Ship using OpenGL
Computer Graphics Project on Sinking Ship using OpenGL
 
Virtual Mouse using hand gesture recognition
Virtual Mouse using hand gesture recognitionVirtual Mouse using hand gesture recognition
Virtual Mouse using hand gesture recognition
 
screen less display documentation
screen less display documentationscreen less display documentation
screen less display documentation
 
Screenless display technology ppt
Screenless display technology pptScreenless display technology ppt
Screenless display technology ppt
 
Diabetic Retinopathy.pptx
Diabetic Retinopathy.pptxDiabetic Retinopathy.pptx
Diabetic Retinopathy.pptx
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Breakout Ball project presentation
Breakout Ball project presentationBreakout Ball project presentation
Breakout Ball project presentation
 
Seminar report on blue eyes
Seminar report on blue eyesSeminar report on blue eyes
Seminar report on blue eyes
 
Screenless display
Screenless display Screenless display
Screenless display
 
Seminar report on cloud computing
Seminar report on cloud computingSeminar report on cloud computing
Seminar report on cloud computing
 
Screenless Display PPT
Screenless Display PPTScreenless Display PPT
Screenless Display PPT
 
Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...
Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...
Skin Lesion Detection from Dermoscopic Images using Convolutional Neural Netw...
 
SMART NOTE TAKER
SMART NOTE TAKERSMART NOTE TAKER
SMART NOTE TAKER
 
5 Pen PC technology seminar report
5 Pen PC technology seminar report5 Pen PC technology seminar report
5 Pen PC technology seminar report
 
Touchless touch screen
Touchless touch screenTouchless touch screen
Touchless touch screen
 
Jini technology ppt
Jini technology pptJini technology ppt
Jini technology ppt
 
Screenless Display
Screenless DisplayScreenless Display
Screenless Display
 

Similar to Rotating Teapot OpenGL Program

CG_report_merged (1).pdf
CG_report_merged (1).pdfCG_report_merged (1).pdf
CG_report_merged (1).pdfrahul812082
 
Ball Collecting game report
Ball Collecting game report Ball Collecting game report
Ball Collecting game report Dileep Maurya
 
CGV Project Report.pdf
CGV Project Report.pdfCGV Project Report.pdf
CGV Project Report.pdfHimaBindhu41
 
CS 354 Introduction
CS 354 IntroductionCS 354 Introduction
CS 354 IntroductionMark Kilgard
 
Dynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdfDynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdfAgneshShetty
 
ARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMVishal GARG
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsRup Chowdhury
 
Gui based debuggers
Gui based debuggers Gui based debuggers
Gui based debuggers Mysa Vijay
 
GPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaGPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaJanie Clayton
 
VisionizeBeforeVisulaize_IEVC_Final
VisionizeBeforeVisulaize_IEVC_FinalVisionizeBeforeVisulaize_IEVC_Final
VisionizeBeforeVisulaize_IEVC_FinalMasatsugu HASHIMOTO
 
GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015Janie Clayton
 
Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow Jen Aman
 
FACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDS
FACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDSFACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDS
FACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDSIRJET Journal
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentIJERD Editor
 
digitaldesign-s20-lecture3b-fpga-afterlecture.pdf
digitaldesign-s20-lecture3b-fpga-afterlecture.pdfdigitaldesign-s20-lecture3b-fpga-afterlecture.pdf
digitaldesign-s20-lecture3b-fpga-afterlecture.pdfDuy-Hieu Bui
 
Compressing of Magnetic Resonance Images with Cuda
Compressing of Magnetic Resonance Images with CudaCompressing of Magnetic Resonance Images with Cuda
Compressing of Magnetic Resonance Images with Cudaijtsrd
 

Similar to Rotating Teapot OpenGL Program (20)

CG_report_merged (1).pdf
CG_report_merged (1).pdfCG_report_merged (1).pdf
CG_report_merged (1).pdf
 
Ball Collecting game report
Ball Collecting game report Ball Collecting game report
Ball Collecting game report
 
CGV Project Report.pdf
CGV Project Report.pdfCGV Project Report.pdf
CGV Project Report.pdf
 
CS 354 Introduction
CS 354 IntroductionCS 354 Introduction
CS 354 Introduction
 
Dynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdfDynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdf
 
Nanaji_Sahukara
Nanaji_SahukaraNanaji_Sahukara
Nanaji_Sahukara
 
ARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEM
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer Graphics
 
Gui based debuggers
Gui based debuggers Gui based debuggers
Gui based debuggers
 
GPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaGPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf Atlanta
 
VisionizeBeforeVisulaize_IEVC_Final
VisionizeBeforeVisulaize_IEVC_FinalVisionizeBeforeVisulaize_IEVC_Final
VisionizeBeforeVisulaize_IEVC_Final
 
GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015
 
report
reportreport
report
 
Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow
 
FACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDS
FACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDSFACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDS
FACE COUNTING USING OPEN CV & PYTHON FOR ANALYZING UNUSUAL EVENTS IN CROWDS
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
digitaldesign-s20-lecture3b-fpga-afterlecture.pdf
digitaldesign-s20-lecture3b-fpga-afterlecture.pdfdigitaldesign-s20-lecture3b-fpga-afterlecture.pdf
digitaldesign-s20-lecture3b-fpga-afterlecture.pdf
 
Compressing of Magnetic Resonance Images with Cuda
Compressing of Magnetic Resonance Images with CudaCompressing of Magnetic Resonance Images with Cuda
Compressing of Magnetic Resonance Images with Cuda
 
MAJOR PROJECT
MAJOR PROJECT MAJOR PROJECT
MAJOR PROJECT
 
3D LED CUBE PROPOSAL.pptx
3D LED CUBE PROPOSAL.pptx3D LED CUBE PROPOSAL.pptx
3D LED CUBE PROPOSAL.pptx
 

Rotating Teapot OpenGL Program

  • 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(); }
  • 7. P a g e | 7 Dept .of Computer science & engineering UBDTCE void table(double topwid,double topthick,double legthick,double leglen) { glPushMatrix(); glTranslated(0,leglen,0); glScaled(topwid,topthick,topwid); glutSolidCube(1.0); glPopMatrix(); doubledist=0.95*topwid/2.0-legthick/2.0; glPushMatrix(); glTranslated(dist,0,dist); tableleg(legthick,leglen); glTranslated(0.0,0.0,-2.0*dist); tableleg(legthick,leglen); glTranslated(-2*dist,0,2*dist); tableleg(legthick,leglen); glTranslated(0,0,-2*dist); tableleg(legthick,leglen); glPopMatrix(); } Static GLfloat theta[]={0.0,0.0,0.0}; Static GLint axis=2; Static GLdouble viewer[]={0.0,0.0,5.0}; void displaysolid(void) { //set surface material properties
  • 8. P a g e | 8 Dept .of Computer science & engineering UBDTCE GLfloatmat_ambient[]={0.7f,0.7f,0.7f,1.0f}; GLfloatmat_diffuse[]={0.5f,0.5f,0.5f,1.0f}; GLfloatmat_specular[]={1.0f,1.0f,1.0f,1.0f}; GLfloatmat_shininess[]={50.0f}; glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient); glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse); glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular); glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess); //set light source properties GLfloatlightIntensity[]={0.7f,0.7f,0.7f,1.0f}; GLfloatlight_position[]={2.0f,6.0f,3.0f,0.0f}; glLightfv(GL_LIGHT0,GL_POSITION,light_position); glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity); //set camera glMatrixMode(GL_PROJECTION); glLoadIdentity(); doublewinht=1.0; //half height of window glOrtho(-winht*64/48.0,winht*64/48.0,-winht,winht,0.1,100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(viewer[0],viewer[1],viewer[2],0.0,0.25,0.0,0.0,1.0,0.0); //start drawing
  • 9. P a g e | 9 Dept .of Computer science & engineering UBDTCE glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslated(0.4,0.4,0.6); glRotated(45,0,0,1); glScaled(0.08,0.08,0.08); glPopMatrix(); glPushMatrix(); glTranslated(0.6,0.38,0.5); glRotatef(theta[0],1,0,0); glRotatef(theta[1],0,1,0); glRotatef(theta[2],0,0,1); glutSolidTeapot(0.08); glPopMatrix(); glPushMatrix(); glTranslated(0.4,0,0.4); table(0.6,0.02,0.02,0.3); glPopMatrix(); wall(0.02); glPushMatrix(); glRotated(90.0,0.0,0.0,1.0); wall(0.02); glPopMatrix();
  • 10. P a g e | 10 Dept .of Computer science & engineering UBDTCE glPushMatrix(); glRotated(-90.0,1.0,0.0,0.0); wall(0.02); glPopMatrix(); glFlush(); glutSwapBuffers(); } void mouse(intbtn,intstate,intx,int y) { if(btn==GLUT_LEFT_BUTTON&&state==GLUT_DOWN)axis=0; if(btn==GLUT_MIDDLE_BUTTON&&state==GLUT_DOWN)axis=1; if(btn==GLUT_RIGHT_BUTTON&&state==GLUT_DOWN)axis=2; theta[axis]+=2.0; if(theta[axis]>360.0)theta[axis]-=360.0; displaysolid(); } void keys(unsigned char key,int x,int y) { if(key=='x')viewer[0]+=1.0; if(key=='a')viewer[0]-=1.0; if(key=='y')viewer[1]+=1.0; if(key=='b')viewer[1]-=1.0; if(key=='z')viewer[2]+=1.0; if(key=='c')viewer[2]-=1.0; displaysolid();
  • 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