0% found this document useful (0 votes)
81 views

1.1 Opengl: Cineplex Arena

This document provides an introduction to OpenGL including: 1. OpenGL is a software interface for graphics hardware that allows specification of 2D and 3D objects through hundreds of functions. 2. OpenGL was developed in the 1990s by SGI as an open standard in response to competitors entering the 3D graphics market. 3. Basic OpenGL operation involves commands passing through a processing pipeline that includes modeling, rasterization, and rendering stages to produce images in the frame buffer.

Uploaded by

Shashank 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)
81 views

1.1 Opengl: Cineplex Arena

This document provides an introduction to OpenGL including: 1. OpenGL is a software interface for graphics hardware that allows specification of 2D and 3D objects through hundreds of functions. 2. OpenGL was developed in the 1990s by SGI as an open standard in response to competitors entering the 3D graphics market. 3. Basic OpenGL operation involves commands passing through a processing pipeline that includes modeling, rasterization, and rendering stages to produce images in the frame buffer.

Uploaded by

Shashank 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/ 21

CINEPLEX ARENA

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.
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
Dept. of CSE, B.I.E.T DVG. Page 1
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 API-compliant
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.
 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.

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.

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

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

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.

 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.
CINEPLEX ARENA

CHAPTER
2 SYSTEM ANALYSIS SYSTEM DESIGN

2.1 SYSTEM ANALYSIS

System analysis and design analysis of project


The software consists of a main program from which the control starts,
and a number of other functions for displaying, initializing and other purposes.
The architecture of the software is explained below.
 The control starts from the main program; the software initializes some
variables and environments and then enters the event driven loop.
 In the event loop, the software waits for an event to occur.

Whenever there is an event, the appropriate action will be taken by the software

2.2 SYSTEM DESIGN


Design of any software depends on the architecture of the machine on
which that software runs, for which the designer needs to know the system
architecture. Design process involves design of suitable algorithms,
modules, subsystems, interfaces etc.
.
2.2.1 CONTROL FLOW DIAGRAM

Dept. of CSE, B.I.E.T DVG. Page 8


CHAPTER 3

SOFTWARE REQUIREMENT SPECIFICATION


In this section the various requirements that are essential for this project are specified. These
requirements have to be fulfilled for execution of the project. The purposes, scope along with hardware
and software requirements are given below.

3.1 USER REQIREMENT


User requirements in project management should be specified in terms of two categories. They are as
follows.
1. Functional requirements
2. Non-functional requirement

3.1.1 Functional requirements:


 Software should have proper, easy to use interface.
 Software should be user friendly and it should not take much time for the user to learn how to use.
 It should be possible to draw any geometric shapes like lines, triangles, polygon in an easy way.
 It should provide at least these colors for usage. Red, Green, Blue, Yellow, White, Magenta, Black.
 It should provide white background to draw objects and pick buttons to pick the tools.

3.1.2 Non-functional requirements:


These are the constraints on the services of functions offered by the system,they include timing
constraints, constraints on the development process and standards and processes. They are:
 The software should be easy to install into the computer.
 It should be very fast and no delay should be present in its operation.
 It should not cause system hanging during any error condition.
 It should be tolerant to user errors.
 It should not create any security problems for the computer.
It should not overload the system
3.2 SYSTEM REQUIREMENT

3.2.1 HARDWARE REQUIREMENTS:


Processor: Intel 386 onwards compatible hardware
RAM: 256MB RAM (minimum)
Hard Disk: 30GB (minimum)
Monitor: VGA compatible
Keyboard: Standard 101 key keyboard

3.2.2 SOFTWARE

REQUIREMENTS: Operating System:


Windows XP onwards Language Tool:
OpenGL
Compiler: Dev-C++
CHAPTER 4
IMPLEMENTATION
The implementation stage of this model involves the following phases.

 ImplementationofOpenGLbuiltinfunctions.

 User defined functionImplementation.

4.1 ImplementationofOpenGLBuiltInFunctions:

1. glutInit ():

glutInitisusedtoinitializetheGLUTlibrary.
Usage:voidglutInit(int*argcp,char**argv);
Description: glutInit will initialize the GLUT library and negotiate a session with the window
system.

2. glutInitDisplayMode():

glutInitDisplayMode sets the initial display mode. Usage: void


glutInitDisplayMode (unsigned int mode);
Mode - Display mode, normally the bitwise OR-ring of GLUT display mode bit masks.
Description: The initial display mode is used when creating top-level windows, sub windows, and
overlays to determine the OpenGL display mode for the to-be-created window or overlay.

3.glutCreateWindow():
glutCreateWindow creates a top-level window. Usage: int
glutCreateWindow(char *name);
Name - ASCII character string for use as window name.

Description:glutCreateWindowcreatesatop-levelwindow.Thenamewillbeprovidedto the window


system as the window's name. The intent is that the window system will label the window with the
name. Implicitly, the current window is set to the newly
createdwindow.EachcreatedwindowhasauniqueassociatedOpenGLcontext.
4.GlutDisplayFunc():

glutDisplayFunc sets the display callback for the current window. Usage:
void glutDisplayFunc(void (*func)(void));
Func - The new display callback function.

Description: glutDisplayFunc sets the display callback for the current window. When GLUT
determines that the normal plane for the window needs to be redisplayed, the display callback for
the window is called. Before the callback, the current window is set to the window needing to be
redisplayed and the layer in use is set to the normal plane.

5.GlutMainLoop ():

