Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Computer graphics project report, Study Guides, Projects, Research of Computer Graphics

Computer graphics mini project report

Typology: Study Guides, Projects, Research

2022/2023

Uploaded on 06/26/2023

greeshma-js
greeshma-js 🇮🇳

1 document

1 / 33

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Flying Ball
Contents
SL.NO particulars PAGE.NO
1Abstract 2
2System Specifications 3
3Introduction to openGL 4
5Implementation 7
6Interaction 9
7Source Code 10
8Output 29
9Conclusion 31
10 Bibliography 32
1 Dept. of Computer Science & Engineering.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21

Partial preview of the text

Download Computer graphics project report and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity!

Contents

  • 1 Abstract SL.NO particulars PAGE.NO
  • 2 System Specifications
  • 3 Introduction to openGL
  • 5 Implementation
  • 6 Interaction
  • 7 Source Code
  • 8 Output
  • 9 Conclusion
  • 10 Bibliography

Abstract

 Main aim of this is to illustrate the concepts of Static Pressure.

 This project uses the GLUT pre-built models sub-API in openGL.

 We have used input devices like mouse and key board to interact with

program.

 We have added menu which makes the program more interactive.

 This project illustrates the concept of static pressure in OpenGL.

Introduction to openGL

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.

OpenGL Fundamentals

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.

Basic OpenGL Operation

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.

Implementation

This program is implemented using various openGL functions which are shown below.

Various functions used in this program.

 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

Source Code

/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); }