You are on page 1of 18

INDEX

Sl. no Page no.


1.INTRODUCTION 2-11

2.ABOUT THE PROJECT 12

3.LITERATURE SURVEY 13-14

4. SYSTEM REQUIREMENTS 15

5.DESIGN 16-17

6.IMPLEMENTATION 18-19

7.RESULT AND SNAPSHOTS 19-21

8.BIBLIOGRAPHY 22

1
1.INTRODUCTION

1.1 Computer Graphics

Graphics provides one of the most natural means of communicating with a computer, since
our highly developed 2D and 3D pattern recognition abilities allow us to perceive and process
pictorial data rapidly and efficiently. Interactive computer graphics is the most important
means of producing pictures since the invention of photography and television. It has the
added advantage that, with the computer, we can make pictures not only of concrete real
world objects but also of abstract, synthetic objects, such as mathematical surfaces and of
data that have no inherent geometry, such as survey results.

Digital images include both vector images and raster images, but raster images are more
commonly used. In the enlarged portion of the image individual pixels are rendered as
squares and can be easily seen.

In digital imaging, a pixel (or picture element) is a single point in a raster image. Pixels are
placed on a regular 2-dimensional grid, and are often represented using dots or squares. Each
pixel is a sample of an original image, where more samples typically provide a more accurate
representation of the original. The intensity of each pixel is variable; in color systems, each
pixel has typically three components such as red, green, and blue. May be the objective,
association with other cultural elements may be sought, or merely, the creation of a
distinctive style.

Applications of computer graphics


We can classify applications of computer graphics into four main areas:
Display of information
Design
Simulation
User interfaces

Although many applications span two, three, or even all of these areas, the development of
the field was based, for the most part, on separate work in each domain.
Display of information: graphics has always been associated with the display of
information. Example of the use of orthographic projections to display floor plans of
buildings can be found on 4000 year old Babylonian stone tablets. Mechanical methods for
creating perspective drawing were developed during the renaissance. Countless engineering
students have become familiar with interpreting data plotted on log paper. More recently,
software packages that allow interactive design of charts incorporating color, multiple data
sets, and alternate plotting methods have become the norm. in field such as architecture and
mechanical design, hand drafting is being replaced by computer-based
drafting systems using plotter and workstations. Medical imaging uses computer graphics in a
number of exciting ways.

2
Recently there has been great interest in problems of science visualization. Although
researchers are now using supercomputer to solve formerly intractable problems in the field
such as fluid flow and molecular biology, they need new display techniques to interpret the
results of multidimensional data generated.

Design: professions such as engineering and architecture are concerned with design.
Although their applications vary, most designers face similar difficulties and use similar
methodologies. One of the principal characteristics of most design problem is the lack of a
unique solution. Hence, the design and then will modify it, possibly many times, in an
attempt to achieve a better solution. Computer graphics has become an indispensable element
in this interactive process.

Consider for example how computer graphics might enter into the design of an electronic
circuit. The designer is seated at a graphical input device, such as mouse, with which she can
indicate locations on the display. The initial display screen might consist of the various
elements that can be used in the circuit and an empty area in which the circuit will be
constructed. The designer will then use the input device to select and move the desire
elements into the design and to make connections between elements. To form this initial
design, the system makes sophisticated use of computer graphics. Circuit elements are drawn,
and perhaps are moved about the screen. A graphic input device is used to indicate choice and
positions. A number of aids may be used to help the designer position the elements accurately
and to do automatically such as routing of wires.
At this point, the designer probably will want to test her design. The circuit will be tested by
an analysis program, which will display its result on the workstation. Now the designer can
modify the design as necessary, try another design, or accept what has already been done. The
designer never had to write a graphics program or even to know much about computer
graphics, yet without computer graphics, this design process would not be possible.
Simulation: some of the most impressive and familiar uses of computer graphics can be
classified as simulations. Video games demonstrate both the visual appeal of computer
graphics and our ability to generate complex imagery in real time. The insides of an arcade
game reveal state-of-the-art hardware and software.
Computer-generated images are also the heart of flight simulators, which have become the
standard method for training pilots. The savings in dollars and lives realized from use of these
simulators has been enormous. The computer-generated images we see on television and in
movies have advanced to the point that they are almost indistinguishable from real-world
image.

