0% found this document useful (0 votes)
74 views24 pages

CG 1 - Merged - Removed45

Uploaded by

Manasa Krishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views24 pages

CG 1 - Merged - Removed45

Uploaded by

Manasa Krishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

“Jnana Sangama”, Belgaum-590018

A Mini Project Report On

FLOWING FOUNTAIN
SUBMITTED IN PARTIAL FULFILMENT FOR 6TH SEMESTER

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE AND ENGINEERING


SUBMITTED BY

KUSUMA S 1JB20CS054
N ASWINI 1JB21CS415

UNDER THE GUIDANCE OF

Mrs. Chaitra D Mrs. Anusha M


Assistant Professor Assistant Professor
Dept. of CSE, SJBIT Dept. of CSE, SJBIT

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SJB INSTITUTE OF TECHNOLOGY
#67, BGS HEALTH & EDUCATION CITY, DR. VISHNUVARDHAN ROAD, KENGERI, BENGALURU-
560060, KARNATAKA, INDIA.
2022 - 2023
|| Jai Sri Gurudev ||
Sri Adichunchanagiri Shikshana Trust ®

SJB INSTITUTE OF TECHNOLOGY


#67, BGS HEALTH & EDUCATION CITY, DR. VISHNUVARDHAN ROAD, KENGERI, BENGALURU-
560060, KARNATAKA, INDIA.

Department of Computer Science & Engineering

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.

Mrs. CHAITRA D Mrs. ANUSHA M Signature of HOD


Asst. professor Asst. professor
Dept. of CSE, SJBIT Dept. of CSE, SJBIT

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 express our gratitude to Dr. K V Mahendra Prashanth, Principal, SJB Institute of


Technology, for providing an excellent facilities and academic ambience; which have helped us
in satisfactory completion of mini project work.

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

4. System Design and Implementation 9


4.1 Header Files 9
4.2 OpenGL API’s 10
4.3 User Defined Functions 12

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

Fig no Fig description Page no

2.1 Library Organization 5

2.2 Graphics System as a Black Box 5

4.1 Flow Chart 14

5.1 Start Screen 15

5.2 Menu Page 15

5.3 Keyboard Control 16

5.4 Flowing Fountain 16

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.

Dept. of CSE, SJBIT 2022-23 1


Flowing Fountain

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.

3D Graphics Editor should include the following features:

➢ Facilities: Cursor Movement, Editing picture objects.


➢ Good User Interface: GUI / Toolbars / Icon based User Interface.

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.1 PROBLEM STATEMENT


Computer graphics is no longer a rarity. It is an integral part of all computer user interfaces,
and is indispensable for visualizing 2D; 3D and higher dimensional objects .Creating 3D
objects, rotations and any other manipulations are laborious process graphics implementation
using text editor. OpenGL provides more features for developing 3D objects with few lines
by built in functions.
The geometric objects are the building blocks of any individual .Thereby developing,
manipulating, applying any transformation, rotation, scaling on them is the major task of any
image development.
Thereby we have put our tiny effort to develop 3D objects and perform different operations
on them by using OpenGL utilities.

Dept. of CSE, SJBIT 2022-23 2


Flowing Fountain

1.2 OBJECTIVES OF THE PROJECT

• Developing a package using computer graphics with OpenGL.


• Migration from text editor to OpenGL.
• To show that implementation of Translation is easier with OpenGL.
• Implementing certain technical concept like Translation, motion, and use of
Idle function
• How to use Lightning effects used to produce computer animation.

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.

Dept. of CSE, SJBIT 2022-23 3


Flowing Fountain

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

Dept. of CSE, SJBIT 2022-23 4


Flowing Fountain

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

• OpenGL is a better documented API.


• OpenGL is also a cleaner API and much easier to learn and program.
• OpenGL has the best demonstrated 3D performance for any API.
• Microsoft's Direct3D group is already planning a major API change called Direct
Primitive that will leave any existing investment in learning Direct3D immediate
mode largely obsolete.

2.3 Computer Graphics in Library Organization


