0% found this document useful (0 votes)
1K views22 pages

1.1 Opengl: Rain Water Harvesting

This document discusses rain water harvesting. It begins by introducing OpenGL, which is a software interface for graphics hardware that allows specification of objects and operations to produce color images. The history of OpenGL is then discussed, noting how it originated from SGI's IRIS GL and was opened as an industry standard. Key features of OpenGL are listed, including being industry standard, stable, portable, evolving, scalable, easy to use, and well-documented. The basic OpenGL operation and processing pipeline is illustrated and described. Finally, the OpenGL interface is discussed, noting the main GL library as well as GLU and GLUT libraries used to access OpenGL functionality.

Uploaded by

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

1.1 Opengl: Rain Water Harvesting

This document discusses rain water harvesting. It begins by introducing OpenGL, which is a software interface for graphics hardware that allows specification of objects and operations to produce color images. The history of OpenGL is then discussed, noting how it originated from SGI's IRIS GL and was opened as an industry standard. Key features of OpenGL are listed, including being industry standard, stable, portable, evolving, scalable, easy to use, and well-documented. The basic OpenGL operation and processing pipeline is illustrated and described. Finally, the OpenGL interface is discussed, noting the main GL library as well as GLU and GLUT libraries used to access OpenGL functionality.

Uploaded by

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

RAIN WATER HARVESTING

CHAPTER 1
INTRODUCTION
1.1 OPENGL
OpenGL is the abbreviation for Open Graphics Library. It is a software interface for
graphics hardware. This interface consists of several hundred functions that allow you, a graphics
programmer, to specify the objects and operations needed to produce high-quality color images
of two-dimensional and three-dimensional objects. Many of these functions are actually simple
variations of each other, so in reality there are about 120 substantially different functions.The
main purpose of OpenGL is to render two-dimensional and three-dimensional objects into the
frame buffer. These objects are defined as sequences of vertices (that define geometric objects)
or pixels (that define images).OpenGL performs several processes on this data to convert it to
pixels to form the final desired image in the frame buffer.

1.2 HISTORY
As a result, SGI released the OpenGL standard In the 1980s, developing software that
could function with a wide range of graphics hardware was a real challenge. Software developers
wrote custom interfaces and drivers for each piece of hardware. This was expensive and resulted
in much duplication of effort.

By the early 1990s, Silicon Graphics (SGI) was a leader in 3D graphics for workstations.
Their IRIS GL API was considered the state of the art and became the de facto industry standard,
overshadowing the open standards-based PHIGS. This was because IRIS GL was considered
easier to use, and because it supported immediate mode rendering. By contrast, PHIGS was
considered difficult to use and outdated in terms of functionality.

SGI's competitors (including Sun Microsystems, Hewlett-Packard and IBM) were also
able to bring to market 3D hardware, supported by extensions made to the PHIGS standard. This
in turn caused SGI market share to weaken as more 3D graphics hardware suppliers entered the
market. In an effort to influence the market, SGI decided to turn the Iris GL API into an open
standard.

CS&E Dept, B.I.E.T, Davangere 1


RAIN WATER HARVESTING

SGI considered that the Iris GL API itself wasn't suitable for opening due to licensing and
patent issues. Also, the Iris GL had API functions that were not relevant to 3D graphics. For
example, it included a windowing, keyboard and mouse API, in part because it was developed
before the X Window System and Sun's NEWSsystems were developed.

In addition, SGI had a large number of software customers; by changing to the OpenGL
API they planned to keep their customers locked onto SGI (and IBM) hardware for a few years
while market support for OpenGL matured. Meanwhile, SGI would continue to try to maintain
their customers tied to SGI hardware by developing the advanced and proprietary Iris Inventor
and Iris Performer programming APIs.

1.3 FEATURES OF OPENGL


• Industry standard
An independent consortium, the OpenGL Architecture Review Board, guides the
OpenGL specification. With broad industry support, OpenGL is the only truly open,
vendor-neutral, multiplatform graphics standard.

• Stable
OpenGL implementations have been available for more than seven years on a wide
variety of platforms. Additions to the specification are well controlled, and proposed
updates are announced in time for developers to adopt changes. Backward compatibility
requirements ensure that existing applications do not become obsolete.

• Reliable and portable

All OpenGL applications produce consistent visual display results on any OpenGL
APIcompliant hardware, regardless of operating system or windowing system.