Concepts And Principles


Rendering
Rendering is the generation of a 2D image from a 3D model by means of computer programs.
A scene file contains objects in a strictly defined language or data structure; it would contain
geometry, viewpoint, texture, lighting, and shading information as a description of the virtual
scene. The data contained in the scene file is then passed to a rendering program to be
processed and output to a digital image or raster graphics image file. The rendering program
is usually built into the computer graphics software, though others are available as plug-ins or
entirely separate programs. The term "rendering" may be by analogy with an "artist's
rendering" of a scene. Though the technical details of rendering methods vary, the general
challenges to overcome in producing a 2D image from a 3D representation stored in a scene

3
file are outlined as the graphics pipeline along a rendering device, such as a GPU. A GPU is a
device able to assist the CPU in calculations. If a scene is to look relatively realistic and
predictable under virtual lighting, the rendering software should solve the rendering equation.
The rendering equation does not account for all lighting phenomena, but is a general lighting
model for computer-generated imagery. 'Rendering' is also used to describe the process of
calculating effects in a video editing file to produce final video output.

3D projection
3D projection is a method of mapping three dimensional points to a two dimensional plane.
As most current methods for displaying graphical data are based on planar two dimensional
media, the use of this type of projection is widespread, especially in computer graphics,
engineering and drafting.

Ray tracing
Ray tracing is a technique for generating an image by tracing the path
of light through pixels in an image plane. The technique is capable of producing a very high
degree of photorealism; usually higher than that of typical scanline rendering methods, but at
a greater computational cost.

Shading
Shading refers to depicting depth in 3D models or illustrations by varying levels of darkness.
It is a process used in drawing for depicting levels of darkness on paper by applying media
more densely or with a darker shade for darker areas, and less densely or with a lighter shade
for lighter areas. There are various techniques of shading including cross hatching where
perpendicular lines of varying closeness are drawn in a grid pattern to shade an area. The
closer the lines are together, the darker the area appears. Likewise, the farther apart the lines
are, the lighter the area appears. The term has been recently generalized to mean
that shadersare applied.

Texture mapping
Texture mapping is a method for adding detail, surface texture, or colour to a computer-
generated graphic or 3D model. Its application to 3D graphics was pioneered by Dr Edwin
Catmull in 1974. A texture map is applied (mapped) to the surface of a shape, or polygon.
This process is akin to applying patterned paper to a plain white box. Multitexturing is the
use of more than one texture at a time on a polygon. Procedural textures (created from
adjusting parameters of an underlying algorithm that produces an output texture), and bitmap
textures (created in an image editing application or imported from a digital camera) are,
generally speaking, common methods of implementing texture definition on 3D models in
computer graphics software, while intended placement of textures onto a model's surface
often requires a technique known as UV mapping (arbitrary, manual layout of texture
coordinates) for polygon surfaces, while NURBS surfaces have their own
intrinsic parameterization used as texture coordinates. Texture mapping as a discipline also
encompasses techniques for creating normal maps and bump maps that correspond to a

4
texture to simulate height and specular maps to help simulate shine and light reflections, as
well as environment mapping to simulate mirror-like reflectivity, also called gloss.

Anti-aliasing
Rendering resolution-independent entities (such as 3D models) for viewing on a raster (pixel-
based) device such as a liquid-crystal display or CRT television inevitably causes aliasing
artifacts mostly along geometric edges and the boundaries of texture details; these artifacts
are informally called "jaggies". Anti-aliasing methods rectify such problems, resulting in
imagery more pleasing to the viewer, but can be somewhat computationally expensive.
Various anti-aliasing algorithms (such as supersampling) are able to be employed, then
customized for the most efficient rendering performance versus quality of the resultant
imagery; a graphics artist should consider this trade-off if anti-aliasing methods are to be
used. A pre-anti-aliased bitmap texture being displayed on a screen (or screen location) at a
resolution different than the resolution of the texture itself (such as a textured model in the
distance from the virtual camera) will exhibit aliasing artifacts, while any procedurally
defined texture will always show aliasing artifacts as they are resolution-independent;
techniques such as mipmapping and texture filtering help to solve texture-related aliasing
problems.

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 3D
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
direct 3D on Microsoft Windows Platforms. OpenGL is managed by the non profit
technology consortium, the Khronos group Inc.
OpenGL serves two main purposes :
To hide the complexities of interfacing with different 3D accelerators, by presenting
programmer with a single, uniform API
To hide the differing capabilities of hardware platforms , by requiring that all
implementations support the full OpenGL feature set.

