You are on page 1of 17

DEFORESTATION

CHAPTER 1
INTRODUCTION

1.1 Introduction To Computer Graphics


Overview of Computer Graphics The term computer graphics has been used in a broad sense to describe
almost everything on computers that is not text or sound. Typically, the term computer graphics refers to
several different things:
 The representation and manipulation of image data by a computer.
 The various technologies used to create and manipulate images.
 The sub-field of computer science which studies methods for digitally synthesizing and manipulating
visual content.
Today, computers and computer-generated images touch many aspects of daily life. Computer images is
found on television, in newspapers, for example in weather reports, in all kinds of medical investigation and
surgical procedures. A well-constructed graph can present complex statistics in a form that is easier to
understand and interpret. In the media such graphs are used to illustrate papers, reports, thesis, and other
presentation material.Many powerful tools have been developed to visualize data. Computer generated
imagery can be categorized into several different types: 2D, 3D, 4D, 7D, and animated graphics.
As technology has improved, 3D computer graphics have become more common. Computer graphics has
emerged as a sub-field of computer science which studies methods for digitally synthesizing and
manipulating visual content. Over the past decade, other specialized fields have been developed like
information visualization, and scientific visualization more concerned with the visualization of three
dimensional phenomena (architectural, meteorological, medical, biological, etc.), where the emphasis is on
realistic renderings of volumes, surfaces, illumination sources, and so forth, perhaps with a dynamic
component.
1.2 History Of Computer Graphics
In 1959, the TX-2 computer was developed at MIT’s Lincoln Laboratory. The TX-2 integrated a number of
new man-machine interfaces. A light pen could be used to draw sketches on the computer using Ivan
Sutherland’s revolutionary Sketchpad software. Using a light pen, Sketchpad allowed one to draw simple
shapes on the computer screen, save them and even recall them later. The light pen itself had a small
photoelectric cell in its tip. This cell emitted an electronic pulse whenever it was placed in front of a
computer screen and the screen’s electron gun fired directly at it. By simply timing the electronic pulse with
the current location of the electron gun, it was easy to pinpoint exactly where the pen was on the screen at
any given moment. Once that was determined, the computer could then draw a cursor at that location. In

Dept of CSE, SJBIT 2022-23 Page 1


DEFORESTATION

1961 another student at MIT, Steve Russell, created the first video game, E. E. Zajac, a scientist at Bell
Telephone Laboratory (BTL), created a film called ”Simulation of a two-giro gravity attitude control system”
in 1963. During 1970s, the first major advance in 3D computer graphics was created at University of Utah by
these early pioneers, the hidden-surface algorithm. In order to draw a representation of a 3D object on the
screen, the computer must determine which surfaces are ”behind” the object from the viewer’s perspective,
and thus should be ”hidden” when the computer creates (or renders) the image. In the 1980s, artists and
graphic designers began to see the personal computer, particularly the Commodore Amiga and Macintosh, as
a serious design tool, one that could save time and draw more accurately than other methods. In the late
1980s, SGI computers were used to create some of the first fully computer-generated short films at Pixar. The
Macintosh remains a highly popular tool for computer graphics among graphic design studios and businesses.
Modern computers, dating from the 1980s often use graphical user interfaces (GUI) to present data and
information with symbols, icons and pictures, rather than text. Graphics are one of the five key elements of
multimedia technology. 3D graphics became more popular in the 1990s in gaming, multimedia and
animation. In 1996, Quake, one of the first fully 3D games, was released. In 1995, Toy Story, the first full-
length computer-generated animation film, was released in cinemas worldwide. Since then, computer
graphics have only become more detailed and realistic, due to more powerful graphics hardware and 3D
modelling software.
1.3 Applications Of Computer Graphics
The applications of computer graphics can be divided into four major areas:
 Display of information
 Design
 Simulation and animation
 User interfaces
1.3.1 Display Of Information
Computer graphics has enabled architects, researchers and designers to pictorially interpret the vast
quantity of data. Cartographers have developed maps to display the celestial and geographical
information. Medical imaging technologies like Computerized Tomography (CT), Magnetic Resonance
Imaging (MRI), Ultrasound, Positron Emission Tomography (PET) and many others make use of
computer graphics.
1.3.2 Design
Professions such as engineering and architecture are concerned with design. They start with a set of
specification; seek cost-effective solutions that satisfy the specification. Designing is an iterative
process. Designer generates a possible design, tests it and then uses the results as the basis for exploring
other solutions. The use of interactive graphical tools in Computer Aided Design (CAD) pervades the

Dept of CSE, SJBIT 2022-23 Page 2


DEFORESTATION

