CG 1 - Merged - Removed45
CG 1 - Merged - Removed45
FLOWING FOUNTAIN
SUBMITTED IN PARTIAL FULFILMENT FOR 6TH SEMESTER
BACHELOR OF ENGINEERING
IN
KUSUMA S 1JB20CS054
N ASWINI 1JB21CS415
CERTIFICATE
Certified that the Computer Graphics Mini project work entitled “FLOWING FOUNTAIN” is a
bonafide work carried out by KUSUMA S (1JB20CS054) and N ASWINI(1JB21CS415) of SJB
Institute of Technology in partial fulfilment for 6th semester in COMPUTER SCIENCE AND
ENGINEERING of the Visvesvaraya Technological University, Belagavi during the academic
year 2022-23. It is certified that all corrections/suggestions indicated for Internal Assessment have
been incorporated in the report deposited in the departmental library. The Mini project report has
been approved as it satisfies the academic requirements in respect of Mini Project prescribed by the
institution.
1. Internal Examiner:
2. External Examiner:
ACKNOWLEDGEMENT
We would like to express our profound thanks to His Divine Soul Padmabhushana Sri Sri Sri
Dr. Balagangadharanatha MahaSwamiji and His Holiness Jagadguru Sri Sri Sri Dr.
Nirmalanandanatha MahaSwamiji for providing us an opportunity to pursue our academics
in this esteemed institution.
We would also like to express our profound thanks to Revered Sri Sri Sri Dr. Prakashnath
Swamiji, Managing Director, SJB Institute of Technology, for his continuous support in
providing amenities to carry out this mini project in this admired institution.
We extend our sincere thanks to Dr. Krishna A N, Head of the Department, Computer Science
and engineering; for providing an invaluable support throughout the period of mini project
work.
We wish to express heartfelt gratitude to our guides, Mrs. Chaitra D, Assistant Professor, Dept
of CSE and Mrs. Anusha M, Assistant Professor, Dept of CSE for their valuable guidance,
suggestions and cheerful encouragement during the entire period of this work.
Finally, we take this opportunity to extend our earnest gratitude and respect to our parents,
Teaching & Non-teaching staffs of the department, the library staff and all our friends, who
have directly or indirectly supported our during the period of this mini project .
Regards,
Kusuma S (1JB20CS054)
N Aswini (1JB21CS415)
i
ABSTRACT
A picture is worth a thousand words’ goes the ancient Chinese proverb. This has become a cliché
in our society after the advent of inexpensive and simple techniques for producing pictures.
Computers have become a powerful medium for the rapid and economical production of pictures.
There is virtually no area in which graphical displays cannot be used to some advantage.
Graphics provide a so natural means of communicating with a computer that they have become
widespread. The fields in which Computer Graphics find their uses are many. Some of them
being User Interfaces, Computer Aided Design, Office automation, Desktop Publishing, plotting
of mathematical, scientific, or industrial data, Simulation, Art, Presentations, Cartography, to
name a few. The graphics in openGL provides a wide variety of built-in function. The computer
graphics remains one of the most exciting and rapidly growing computer fields. It has become a
common element in user interface, data visualization, TV commercials, motion picture and many
other applications. The current trend of computer graphics is to incorporate more physics
principles into 3D graphics algorithm to better simulate the complex interactions between objects
and lighting environment. The "FLOWING FOUNTAIN MODEL". It depicts a 3 Dimensional
model of a fountain through which water is continuously flowing out in its idle state. The water
gets stored into a small reservoir. The water flows out through different levels in the fountain,
giving it a realistic look. The user is provided with an option to change the color of the fountain
using the RIGHT MOUSE BUTTON. The user can view the fountain from different angles
including a Top-view and can also zoom in or zoom out. This can be controlled using a set of
specified keys on keyboard such as ‘N’ and ‘A’ for ZOOM IN and ZOOM OUT, buttons ‘T’ and
‘F’ for TOP and FRONT VIEW etc. Clicking on the RIGHT MOUSE BUTTON shows a sub
menu -'Help' which displays the keyboard shortcuts for various controls. The third option ‘Exit’
pops out of the program. The project is based on Simple window coordinates and using recursive
techniques in OpenGL.
ii
TABLE OF CONTENTS
Acknowledgement i
Abstract ii
List of Figures iv
1. Introduction 1
1.1 Problem Statement 2
1.2 Objectives of Project 3
1.3 Scope 3
2. Literature Survey 3
2.1 History 4
2.2 Characteristics 5
2.3 Computer Graphics Library Organization 5
2.4 Graphics System and Functions 6
3. System Requirements 8
3.1 Hardware Requirement 8
3.2 Software Requirement 8
5. Snapshots 15
5.1 Start Screen 15
5.2 Menu Page 15
5.3 Keyboard Controls 16
5.4 Flowing Fountain 16
Conclusion 17
Bibliography 18
iii
LIST OF FIGURES
iv
Flowing Fountain
CHAPTER 1
INTRODUCTION
OpenGL has become a widely accepted standard for developing graphics application.
OpenGL is easy to learn, and it possesses most of the characteristics of other popular graphics
system. It is top-down approach. OpenGL is a standard specification defining a cross-
language, cross-platform
API for writing applications that produce 2D and 3D computer graphics. The interface
consists of over 250 different function calls which can be used to draw complex three-
dimensional scenes from simple primitives.
OpenGL was developed by Silicon Graphics Inc. (SGI) in 1992 and is widely used in CAD,
virtual reality, scientific visualization, information visualization, and flight simulation. It is
also used in video games, where it competes with Direct3D on Microsoft Windows
platforms.
The interface between the application program and the graphics system can be specified
through that set of function that resides in graphics library. The specification is called the
APPLICATION PROGRAM INTERFACE (API). The application program sees only the
API and is thus shielded from the details both the hardware and software implementation of
graphics library. The software driver is responsible for interpreting the output of an API and
converting these data to a form that is understood by the particular hardware.
Most of our applications will be designed to access openGL directly through functions in
three libraries. Function in the main GL library have name that begin with the letter gl and
stored in the library. The second is the openGL utility Library (GLU). This library uses only
GL function but contains codes for creating common object and viewing. Rather then using
an different library for each system we used available library called openGL utility toolkit
(GLUT). It used as #include<glut.h>
A graphics editor is a computer program that allows users to compose and edit pictures
interactively on the computer screen and save them in one of many popular “bitmap” or
“raster” a format such as TIFF, JPEG, PNG and GIF.
Graphics Editors can normally be classified as:
➢ 2D Graphics Editor
➢ 3D Graphics Editors.
A 3D Graphics Editor is used to draw 3D primitives Rectangles, Circle, polygons, etc and
alter those with operations like cut, copy, paste. These may also contain features like layers
and object precision etc.
Computer Graphics is concerned with all aspects of producing pictures or images using a
computer. A particular graphics software system called OpenGL, which has become a widely
accepted standard for developing graphics applications .
The applications of computer graphics in some of the major areas are as follows
1. Display of information.
2. Design.
3. Simulation and Animation.
4. User interfaces.
OpenGL is a software interface to graphics hardware. This interface consists of about 150
distinct commands that you use to specify the objects and operations needed to produce
interactive three-dimensional applications. My project named “FLOWING FOUNTAIN
1MODEL” uses OpenGL software interface and develops 2D images. This project uses the
techniques like Translation, motion, display list, transformation techniques, etc.
1.3 SCOPE
• The project is used to follow the architecture of fountain and its further
Development in future with more options.
• Even though demo is designed is enriched with many options,it is a two dimensional
demo,in future it can be redisgned with 3D animation and sound effects.
CHAPTER 2
LITERATURE SURVEY
People use the term “computer graphics” to mean different things in different context.
Computer graphics are pictures that are generated by a computer. Everywhere you look
today, you can find examples, especially in magazines and on television. Some images look
so natural you can’t distinguish them from photographs of a real scene. Others have an
artificial look, intended to achieve some visual effects.
There are several ways in which the graphics generated by the program can be delivered.
• Frame- by- frame: A single frame can be drawn while the user waits.
• Frame-by-frame under control of the user: A sequence of frames can be drawn, as in
a corporate power point presentation; the user presses to move on to the next slide,
but otherwise has no way of interacting with the slides
• Animation: A sequence of frames proceeds at a particular rate while the user watches
with delight.
• Interactive program: An interactive graphics presentation is watched, where the user
controls the flow from one frame to another using an input device such as a mouse or
keyboard, in a manner that was unpredictable at the time the program was written.
This can delight the eye.
2.1 History
OpenGL was developed by ‘Silicon Graphics Inc‘(SGI) on 1992 and is popular in the gaming
industry where it competes with the Direct3D in the Microsoft Windows platform. OpenGL
is broadly used in CAD (Computer Aided Design), virtual reality, scientific visualization,
information visualization, flight simulation and video games development.
OpenGL is a standard specification that defines an API that is multi-language and multi-
platform and that enables the codification of applications that output computerized graphics
in 2D and 3D.
The interface consists in more than 250 different functions, which can be used to draw
complex tri dimensional scenes with simple primitives. It consists of many functions that
help to create a real-world object and a particular existence for an object can be given.
In late 1960’s the development of Free-form curves and surfaces for computer graphics begins.
Free-form curves and surfaces where developed to describe curved 3-D objects without using
polyhedral representations which are bulky and intractable. To get a precise curve with polygons
might require thousands of faces, whereas a curved surface requires much less calculations. The
UNISURF CAD system was created for designing cars which utilized the curve theories.
A research was made, but was never published so designers get most of the credit. The men were
pioneers in Computer Aided Geometric Design (CAGD) for the auto industry, which replaced the
use of hand drawn French-curve templates in design of auto bodies.
In 1973, designers based their research into Parametric B-Splines on Coon’s work. The main
difference between B-Splines and Bezier curves is the former allows for local control of key control
points and the later has more of a global control system. B-Splines are also faster to calculate for
a computer than cubic polynomial based curves like the Hermite and Bezier.
2.2 Characteristics
GLU library uses only GL functions but contains code for creating objects and simplify
viewing.
To interface with the w indow system and to get input from external devices GLUT library
is used, which is a combination of three libraries GLX for X windows, ‘wgl’ for Windows
• These libraries are included in the application program using preprocessor directives. E.g.:
#include<GL/glut.h>
• The following figure shows the library organization in OpenGL.
GLU
Open GL
GL
Frame
application
Xlib, Xtk Buffer
program GLUT
GLX
Fig. 2.1 Library Organization
• Graphics system and functions can be considered as a black box, a term used to denote
a system whose properties are only described by its inputs and outputwithout knowing
the internal working.
• Inputs to graphics system are functions calls from application program, measurements
from input devices such as mouse and keyboard.
• Outputs are primarily the graphics sent to output devices.
Data Input
Fig 2.2 Graphics System as a black box
API’s are described through functions in its library. These functions are divided into seven
major groups.
• Primitive Functions:
Primitive functions define the low-level objects or atomic entities that a system can
display, the primitives include line segments, polygons, pixels, points, text and various
types of curves and surfaces.
• Attribute Functions:
Attribute Functions allow us to perform operations ranging from choosing the color to
display a line segment, to packing a pattern to fill inside any solid figure.
• Viewing Functions:
• Transformation Functions:
• Input Functions:
Input functions allow us to deal with the diverse forms of input that characterize modern
graphics system. It deals with devices such as keyboard, mouse and data tablets.
• Control Functions:
Control Functions enable us to communicate with the window system, to initialize the
programs, and to deal with any errors that occur during the execution of the program.
• Query Functions:
Query Functions provides information about the API.
CHAPTER 3
SYSTEM REQUIREMENTS
To be used efficiently, all computer software needs certain hardware components or other
software resources to be present on a computer. These prerequisites are known as (computer)
system requirements and are often used as a guideline as opposed to an absolute rule. Most
software defines two sets of system requirements: minimum and recommended. With
increasing demand for higher processing power and resources in newer versions of software,
system requirements tend to increase over time.
• The graphics package has been designed for OpenGL; hence the machine must have
Eclipse.
• Software installed preferably 6.0 or later versions with mouse driver installed.
• Turbo c Libraries are used and hence a TC version 2 or later is required.
Ubuntu 10.10.
CHAPTER 4
SYSTEM DESIGN & IMPLEMENTATION
4.1 HEADER FILES
• #include<stdlib.h>
stdlib.h is the header of the general-purpose standard library of C programming
language which includes functions involving memory allocation, process control,
conversions and others. It is compatible with C++ and is known as cstdlib in C++. The
name "stdlib" stands for "standard library”.
• #include<GL/glut.h>
GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window
system independent toolkit for writing OpenGL programs. It implements a simple
windowing application programming interface (API) for OpenGL. GLUT makes it
considerably easier to learn about and explore OpenGL programming. GLUT provides
a portable API so you can write a single OpenGL program that works across all PC and
workstation OS platforms.
• #include<stdio.h>
The C programming language provides many standard library functions for file input
and output. These functions make up the bulk of the C standard library header .The first
thing you will notice is the first line of the file, the #include "stdio.h" line. This is very
much like the #define the preprocessor, except that instead of a simple substitution, an
entire file is read in at this point.
The file is called a header file and you will find several different header files on the
source disks that came with your C compiler. Each of the header files has a specific
purpose and any or all of them can be included in any program.
• #include<math.h>
math.h is a header file in the standard library of the C programming language designed
for basic mathematical operations. Most of the functions involve the use of floating-
point numbers. C++ also implements these functions for compatibility reasons and
declares them in the header cmath (the C99 functions are not available in the current
C++ standard, C++ 98).All functions that take or return an angle work in radians. All
functions take doubles for floating-point arguments, unless otherwise specified. In C99,
to work with floats or long doubles, append an f or an l to the name, respectively.
• #include<string.h>
string.h is the header in the C standard library for the C programming language which
contains macro definitions, constants and declarations of functions and types used not
only for string handling but also various memory handling functions. All the string
handling functions are prototyped in: #include . The common functions are described
below: char *stpcpy (char *dest,const char *src) -- Copy one string into another. int
strcmp(char *string1,const char *string2) - Compare string1 and string2 to determine
alphabetic order etc.
• voidglMatrixMode(GLenum mode);
where mode Specifies which matrix stack is the target for subsequent matrix operations.
Three values are accepted: GL_MODELVIEW, GL_PROJECTION, and
GL_TEXTURE. The initial value is GL_MODELVIEW.
glMatrixMode sets the current matrix mode. mode can assume one of three values:
xw = ( xnd + 1 ) width/2 + x
yw = ( ynd + 1 ) height/2 + y
Viewport width and height are silently clamped to a range that depends on the
implementation. To query this range, call glGetInteger with argument
GL_MAX_VIEWPORT_DIMS.
for the window is established. The width andheight parameters of the callback specify the
new window size in pixels. Before the callback, the current window is set to the window
that has been reshaped.
If a reshape callback is not registered for a window or NULL is passed to
glutReshapeFunc (to deregister a previously registered callback), the default reshape
callback is used. This default callback will simply glOrtho ( ).
• void glOrtho ( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble near, GLdouble far):
The function defines an orthographic viewing volume with all parameters measured from
the centre of the projection plane.
• void glutMainLoop(void);
glutMainLoop enters void glOrtho the GLUT event processing loop. This routine should
be called at most once in a GLUT program. Once called, this routine will never stop.
• glutPostRedisplay();
glutPostRedisplay, glutPostWindowRedisplay — marks the current or specified
window as needing to be redisplayed.
• GlutSwapBuffers ():
Swap the buffers ->make the result of rendering visible.
ListNum = glGenLists(1);
for (GLint i = 0; i<NumOfVerticesStone; i++)
{
Vertices[i].x = cos(2.0 * PI / NumOfVerticesStone * i) * OuterRadius;
Vertices[i].y = StoneHeight;
Vertices[i].z = sin(2.0 * PI / NumOfVerticesStone * i) * OuterRadius;
}
glTranslatef(x,y,z);
glScalef(scale,scale,scale);
for (i=0;i < strlen(s);i++)
glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN,s[i]);
glPopMatrix();
}
• glEnable(GL_BLEND):
You have to tell OpenGL how to use the alpha values. It isn't specified, that a higher
alpha-value means more transparency or something like that. You can use them as you
want.
• glBlendFunc():
To tell OpenGL _what_ you want, you must use this function. It takes two parameters, one
for the source factor and the second for the destination factor.
GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA are parameters. This is quite an
often used combination and affects, that the higher the alpha value, the less transparency
of the incoming fragment is GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA as
parameters. This is quite an often used combination and affects, that the higher the alpha
value, the less transparency of the incoming fragment .
4.4Architecture
CHAPTER 5
SNAPSHOTS
Fig 5.1 consist of window which has contemts like name of the project,department and
institute name.We need to press enter to go to the next screen.
Fig 5.2 consist of the window which has title of the project “Fountain” .It also consists of
the option like proceed ,help ,exit and back option.
Fig 5.3 consist of window which has keyboard controls on pressing key N will move near
,pressing A will move away and on U it will up ,on D it will move down similarily the
corresponding key will do the corresponding actions.
BIBLIOGRAPHY
[1].Programming Open GL for the X Window System by Addison-Wesley
[2].Donald Hearn & Pauline Baker:Computer Graphics with OpenGL version,3rd/4th
Edition,Pearson education ,2011
[7].https://www.opengl.org/
[8].http://www.opengl-tutorial.org/
[9].https://ogldev.org/