OpenGL has historically been influential on the development of 3D accelerator, promoting a


base level of functionality that is now common in consumer level hardware:
Rasterized points, lines and polygons are basic primitives.
A transform and lighting pipeline .
Z buffering .
Texture Mapping.
Alpha Blending.

5
OPENGL was developed by silicon graphics Inc. (SGI) in 1992 and is widely used in CAD,
virtual reality, scientific virtualization, flight simulation. It is also used in video games, where
it completes with direct3D on Microsoft window platforms. OPENGL is managed by the by
the non-profit technologyconsortium, group.
The figure specifies the order of operation in OPENGL rendering pipelines. It consist the
following components:
Display list
Evaluator
Per-vertex operation and primitive assembly
Rasterization
Pre-fragment operation
Frame buffer
Texture memory
Pixel operation

TO ACCESS GLUT IN DEV-C++

1. Click File/New/Project. Pick a name or project (such as myProject). Click C Project.


Click on Empty Project. Click OK.
2. In Create New Project click save.
3. Click File/new/source File and in Add source file to current project click YES. You
now get a screen where you can edit the source file.
4. Type in a simple C Program. Now click File/Save As and save the file as hello.c(or
other name) Important be sure that file extension is .c/cpp With any other extension(such as
suggested .cpp) you will have problems compling.
5. Tell Dec-Cpp what libraries need to be lined. Click Project/Project Options.
6. Now click Parameters. Click the Add Library or Object button and navigate to the
libraries that should be added, found under C: Dev-Cpp lib.
/lib/libglut32.a
/lib/libglut32.a
/lib/libopengl32.a

6
OpenGL Graphics Architecture :

All data, whether it describes geometry or pixels, can be saved in a display list for current or
later use. When a display list is executed, the retained data is sent from the display list just as
if it were sent by the application in immediate mode.
Early graphics system used general purpose computers with the standard Von
Neumannarchitecture, such computer are characterized by a single processing unit that
processes a single instruction at a time. The display in these systems was based on a
calligraphic CRT display that included the necessary circuitry to generate the line segment
connecting to points. The job of first computer was to run the applications program and to

7
compute the end points of the segment in the image. This information had to be sent to the
display at a rate high enough to avoid flickers on the display.

Display Lists :
All data, whether it describes geometry or pixels, can be saved in a display list for current or
later use. When a display list is executed, the retained data is sent from the display list just as
if it were sent by the application in immediate mode.Display list is a group of OpenGL
commands that have been stored (compiled) for later execution. Once a display list is created,
all vertex and pixel data are evaluated and copied into the display list memory on the server
machine. It is only one time process. After the display list has been prepared (compiled), you
can reuse it repeatedly without re-evaluating and re-transmitting data over and over again to
draw each frame. Display list is one of the fastest methods to draw static data because vertex
data and OpenGL commands are cached in the display list and minimize data transmissions
from the client to the server side. It means that it reduces CPU cycles to perform the actual
data transfer.

Evaluators :

8
All geometric primitives are eventually described by vertices. Parametric curves and surfaces
may be initially described by control points and polynomial functions called basis functions.

Per Vertex Operations :


For vertex data, next is the "per-vertex operations" stage, which converts the vertices into
primitives. Some vertex data are transformed by 4 x 4 floating-point matrices. Spatial
coordinates are projected from a position in the 3D world to a position on your screen.

Primitive Assembly :
Clipping, a major part of primitive assembly, is the elimination of portions of geometry which
fall outside a half space, defined by a plane.

Pixel Operation:
While geometric data takes one path through the OpenGL rendering pipeline, pixel data takes
a different route. Pixels from an array in system memory are first unpacked from one of a
variety of formats into the proper number of components. Next the data is scaled, biased, and
processed by a pixel map. The results are clamped and then either written into texture
memory or sent to the rasterization step.

9
2.ABOUT THE PROJECT
This Project is on 3D RACING CAR SIMULATION Computer Graphics using OpenGL
Functions. It is a User interactive program where in the User can view the required display by
making use of the input devices like Keyboard and Mouse. This project mainly consists of an
3D racing car on which a robot sits. The bike can be viewed in any direction using Keyboard.
The car movement is automatic.