fields including architecture, mechanical engineering, and the design of very-large-scale integrated
(VLSI) circuits and creation of characters for animation.

1.3.3 Simulation And Animation


Once the graphics system evolved to be capable of generating sophisticated images in real time, engineers and
researchers began to use them as simulators. Graphical flight simulators have proved to increase the safety and
to reduce the training expenses. The field of virtual reality (VR) has opened many new horizons. A human
viewer can be equipped with a display headset that allow him/her to see the images with left eye and right eye
which gives the effect of stereoscopic vision. This has further led to motion pictures and interactive video
games.

1.3.4 User Interfaces


Computer graphics has led to the creation of graphical user interfaces (GUI) using which even naive users are
able to interact with a computer. Interaction with the computer has been dominated by a visual paradigm that
includes windows, icons, menus and a pointing device such as mouse. Millions of people are internet users;
they access the internet through the graphical network browsers such as Microsoft internet explorer and
Mozilla Firefox.

Dept of CSE, SJBIT 2022-23 Page 3


DEFORESTATION

CHAPTER 2

OPENGL
OpenGL (Open Graphics Library) is a standard specification defining a cross-language, crossplatform 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. OpenGL provides a set of commands to render a
three-dimensional scene. That means you provide the data in an OpenGL-useable form and OpenGL will show
this data on the screen (render it). It is developed by many companies and it is free to use. You can develop
OpenGL-applications without licensing. OpenGL is a hardware- and system-independent interface. An
OpenGL-application will work on every platform, as long as there is an installed implementation. Because it is
system independent, there are no functions to create windows etc., but there are helper functions for each
platform. A very useful thing is GLUT.

2.1 OpenGL Libraries


Computer Graphics are created using OpenGL, which became a widely accepted standard software system for
developing graphics applications. 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 (which define geometric objects) or pixels (which define images). OpenGL performs several
processing steps on this data to convert it to pixels to form the final desired image in the frame buffer. OpenGL
stands for ‘open graphics library’ graphics library is a collection of API’s (Applications Programming
Interface). Graphics library functions are:

 GL library (OpenGL in windows) – Main functions for windows.


 GLU (OpenGL utility library) - Creating and viewing objects
 GLUT (OpenGL utility toolkit)- Functions that help in creating interface of windows
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
(although many modes may interact to determine what eventually ends up in the frame buffer). Primitives are
specified, modes are set, and other OpenGL operations are described by issuing commands in the form of
Dept of CSE, SJBIT 2022-23 Page 4
DEFORESTATION

function calls. These libraries are included in the application program using preprocessor directives OpenGL
User Interface Library (GLUI) is a C++ user interface library based on the OpenGL Utility Toolkit (GLUT)
which provides controls such as buttons, checkboxes, radio buttons, and spinners to OpenGL applications. It is
window and operating system independent, relying on GLUT to handle all system-dependent issues, such as
window and mouse management. The OpenGL Utility Library (GLU) is a computer graphics library. It consists
of a number of functions that use the base OpenGL library to provide higher-level drawing routines from the
more primitive routines that OpenGL provides. It is usually distributed with the base OpenGL package.

2.2 OpenGL Contributions

It is very popular in the video games development industry where it competes with Direct3D (on Microsoft
Windows).OpenGL is also used in CAD, virtual reality, and scientific visualization programs. OpenGL is very
portable. It will run for nearly every platform in existence, and it will run well. It even runs on Windows NT
4.0 etc. The reason OpenGL runs for so many platforms is because of its Open Standard. OpenGL has a wide
range of features, both in its core and through extensions. Its extension feature allows it to stay immediately
current with new hardware features, despite the mess it can cause.

2.3 Limitations
 OpenGL is case sensitive.
 Line Color, Filled Faces and Fill Color not supported.
 Shadow plane is not supported.

Dept of CSE, SJBIT 2022-23 Page 5


DEFORESTATION

CHAPTER 3

SYSTEM REQUIREMENTS SPECIFICATIONS


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

 Processor: Pentium PC
 RAM: 512 MB
 Hard Disk: 20 GB (approx.)
 Hard disk speed in RPM: 5400 RPM
 Keyboard: QWERTY Keyboard
 Mouse: 2 or 3 Button mouse
 Monitor: 1024 x 768 display resolution

3.2 Software Requirements

 Programming language – C/C++ using OpenGL


 Operating system – Windows98SE/2000/XP/Vista/UBUNTU
 Compiler/IDE - Code::Blocks IDE
 Graphics library – GL/glut.h
 OpenGL 2.0

Dept of CSE, SJBIT 2022-23 Page 6


DEFORESTATION

CHAPTER 4

