

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Computer graphics mini project report
Typology: Study Guides, Projects, Research
1 / 33
This page cannot be seen from the preview
Don't miss anything!
program.
As a software interface for graphics hardware, OpenGL's main purpose is to render two- and three-dimensional objects into a frame buffer. These objects are described as sequences of vertices or pixels. OpenGL performs several processing steps on this data to convert it to pixels to form the final desired image in the frame buffer.
This section explains some of the concepts inherent in OpenGL. Primitives and Commands OpenGL draws primitives—points, line segments, or polygons—subject to several selectable modes. You can control modes independently of each other; that is, setting one mode doesn't affect whether other modes are set .Primitives are specified, modes are set, and other OpenGL operations are described by issuing commands in the form of function calls. Primitives are defined by a group of one or more vertices. A vertex defines a point, an endpoint of a line, or a corner of a polygon where two edges meet. Data is associated with a vertex, and each vertex and its associated data are processed independently, in order, and in the same way. The type of clipping depends on which primitive the group of vertices represents. Commands are always processed in the order in which they are received,
although there may be an indeterminate delay before a command takes effect. This means that each primitive is drawn completely before any subsequent command takes effect. It also means that state-querying commands return data that's consistent with complete execution of all previously issued OpenGL commands.
The figure shown below gives an abstract, high-level block diagram of how OpenGL processes data. In the diagram, commands enter from the left and proceed through what can be thought of as a processing pipeline. Some commands specify geometric objects to be drawn, and others control how the objects are handled during the various processing stages. Figure. OpenGL Block Diagram As shown by the first block in the diagram, rather than having all commands proceed immediately through the pipeline, you can choose to accumulate some of them in a display list for processing at a later time.
This program is implemented using various openGL functions which are shown below.
glutInit() : interaction between the windowing system and OPENGL is initiated glutInitDisplayMode() : used when double buffering is required and depth information is required glutCreateWindow() : this opens the OPENGL window and displays the title at top of the window glutInitWindowSize() : specifies the size of the window glutInitWindowPosition() : specifies the position of the window in screen co-ordinates glutKeyboardFunc() : handles normal ascii symbols
glutSpecialFunc() : handles special keyboard keys glutReshapeFunc() : sets up the callback function for reshaping the window glutIdleFunc() : this handles the processing of the background glutDisplayFunc() : this handles redrawing of the window glutMainLoop() : this starts the main loop, it never returns glViewport() : used to set up the viewport glVertex3fv() : used to set up the points or vertices in three dimensions glColor3fv() : used to render color to faces glFlush() : used to flush the pipeline glutPostRedisplay() : used to trigger an automatic redrawal of the object glMatrixMode() : used to set up the required mode of the matrix glLoadIdentity() : used to load or initialize to the identity matrix
/An Interactive Program to create 3d objects/ #include <windows.h> #include<string.h> #include<stdarg.h> #include<stdio.h> #include <glut.h> static double x=0.0; static double inc=0.0; void stroke_output(GLfloat x, GLfloat y, char *format,...) { va_list args; char buffer[200], *p;
va_start(args, format); vsprintf(buffer, format, args); va_end(args); glPushMatrix(); glTranslatef(-2.5, y, 0); glScaled(0.003, 0.005, 0.005); for (p = buffer; *p; p++) glutStrokeCharacter(GLUT_STROKE_ROMAN, *p); glPopMatrix(); } //changing backgroun color // Table Fan void fan(double ang) { glClearColor(0.8,0.8,0.8,0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,0.0f,-13.0f);
glutSolidCube(6.0); glPopMatrix(); //fan cover glPushMatrix(); glScaled(0.8,1.0,0.2); glTranslatef(0.0,0.0,0.0); glutWireSphere(0.9,20,60); glPopMatrix(); glPushMatrix(); glScaled(0.8,0.18,0.8); glTranslatef(0.0,-7.2,0.0); glutSolidCube(0.7); glPopMatrix();
//Fan motor glPushMatrix(); glScaled(0.35,0.4,0.5); glTranslatef(0.0,0.0,0.5); glutSolidSphere(0.5,20,60); glPopMatrix(); // glFlush(); glutSwapBuffers(); } // Ceiling Fan void cfan(double rang) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.5,0.5,0.5,0.0); glLoadIdentity(); glTranslatef(0.0f,0.0f,-13.0f);
glTranslatef(0.0,0.0,16.0); glRotatef(ang,0.0f,0.0f,1.0f); glutSolidSphere(0.7,20,60); glPopMatrix(); glPushMatrix(); glutWireCone(4,3,80,120); glPopMatrix(); glPushMatrix(); glTranslatef(0.0,inc,0.0); glPushMatrix(); glRotated(ang,0.0,1.0,0.0); glTranslatef(0.05,2.0,0.0); glutSolidSphere(0.3,20,60); glPopMatrix(); glPopMatrix(); glFlush(); glutSwapBuffers(); }
void f() { x += 9.0; fan(x); } //stop the fan void F() { x = 0.0; fan(x); } void c() { x += 10.9; cfan(x); } void C() {
cfan(0); } else if(x>=0) {x+=0.3; inc+=.01; cfan(x); }else{ cfan(0); } } void fly() { if (inc<=-4){ x+=5.30; flying(x,inc); } else
inc-=0.01; x += 5.30; flying(x,inc); } } void StopFly() { if(inc>=0){ flying(0,0); } else if(x>=0) {x+=0.3; inc+=.01; flying(x,inc); }else{ flying(0,0); }