User interface

A set of keys are used to change the following:

G or g: To start or continue

E or e: To Stop

H or h : Helicopter View

B or b : Back View

S or s : Side View

F or f: Front View

OBJECTIVE:
1.The aim of the project is to demonstrate the 3D Racing Car Simulation with multiple views.
2.As Linux doesnt provide graphics editor, it should be designed in such a way that it
provides a very useful graph implementation interface.
3.It should be easy to understand, user interactive interface.
4.Creation of primitives, i.e. polygons
5.Providing human interaction through Mouse and keyboard.

10
3. LITERATURE SURVEY
Computer graphics started with the display of data on hardcopy plotters and cathode ray tube
(CRT) screens soon after the introduction of computers.
Computer graphics today largely interactive, the user controls the contents, structure, and
appearance of objects and of displayed images by using input devices, such as keyboard,
mouse, or touch-sensitive panel on the screen. Graphics based user interfaces allow millions
of new users to control simple, low-cost application programs, such as spreadsheets, word
processors, and drawing programs.

OpenGL (Open Graphics Library) 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 (see Direct3D vs.
OpenGL). OpenGL is managed by the non-profit technology consortium, the Khronos Group.

In the 1980s, developing software that could function with a wide range of graphics hardware
was a real challenge. By the early 1990s, Silicon Graphics (SGI) was a leader in 3D graphics
for workstations. SGI's competitors (including Sun Microsystems, Hewlett-Packard and IBM)
were also able. 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 to bring to market 3D hardware,
supported by extensions made to the PHIGS standard. In 1992, SGI led the creation of the
OpenGL architectural review board (OpenGL ARB).

OpenGL specification took for years to come. On 17 December 1997, Microsoft and SGI
initiated the Fahrenheit project, which was a joint effort with the goal of unifying the
OpenGL and Direct3D interfaces (and adding a scene-graph API too). In 1998 Hewlett-
Packard joined the project.[4] It initially showed some promise of bringing order to the world
of interactive 3D computer graphics APIs, but on account of financial constraints at SGI,
strategic reasons at Microsoft, and general lack of industry support, it was abandoned in
1999[8].
Many opengl functions are used for rendering and transformation purposes. Transformations
functions like glRotate (), glTranslate (), glScaled () can be used.
OpenGL provides a powerful but primitive set of rendering command, and all higher-level
drawing must be done in terms of these commands. There are several libraries that allow you
to simplify your programming tasks, including the following:

OpenGL Utility Library (GLU) contains several routines that use lower-level OpenGL
commands to perform such tasks as setting up matrices for specific viewing orientations and
projections and rendering surfaces.
OpenGL Utility Toolkit (GLUT) is a window-system-independent toolkit, written by Mark
Kill guard, to hide the complexities of differing window APIs.
To achieve the objective of the project, information related to the light sources is required
with OpenGL we can manipulate the lighting and objects in a scene to create many different
kinds of effects. It explains how to control the lighting in a scene, discusses the OpenGL

11
conceptual model of lighting, and describes in detail how to set the numerous illumination
parameters to achieve certain effects.
The properties of a light source like its material, diffuse, emissive, has to mention in the
project. So to design the light source and the objects, programming guide of an OpenGL is
used.

12
4.SYSTEM REQUIREMENTS SPECIFICATION
SOFTWARE REQUIREMENTS

Minimum software specification


Operating system : Windows
Tool Used : Dev C++
OPENGL Library

X86
X64(WOW)
Mouse Driver
Graphics Driver
C++ Language

FUNCTIONAL REQUIREMENTS:

OpenGL APIs:
If we want to have a control on the flow of program and if we want to interact with the
window system then we use OpenGL APIS. Vertices are represented in the same manner
internally, whether they are specified as two-dimensional or three-dimensional
entities,everything that we do are here will be equally valid in three dimensions. Although
OpenGLis easy to learn, compared with other APIs, it is nevertheless powerful. It supports
the simplethree dimensional programs and also supports the advanced rendering techniques.