SYSTEM DESIGN
4.1 Header Files
 #include<stdio.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 stdlib in C++. The name "stdlib" stands for "standard library”.
 #include<GL/glut>
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.
 #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 floatingpoint 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.

Dept of CSE, SJBIT 2022-23 Page 7


DEFORESTATION

4.2 OpenGL API’s Used


The description of all the functions used in the program is given below:
 void glutInitDisplayMode(unsigned int mode):This function requests a display with the properties in
mode. The value of mode is determined by the logical OR of options including the color model (GLUT
RGB, GLUT INDEX) and buffering (GLUT SINGLE, GLUT DOUBLE).
 void glutInitWindowPosition(int x, int y):This specifies the initial position of top-left corner of the
windows in pixels.
 void glutInitWindowSize(int width, int height): This function specifies the initial height and width of
the window in pixels.
 void glutCreateWindow(char *title):This function creates a window on the display the string title can be
used to label the window. The return value provides a reference to the window that can be used when
there are multiple windows.
 void glutDisplayFunc(void (*func)(void)):This function registers the display func that is executed when
the window needs to be redrawn.
 void glClearColor(GLclampfr,GLclampfg GLclampfb,GLclampf a):This sets the present RGBA
clear colour used when clearing the colour buffer. Variables of type GLclampf are floating point numbers
between 0.0 and 1.0.
 void glutBitmapCharacter(void *font, int character):This renders a bitmap character using OpenGL. It
automatically sets the OpenGL unpack pixel storage modes it needs appropriately and saves and restores
the previous modes before returning. The generated call to glBitmap will adjust the current raster position
based on the width of the character.
 void glRasterPos3f(GLfloat x,GLfloat y,GLfloat z):This specify the raster position for pixel operations.
The parameters specify the x, y, z, and w object coordinates (if present) for the raster position.
 int glutCreateMenu(void (*func)(int value)): This creates a new pop-up menu. The callback function
for the menu that is called when a menu entry from the menu is selected. The value passed to the callback
is determined by the value for the selected menu entry.
 void glutReshapeFunc(void (*func)(int width, int height)):This sets the reshape callback for the current
window. The reshape call back is triggered when a window is reshaped. A reshape callback is also
triggered immediately before a window’s first display call back after a window is created or whenever an
overlay for the window is established.

Dept of CSE, SJBIT 2022-23 Page 8


DEFORESTATION

 void glutIdleFunc(void (*func)(void)):This sets the global idle callback to be func so a GLUT program
can perform background processing tasks or continuous animation when window system events are not
being received. If enabled, the idle call back is continuously called when events are not being received.
 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.
 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.

Dept of CSE, SJBIT 2022-23 Page 9


DEFORESTATION

CHAPTER 5
IMPLEMENTATION
5.1 Code Snippet
//Drawing sun Code:

 Define colors and attributes: Determine the colors you want to use for drawing the sun. Typically, the sun is
depicted with a bright yellow color. You may also want to define attributes such as line width or fill
properties.
 Begin drawing: Start by drawing the core of the sun, which is typically a circle. You can use a circle-
drawing function or method provided by your CG library.
 Creating of an SUN object,