• Evolving
Because of its thorough and forward-looking design, OpenGL allows new hardware
innovations to be accessible through the API via the OpenGL extension mechanism. In
this way, innovations appear in the API in a timely fashion, letting application developers
and hardware vendors incorporate new features into their normal product release cycles.

CS&E Dept, B.I.E.T, Davangere 2


RAIN WATER HARVESTING

• Scalable
OpenGL API-based applications can run on systems ranging from consumer electronics
to PCs, workstations, and supercomputers. As a result, applications can scale to any class
of machine that the developer chooses to target.

• Easy to use
OpenGL is well structured with an intuitive design and logical commands. Efficient
OpenGL routines typically result in applications with fewer lines of code than those that
make up programs generated using other graphics libraries or packages. In addition,
OpenGL drivers encapsulate information about the underlying hardware, freeing the
application developer from having to design for specific hardware features.

• Well-documented
Numerous books have been published about OpenGL, and a great deal of sample code is
readily available, making information about OpenGL inexpensive and easy to obtain.

CS&E Dept, B.I.E.T, Davangere 3


RAIN WATER HARVESTING

1.4 BASIC OPENGL OPERATION

The following diagram illustrates how OpenGL processes data. As shown, commands
enter from the left and proceed through a processing pipeline. Some commands specify
geometric objects to be drawn, and others control how the objects are handled during various
processing stages.

Fig 1.4.1: OpenGL Block Diagram

The processing stages in basic OpenGL operation are as follows:

• Display list

Rather than having all commands proceed immediately through the pipeline, you can
choose to accumulate some of them in a display list for processing later.

• Evaluator

The evaluator stage of processing provides an efficient way to approximate curve and
surface geometry by evaluating polynomial commands of input values.

CS&E Dept, B.I.E.T, Davangere 4


RAIN WATER HARVESTING

• Per-vertex operations and primitive assembly

OpenGL processes geometric primitives - points, line segments, and polygons all of
which are described by vertices. Vertices are transformed, and primitives are clipped to
the viewport in preparation for rasterization.

• Rasterization

The rasterization stage produces a series of frame-buffer addresses and associated


values using a two-dimensional description of a point, line segment, or polygon. Each so
produced is fed into the last stage, per-fragment operations.

• Per-fragment operations

These are the final operations performed on the data before it is stored as pixels in the
frame buffer Per-fragment operations include conditional updates to the frame buffer
based on incoming and previously stored z values (for z buffering) and blending of
incoming pixel colors with stored colors, as well as masking and other logical operations
on pixel values.

• Pixel operation

Input data can be in the form of pixels rather than vertices. Such data which might
describe an image for texture mapping skips the first stage of processing and instead
processed as pixels in the pixel operation stage.

• Texture memory

The result of pixel operation stage is either stored as texture memory for use in
rasterization stage or rasterised and resulting fragment merged into the frame buffer just
as they were generated from the geometric data.

CS&E Dept, B.I.E.T, Davangere 5


RAIN WATER HARVESTING

1.5 THE OPENGL INTERFACE

Most of our applications will be designed to access OpenGL directly through functions in
three libraries. They are

• GL – Graphics Library

Functions in the main GL (or OpenGL in Windows) library have names that begin with
the letters gl and are stored in a library usually referred to as GL (or OpenGL in
Windows).

• GLU – Graphics Utility Library

This library uses only GL functions but contain code for creating common objects and
simplifying viewing. All functions in GLU can be created from the core GL library but
application programmers prefer not to write the code repeatedly. The GLU library is
available in all OpenGL implementations; functions in the GLU library begins with the
letters glu.

• GLUT – OpenGL Utility Toolkit

To interface with the window system and to get input from external devices into our
programs we need at least one more library. For the X window System, this library is
called GLX, for Windows, it is wgl, and for the Macintosh, it is agl. Rather than using a
different library for each system, we use a readily available library called the OpenGL
Utility Toolkit (GLUT) , which provides minimum functionality that should be expected
in any modern windowing system.

CS&E Dept, B.I.E.T, Davangere 6


RAIN WATER HARVESTING

Fig 1.5.1: Library Organization

The above figure shows the organization of the libraries for an X Window System
environment.

In most implementations, one of the include lines

#include<GL/glut.h>

or