glutMainLoopenterstheGLUTeventprocessingloop. Usage:
voidglutMainLoop(void);
Description:glutMainLoopenterstheGLUTeventprocessingloop.Thisroutineshould
becalledatmostonceinaGLUTprogram.Oncecalled,thisroutinewillneverreturn.It
willcallasnecessaryanycallbacksthathavebeenregistered.

6. GlMatrixMode():

Thetwomostimportantmatricesarethemodel-viewandprojectionmatrix.Atanytime, the state


includes values for both of these matrices, which are initially set to identity
matrices.Thereisonlyasinglesetoffunctionsthatcanbeappliedtoanytypeofmatrix.
Selectthematrixtowhichtheoperationsapplybyfirstsetinthematrixmode,avariable
thatissettoonetypeofmatrixandisalsopartofthestate.

7. GlutTimerFunc ();

GlutTimerFunc registers a timer callback to be triggered in a specified number of milliseconds.


Usage:voidglutTimerFunc (unsignedintm/secs,void(*func)(intvalue),value);

Description:glutTimerFuncregistersthetimercallbackfunctobetriggeredinatleast
msecsmilliseconds.Thevalueparametertothetimercallbackwillbethevalueofthe
valueparametertoglutTimerFunc.Multipletimercallbacksatsameordifferingtimes
mayberegisteredsimultaneously.Thenumberofmillisecondsisalowerboundonthe
timebeforethecallbackisgenerated.GLUTattemptstodeliverthetimercallbackas
soonaspossibleaftertheexpirationofthecallback'stimeinterval.

4.1 ImplementationofUserDefinedFunctions:

1. Voidinit(void):

Heretheinitializationfunctioninit()isusedtosettheOpenGLstatevariablesdealing
withviewingandattributes-parametersthatispreferedtosetonce,independentlyofthe
displayfunction.

2. voidSprint(floatx,floaty,char*st):

Thisfunctionisusedtoprintthetextonthevisualizerwindow.Ittakesxandyaspixel
values,whichisthepointonthescreenwherethecharacterisrequiredtobeprintedof
typefont.PositioningisachievedthroughglRasterPos3f(x,y,-1).Ifstringisneededtobe printed then,
find the length of the string needed to be printed and using the loop construct call
glutBitmapCharacter to print the character by character until the loop ends.

3. static void Time Event(intte):


This function is used to rotate the hands (second,minute& hour) as per the angle specified.

This function uses “glutTimerFunc()” that calls back this function once timer ellapses.

4. voidDraw_gear( void):

This function is used to draw the gears of the hands (second,minute& hour) at the back end of the
clock.
This uses “gluCylinder()” and “gluDisk()”to draw the gears of every individual hand.

5. voidDraw_clock(GLfloatcx,GLfloatcy,GLfloatcz):

This function basically draws the whole face of the clock. This includes a round circular board and
three conic geometrics (second, minute & hour).
The face of the clock is drawn using the function “gluDisk()” with the appropriate parameters.
Now the conic geometrics I.e; the second hand, minute hand, and hour hand are drawn using the
functions “glRotatef()” to rotate the hands periodically and “gluCylinder()” with appropriate
parameters to draw the hands of the clock.

6. voidnum():

Thisfunctionistodisplaythenumbers(1to12)alongwithitscorrespondingseconds
onthefaceoftheclock.
This calls the user defined function “Sprint()” with appropriate co-ordinates and numbers.
7. voidabout():

Thisfunctiongivesthedescriptionoftheclockonthevisualizerwindow.
Thisusestheuserdefinedfunction“Sprint()”todisplaythecharacters.
8.voiddisplay_wind_energy():

This function basically renders various views of the clock like ortho view and perspective view
depending upon the “if” condition. Depending upon the input giventheuser defined function
“draw_wind_energy()” and “num()” are called.

9.voidmain(intargc,char**argv):
This is the function from where the execution of the program begins.
In this function we have certain “gl” functions used to initialize the basic glut window
withdesiredproperties.Afterinitializationthedisplayfunctioniscalledwithrespectto
thewindowandfinallythelaststatementofthissectionistheglutMainLoop().

CHAPTER 5
RESULT
5.1 SNAPSHOTS
FIG 5.1: WELCOME PAGE

FIG 5.2: WHEN NO WIND


FIG 5.3: WHEN WIND IS CLOCKWISE

FIG 5.4: WHEN WIND IS ANTI-CLOCKWISE


FIG 5.5: WHEN IS WIND FAST CLOCKWISE

FIG 5.6: WHEN WIND IS FAST ANTI-CLOCKWISE


5.2 FLOWCHART
CINEPLEX ARENA

CHAPTER 6
CONCLUSION
Thus in this project we have acquired a lot of knowledge about
various techniques in OpenGL programming. We have
explored many new concepts on the World Wide Web, such as
Texture mapping, randomizing, color swapping etc.

This control demonstrates a simple use of the Graphics object


in a real world example, which can be combined with other
applications requiring alarms. I have included some more
functionality in my control and also included the demo project
of how to use it and set the real time.
CINEPLEX ARENA

Dept. of CSE, B.I.E.T DVG.


CINEPLEX ARENA

BIBLIOGRAPHY

Books:

Interactive Computer Graphics, 5th Edition, Edward Angel


Computer Graphics and Multimedia, Edit Sharma

Websites:

1. http://www.amazon.in/Computer-Graphics-Multimedia-Udit-
Agarwal/dp/935014316X?tag=googinhydr18418-21
2. http://en.wikipedia.org/wiki/Computer_graphics

3. https://www.youtube.com/watch?v=Hj6-M-Vj0p4

Dept. of CSE, B.I.E.T DVG. Page 20

You might also like