OpenGL stands for Open Source Graphics Library. Graphics Library is a collection of APIs
(Application Programming Interfaces).
Graphics Library functions are divided in three libraries. They are as follows-
i. GL Library (OpenGL in Windows)
ii. GLU (OpenGL Utility Library)
iii. GLUT (OpenGL Utility Toolkit)
Functions in main GL library name functions names that begin with the letter ‘gl’.

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

Dept. of CSE, SJBIT 2022-23 5


Flowing Fountain

• 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

2.4 Graphics Systems and Functions

• 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.

Applicat Function calls Output Input


ion Graphics System Output
Program 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.

Dept. of CSE, SJBIT 2022-23 6


Flowing Fountain

• 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:

Viewing functions allow us to specify various views.

• Transformation Functions:

Transformation functions allow us to carry out transformation of objects such as rotation,


translation and scaling.

• 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.

Dept. of CSE, SJBIT 2022-23 7


Flowing Fountain

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.

3.1 Hardware requirements:

• Pentium or higher processor.


• 16 MB or more RAM.
• A standard keyboard, and Microsoft compatible mouse VGA monitor.
• If the user wants to save the Created files a secondary storage medium can be Used.

3.2 Software requirements:

• 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.

3.3 Development platform:

Ubuntu 10.10.

Dept. of CSE, SJBIT 2022-23 8


Flowing Fountain

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.

Dept. of CSE, SJBIT 2022-23 9


Flowing Fountain

• #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.

4.2 OpenGL API’s Used


• voidglColor3f (float red, float green, float blue);
This function is used to mention the color in which the pixel should appear. The number
3 specifies the number of arguments that the function would take. ‘f ’ gives the type that
is float. The arguments are in the order RGB(Red, Green, Blue). The color of the pixel
can be specified as the combination of these 3 primary colors.
• voidglClearColor (int red, int blue, int green, int alpha);
This function is used to clear the color of the screen. The 4 values that are passed as
arguments for this function are (RED, GREEN, BLUE, ALPHA) where the red green
and blue components are taken to set the background color and alpha is a value that
specifies depth of the window. It is used for 3D images.
• void glutKeyboardFunc();
void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y)); where func is the
new keyboard callback function. glutKeyboardFunc sets the keyboard callback for the
current window. When a user types into the window, each key press generating an ASCII
character will generate a keyboard callback. The key callback parameter is the generated
ASCII character. The x and y callback parameters indicate the mouse location in window
relative coordinates when the key was pressed. When a new window is created, no
keyboard callback is initially registered, and ASCII keystrokes in the window are
ignored. Passing NULL to glutKeyboardFunc disables the generation of keyboard
callbacks.network buffers and the graphics accelerator itself. glFlush empties all of these
buffers, causing all issued commands to be executed as quickly as they are accepted by
the actual rendering engine. Though this execution may not be completed in any
particular time period, it does complete in finite time.

Dept. of CSE, SJBIT 2022-23 10


Flowing Fountain

• 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:

1. GL_MODELVIEW : Applies subsequent matrix operations to the model view


matrix stack.
2. GL_PROJECTION : Applies subsequent matrix operations to the projection
matrix stack.
• void glViewport(GLint x, GLint y, GLsizei width, GLsizei height):
where x, y Specify the lower left corner of the viewport rectangle, in pixels. The
initial value is (0, 0). The width, height Specify the width and height of the viewport.
When a GL context is first attached to a surface (e.g. window), width and height are set
to the dimensions of that surface. GlViewport specifies the affine transformation of x and
from normalized device coordinates to window coordinates. Let (xnd, ynd) be normalized
device coordinates. Then the window coordinates (xw, yw) are computed as follows:

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.

• void glutInit(int *argc, char **argv);


glutInit will initialize the GLUT library and negotiate a session with the window system.
During this process, glutInit may cause the termination of the GLUT program with an
error message to the user if GLUT cannot be properly initialized. Examples of this
situation include the failure to connect to the window system, the lack of window system
support for OpenGL, and invalid command line options.glutInit also processes command
line options, but the specific options parse are window system dependent.
• void glutReshapeFunc(void (*func)(int width, int height)):
glutReshapeFunc sets the reshape callback for the current window. The reshape callback
is triggered when a window is reshaped. A reshape callback is also triggered immediately
before a window's first display callback after a window is created or whenever an overlay