#include<GLUT/glut.h>

is sufficient to read in glut.h, gl.h and glu.h.

CS&E Dept, B.I.E.T, Davangere 7


RAIN WATER HARVESTING

1.6 Graphics Functions

Our basic model of a graphics package is a black box, a term that engineers use to denote
a system whose properties are described only by its inputs and outputs; we may know nothing
about its internal workings.

OpenGL functions can be classified into seven major groups:

• Primitive function: The primitive functions define the low-level objects or atomic entities
that our system can display. Depending on the API, the primitives can include points, lines,
polygons , pixels, text, and various types of curves and surfaces.

• Attribute functions
If primitives are the what of an API – the primitive objects that can be displayed- then
attributes are the how. That is, the attributes govern the way the primitive appears on the
display. Attribute functions allow us to perform operations ranging from choosing the
color with which we display a line segment, to picking a pattern with which to fill inside
of a polygon.

• Viewing functions
The viewing functions allow us to specify various views, although APIs differ in the
degree of flexibility they provide in choosing a view.

• Transformation functions
One of the characteristics of a good API is that it provides the user with a set of
transformations functions such as rotation, translation and scaling.

• Input functions
For interactive applications, an API must provide a set of input functions, to allow users
to deal with the diverse forms of input that characterize modern graphics systems. We
need functions to deal with devices such as keyboards, mice and data tablets.

CS&E Dept, B.I.E.T, Davangere 8


RAIN WATER HARVESTING

• Control functions
These functions enable us to communicate with the window system, to initialize our
programs, and to deal with any errors that take place during the execution of our
programs.

• Query functions
If we are to write device independent programs, we should expect the implementation of
the API to take care of the differences between devices, such as how many colors are
supported or the size of the display. Such information of the particular implementation
should be provides through a set of query functions.

CS&E Dept, B.I.E.T, Davangere 9


RAIN WATER HARVESTING

CHAPTER 2

SYSTEM REQUIREMENTS

2.1 Software Requirements

1. Operating System : Microsoft Windows XP,Microsoft Windows 7

2. Compiler used: VC++ 6.0 compiler

3. Language used: C/ C++

2.2 Hardware Requirements

1. Main Processor: PENTIUM III

2. Processor Speed: 800 MHz

3. RAM Size: 128MB DDR

CS&E Dept, B.I.E.T, Davangere 10


RAIN WATER HARVESTING

CHAPTER 3
SYSTEM DESIGN
3.1 Flow Chart
START

Main() ;

myinit();

Display();

If
key=q

If
key=s

Stop If
Drawhouse( ); key=r

PostRedisplay();
Rain();

IdleFunction();

STOP

Fig 3.1 Stages In Rainwater Harvesting

CS&E Dept, B.I.E.T, Davangere 11


RAIN WATER HARVESTING

3.2 Initialization
• Initialize to interact with windows.
• Initialize to display mode that is double buffer and RGB colour system.
• Initialize window position and window size.
• Initialize and create window to display the output.

3.3 Display
• Rainwater Harvesting window will be displayed.
• Menus are created depending on the values returned by the menu.
• The operations performed are:
i. Create home.
ii. Rain.
iii. Exit.

CS&E Dept, B.I.E.T, Davangere 12


RAIN WATER HARVESTING

CHAPTER 4
IMPLEMENTATION
4.1 OVERVIEW
This project is a demonstration of animation on “Rain water harvesting”. We have taken the help
of built in functions present in the header file. To provide functionality to our project we have
written sub functions. These functions provide us the efficient way to design the project. In this
chapter we are describing the functionality of our project using these functions.

4.2 USER INTERFACE


The project which we have done uses the OpenGL function and implemented using C. our project
is to demonstrate RAIN WATER HARVESTING. User can perform operation using keyboard.

Keyboard interaction
1. Firstly, after compiling and running the program we get the display of animation.
2. Then if we press the key s the animation of house is created.
3. If the key “ r” is pressed it starts raining.
4. If the key ”q” is pressed then the process will quit.

4.3 STRUCTURE
 int main(int argc,char**argv)
 void myinit()
 void mykey(unsigned char key,int x,int y)
 void display()
 void rain1()
 void drawhouse()
 void drawpump()
 void drawtank()
 void bitmap()
 void draw_pixel()

CS&E Dept, B.I.E.T, Davangere 13