GL/glut.h:
We use a readily available library called the OpenGL Utility Toolkit (GLUT), whichprovides
the minimum functionality that should be expected in any modern windowingsystem.The
application program uses only GLUT functions and can be recompiled with the GLUTlibrary
for other window system. OpenGL makes a heavy use of macros to increase codereadability
and avoid the use of magic numbers. In most implementation, one of the include lines.

13
5.DESIGN
EXISTING SYSTEM
Existing system for a graphics is the TC++. This system will support only the 2D graphics.
2D graphics package being designed should be easy to use and understand. It should provide
various options such as free hand drawing, line drawing, polygon drawing, filled polygons,
flood fill, translation, rotation, scaling, clipping etc. Even though these properties were
supported, it was difficult to render 2D graphics cannot be very difficult to get a 3
Dimensional object. Even the effects like lighting, shading cannot be provided. So we go for
Microsoft Visual Studio software.

PROPOSED SYSTEM
To achieve three dimensional effects, open GL software is proposed. It is software which
provides a graphical interface. It is a interface between application program and graphics
hardware. The advantages are:
1. Open GL is designed as a streamlined.
2. Its a hardware independent interface i.e it can be implemented on many different hardware
platforms.
3. With openGL we can draw a small set of geometric primitives such as points, lines and
polygons etc.
4. It provides double buffering which is vital in providing transformations.
5. It is event driven software.
6. It provides call back function.

14
15
6.IMPLEMENTATION
OPengl Functions

glColor3f (float, float, float) :- This function will set the current drawing color

gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top):- which
defines a two dimensional viewing rectangle in the plane z=0.

glClear( ):-Takes a single argument that is the bitwise OR of several values indicating which
buffer is to be cleared.

glClearColor ():-Specifies the red, green, blue, and alpha values used by glClear to clear the
color buffers.

GlLoadIdentity( ):-the current matrix with the identity matrix.

glMatrixMode(mode):-Sets the current matrix mode, mode can be GL_MODELVIEW,


GL_PROJECTION or GL_TEXTURE.

Void glutInit (int *argc, char**argv):-Initializes GLUT, the arguments from main are
passed in and can be used by the application.

Void glutInitDisplayMode (unsigned int mode):-Requests a display with the properties in


mode. The value of mode is determined by the logical OR of options including the color
model and buffering.

Int glutCreateWindow (char *title):-A window on the display. The string title can be used
to label the window. The return value provides references to the window that can be used
when there are multiple windows.

Void glutMouseFunc(void *f(int button, int state, int x, int y):-Register the mouse
callback function f. The callback function returns the button, the state of button after the
event and the position of the mouse relative to the top-left corner of the window.

Void glutDisplayFunc (void (*func) (void)):-Register the display function func that is
executed when the window needs to be redrawn.

glut PostReDisplay ( ) :-which requests that the display callback be executed after the
current callback returns.

Void MouseFunc (void (*func) void)):-This function is invoked when mouse keys are
pressed. This function is used as an alternative to the previous function i.e., it is used to move
the object(car) to right or left in our program by clicking left and right button respectively.

Void glutMainLoop ()
Cause the program to enter an event-processing loop. It should be the last statement in main
function.

16
USER DEFINED FUNCTIONS

Void cone(): It is Function to generate a cone.It is used to make trees.

Void track():It is Function to draw the track.

Void cylinder(): It is a Function that generates a cylinder.

Void tree(): Function that generates tree with cone shaped tree top.

Void tree 2():Function that generates tree with sphere shaped tree top.

Void alloy():Function to generate the sides of the tyres.

Void actall():Function to draw the spokes of the wheel.

Void driver()Function to generate car driver by using circle and rectangle function .

Void scenery(): Function generating scenery using functions track( ),tree( ),tree2( ).

Void view(): Function that generates a particular view of scene depending on view selected
by user.

17
8.BIBLIOGRAPHY

[1] Edward Angels Interactive Computer Graphics Pearson Education 5th Edition

[2] Interactive computer Graphics --A top down approach using open GL--by
Edward Angle

[3] Jackie .L. Neider, Mark Warhol, Tom.R.Davis, "OpenGL Red Book", Second
Revised Edition, 2005.

[4] openglprojects.com

[5]https://www3.ntu.edu.sg/home/ehchua/programming/opengl/CG_Introduction.html

[6] stackoverflow.com

18

You might also like