Dept. of CSE, SJBIT 2022-23 11


Flowing Fountain

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.

4.3 USER DEFINED FUNCTIONS


• GetNewPosition ():
To create a fountain there is a class declared called CDrop. In GetNewPosition (), we
calculate the position and delay of each drop with respect to the coordinate axes.
• createlist ():
Dynamically allocate memory for the required vertices. Function glGenLists used to
generate a contiguous set of empty display lists. Then specify a series of ‘for ‘loops to
construct the top and bottom of the stone. Then create a qaudrilateral to represent the
ground.
CreateList(void)

SVertex * Vertices = new SVertex[NumOfVerticesStone*3];

ListNum = glGenLists(1);
for (GLint i = 0; i<NumOfVerticesStone; i++)

Dept. of CSE, SJBIT 2022-23 12


Flowing Fountain

{
Vertices[i].x = cos(2.0 * PI / NumOfVerticesStone * i) * OuterRadius;
Vertices[i].y = StoneHeight;
Vertices[i].z = sin(2.0 * PI / NumOfVerticesStone * i) * OuterRadius;
}

To create water, use the following functions:


• GlTranslatef () :
is to calculate water and stone height.
• rand () :
is used to generate random unique numbers, for each time it is executed.
void randcolor()
{ GLint a,b,c; a=rand()%101;
b=rand()%101;
c=rand()%101;
X[0]=(GLfloat)a/100.0;
X[1]=(GLfloat)b/100.0;
X[2]=(GLfloat)c/100.0;
}
• InitFountain () :
Create fountain drops and vertices. Declare StepAngle, the angle which the ray gets out
of the fountain and RayAngle, the angle you see when you look down on the fountain.
Use sine () and cosine () functions inside for loops, to calculate the speed of each step in
the fountain, how many steps are required, that a drop comes out and falls down again.
• GlClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT):
Indicates the buffers currently enabled for color writing and also indicates the depth
buffer.
• GlPushMatrix (), glPopMatrix () :
to push and pop the current matrix stack.

• DrawTextXY () :
used to set the text of the program.
void DrawTextXY(double x,double y,double z,double scale,char *s)
{ int i; glPushMatrix();

Dept. of CSE, SJBIT 2022-23 13


Flowing Fountain

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

Fig 4.1:Flow Chart

Dept. of CSE, SJBIT 2022-23 14


Flowing Fountain

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.1 Star 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.2: Menu Page

Dept. of CSE, SJBIT 2022-23 15


Flowing Fountain

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.

Fig 5.3 Keyboard Controls

This window will show the Flowing Fountain.

Fig 5.4: Flowing Fountain

Dept. of CSE, SJBIT 2022-23 16


Flowing Fountain

CONCLUSION AND FUTURE ENHANCEMENT


An attempt has been made to develop an OpenGL package which meets necessary
requirements of the user successfully. Since it is user friendly, it enables the user to interact
efficiently and easilyThe "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. User can specify these levels as three, four or five at the
beginning.
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 development of the mini project has given us a good exposure to OpenGL by which we
have learnt some of the technique which help in development of animated pictures, gaming.
Hence it is helpful for us even to take up this field as our career too and develop some other
features in OpenGL and provide as a token of contribution to the graphics world.

Dept. of CSE, SJBIT 2022-23 17


Flowing Fountain

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

[3].Edward Angel:Interactive Computer Fraphics-A Top Down approach with OpenGL,5th


edition.Pearson Education,2008

[4].James D Foley,Andries Van Dam,Steven K Feiner,John F Huges Computer Graphics


with OpenGL:Pearson education

[5].M M Raiker & Shreedhara K S Computer Graphics using OpenGL

[6].Programming OpenGL for the X Window System by Addison-Wesley

[7].https://www.opengl.org/

[8].http://www.opengl-tutorial.org/

[9].https://ogldev.org/

Dept. of CSE, SJBIT 2022-23 18

You might also like