void draw_object()
{
int l;
{
for (l = 0; l <= 35; l++)
{
glColor3f(1.0, 0.9, 0.0);
draw_circle(700, 600, l);
}
}

//Cloud Code
 Create 2 clouds named as cloud1 and cloud2.
 The code uses the glColor3f() function to set the color of the cloud to white.
 The draw_circle() function is used to draw circles of different sizes at different positions on the screen.

void draw_object()
{
int l;
{

Dept of CSE, SJBIT 2022-23 Page 10


DEFORESTATION

if (m < 300)
{
//cloud 1
for (l = 0; l <= 20; l++)
{
glColor3f(1.0, 1.0, 1.0);

draw_circle(160 + m, 625, l);


}
for (l = 0; l <= 35; l++)
{
glColor3f(1.0, 1.0, 1.0);
draw_circle(200 + m, 625, l);
draw_circle(225 + m, 625, l);
}
for (l = 0; l <= 20; l++)
{
glColor3f(1.0, 1.0, 1.0);
draw_circle(265 + m, 625, l);
}

//cloud2
for (l = 0; l <= 20; l++)
{
glColor3f(1.0, 1.0, 1.0);
draw_circle(370 + m, 615, l);
}
for (l = 0; l <= 35; l++)
{
glColor3f(1.0, 1.0, 1.0);
draw_circle(410 + m, 615, l);
draw_circle(435 + m, 615, l);
draw_circle(470 + m, 615, l);
}
}

Dept of CSE, SJBIT 2022-23 Page 11


DEFORESTATION

//Drawing Boat Code:


 The code uses the glColor3f() function to set the color of the boat.
 The glBegin() function is used to begin drawing a polygon.
 The glVertex2f() function is used to specify the vertices of the polygon.
 The glEnd() function is used to end drawing the polygon.
 The code uses two polygons to draw the boat. The first polygon is used to draw the bigger part of the boat
and the second polygon is used to draw the smaller part of the boat.

void object()
{
Int l;
if (boat < 500)
{
//boat bigger part
glColor3f(0.2, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(647 - boat, 66);
glVertex2f(811 - boat, 66);
glVertex2f(830 - boat, 102);
glVertex2f(588 - boat, 102);
glEnd();
//boat small part
glColor3f(0.2, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(815 - boat, 102);
glVertex2f(815 - boat, 114);
glVertex2f(772 - boat, 114);
glVertex2f(772 - boat, 102);
glEnd();

//Road Drawing Code:


glBegin(GL_POLYGON);
glVertex2f(1100, 0);
glVertex2f(0, 0);
glVertex2f(0, 160);

Dept of CSE, SJBIT 2022-23 Page 12


DEFORESTATION

glVertex2f(1100, 160);
glEnd();

//Divider Drawing Code:


It uses three polygons to draw the road. The first polygon is used to draw the main part of the road and the
other two polygons are used to draw the dividers on the road.
Vertex2f
glBegin(GL_POLYGON);
glVertex2f(950, 40);
glVertex2f(730, 40);
glVertex2f(730, 60);
glVertex2f(950, 60);
glEnd();

//MyInit Code:

 The glClearColor() function is used to set the background color of the window.


 It uses three polygons to draw the road. The first polygon is used to draw the main part of the road and the
other two polygons are used to draw the dividers on the road.Vertex2
 The glColor3f() function is used to set the color of the points that will be drawn.
 The glPointSize() function is used to set the size of the points that will be drawn.
 The glMatrixMode() function is used to specify which matrix stack is the target for subsequent matrix
operations.
 The glLoadIdentity() function is used to replace the current matrix with the identity matrix.
 The gluOrtho2D() function is used to specify a two-dimensional orthographic viewing region.

void myinit(){
glClearColor(1.0, 1.0, 1.0, 1.0);
glColor3f(0.0, 0.0, 1.0);
glPointSize(2.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1100.0, 0.0, 700.0);
}

Dept of CSE, SJBIT 2022-23 Page 13


DEFORESTATION

CHAPTER 6
RESULT
6.1 Snapshots
The project designed has been tested for its working, and is found to be working properly to meet all its
requirements.

The designed project has been tested for errors and has been found to be meeting all the requirements of
design with which it was started. Thus, the project is declared to be working properly.

Working of the project is explained through snapshots as follows.

FOREST PAGE

Fig 6.1 Forest Page

Dept of CSE, SJBIT 2022-23 Page 14


DEFORESTATION

 The figure 6.1 shows the Forest page of the project.


 “A forest is a living thing like a human body.
 Each part dependent on all the other parts.”
 A forest is an area of land dominated by trees.

BUILD ROADS PAGE

Fig 6.2 Build Roads Page

 The figure 6.2 shows the Build Roads Page of the project.
 It will build roads to access more and more remote forests that leads Deforestation.
 It shows buildings and roads which are constructed by humans.

Dept of CSE, SJBIT 2022-23 Page 15


DEFORESTATION

TREES AND CONSTRUCTING PAGE

Fig 6.3 Trees and Constructing Page

 The figure 6.3 shows the Trees and constructing Page of the project.
 It shows buildings and roads which are constructed by humans.

CONCLUSION
In conclusion, creating a mini project that abstracts a traffic signal using computer graphics (CG) involves
setting up a canvas or window, drawing the background and signal lights, defining signal states, implementing
state transitions, and optionally handling user interaction. By following these steps, you can create a simple yet
effective representation of a traffic signal. Remember to choose appropriate colors and design the logic for state
transitions based on standard traffic signal behavior. Feel free to explore additional features to enhance the
project, such as pedestrian signals or zcountdown timers. The specific implementation details will depend on
the programming language and graphics library you choose to use. Have fun creating your mini project
 Set up the graphics context: Initialize the graphics library and create a window or canvas to draw the traffic
signal.
 .Define colors and attributes: Determine the colors you want to use for the traffic signal lights, such as red,
yellow, and green. You may also want to define attributes like the size and position of the signal lights.
 Begin drawing: Draw the outline of the traffic signal structure using lines, rectangles, or polygons. Position the
signal lights appropriately within the structure.

Dept of CSE, SJBIT 2022-23 Page 16


DEFORESTATION

Dept of CSE, SJBIT 2022-23 Page 17

You might also like