RAIN WATER HARVESTING

4.3.1 Main function:


int main(int argc,char **argv)

glutInit(&argc,argv);

glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH|GLUT_RGB);

glutInitWindowPosition(0,0);

glutInitWindowSize(1250,750);

glutCreateWindow("RAIN WATERHARVESTING");

myinit();

glutDisplayFunc(display);

glutIdleFunc(idle);

glutKeyboardFunc(mykey);

glutMainLoop();

4.3.2myinit:
void myinit() {

glClearColor(0.0,0.0,0.0,0.0);

glColor3f(1.0,0.0,0.0);

glPointSize(1.0);

glMatrixMode(GL_PROJECTION);

gluOrtho2D(-750.0,400.0,-500.0,400.0);

4.3.3 Keyboard function:


void mykey(unsigned char key,int x,int y)

CS&E Dept, B.I.E.T, Davangere 14


RAIN WATER HARVESTING

{ key2=key;

if(key==27)

exit(0);

if(key=='q'||key=='Q')

exit(0);

if(key=='s'||key=='S') {

drawhouse();

bitmap1();

} if(key=='r'||

key=='R')

count=150;

drawhouse();

rain1();

rain35();

4.3.4 Display
void display()

glClear(GL_COLOR_BUFFER_BIT);

glPointSize(2.0);

bitmap();

if(key2=='q'||key2=='Q')

CS&E Dept, B.I.E.T, Davangere 15


RAIN WATER HARVESTING

exit(0);

if(key2=='s'||key2=='S')

drawhouse();

if(count1>150)

line();

bitmap1(); }

} if(key2=='r'||key2=='R')

count=count+1;

drawhouse();

bitmap();

line();

bitmap1();

if(count<2500)

rain1();

if(count>370&&count<3600)

flow1();

if(count<3620)

CS&E Dept, B.I.E.T, Davangere 16


RAIN WATER HARVESTING

flow2();

if(count>300&&count<4030)

{ disprectangle2();

if(count>3770 && count<4200)

disprec();

if(count>500&&count<3730)

flow3();

if(count>520&&count<3750)

flow4();

if(count>540&&count<3770)

disprectangle();

if(count>1530&&count<4250)

flow5();

if(count>1500&&count<4480)

square();

if(count>1560&&count<4300)

flow6();

if(count>1600&&count<4320)

flow7();

if(count>1620&&count<4340)

flow8();

CS&E Dept, B.I.E.T, Davangere 17


RAIN WATER HARVESTING

if(count>1660&&count<4360)

flow9();

if(count>1690&&count<4380)

flow10(); if(count>1790)

disprectangle1();

} glFlush();

glutSwapBuffers();

4.3.5 Draw Raindrop:

void rain1() {

int k,l;

glPointSize(4.0);

for( k=24;k>=0;k--)

if(rainpoint1[k][1]==-60.0)

rainpoint1[k][1]=400.0;

for( l=1;l<=24;l++)

glBegin(GL_POINTS);

CS&E Dept, B.I.E.T, Davangere 18


RAIN WATER HARVESTING

glColor3f(0.0,0.5,1.0);

glVertex2fv(rainpoint1[l]);

glEnd();

for(i=23;i>=0;i--)

rainpoint1[i][1]=rainpoint1[i][1]-2;

rain3();

CS&E Dept, B.I.E.T, Davangere 19


RAIN WATER HARVESTING

CHAPTER 5
SNAPSHOTS

Fig 5.1:Display Buttons


The above figure shows the initial display buttons to create house, rain and exit.

Fig 5.2:Setup of house and tank


The above figure is the initial setup of the house ,purifier and tank when the s/S button is pressed.

CS&E Dept, B.I.E.T, Davangere 20


RAIN WATER HARVESTING

Fig 5.3: Rainwater flow


This is when the r/R is pressed. When this button is pressed it rains and collected on the roof
of the house.

Fig 5.4: Setup while tank is filling


The above figure shows collection of the water in the purifier and in the ground tank. Water is
pumped up automatically when filled.

CS&E Dept, B.I.E.T, Davangere 21


RAIN WATER HARVESTING

Fig 5.5:Setup after tank is filled


When the tank water is filled, the pump will automatically stop and this is the process of rain water
harvesting.

CS&E Dept, B.I.E.T, Davangere 22

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy