Professional Documents
Culture Documents
CHAPTER 1
INTRODUCTION
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
fields including architecture, mechanical engineering, and the design of very-large-scale integrated
(VLSI) circuits and creation of characters for animation.
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.
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.
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.
CHAPTER 3
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
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.
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.
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;
{
if (m < 300)
{
//cloud 1
for (l = 0; l <= 20; l++)
{
glColor3f(1.0, 1.0, 1.0);
//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);
}
}
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();
glVertex2f(1100, 160);
glEnd();
//MyInit Code:
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);
}
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.
FOREST 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.
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.