0% found this document useful (0 votes)
127 views25 pages

CGREPORT

Uploaded by

Pooja
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)
127 views25 pages

CGREPORT

Uploaded by

Pooja
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/ 25

CLASSIC CLOCK USING OPENGL

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 NEWS systems were developed

1 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

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

2 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

the application developer from having to design for specific hardware features.

3 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

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 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.
4 Dept of CSE , Yenepoya Institute Of Technology
CLASSIC CLOCK USING OPENGL

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

 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 rasterized and resulting fragment merged into the frame buffer just
as they were generated from the geometric data.

5 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

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

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

6 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

Fig: 1.5 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

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.

 Attribute functions

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
7 Dept of CSE , Yenepoya Institute Of Technology
CLASSIC CLOCK USING OPENGL

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.

8 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

1.7 DATA TYPES


OpenGL supports different data types. A list of data types supported by OpenGL
is given in the following table.

Sl no. Suffix Data type C type OpenGL type

1. B 8 bit int signed int GLbyte

2. S 1 bit int Short GLshort

3. I 32 bit int Long GLint , GLsizei

4. F 32 bit float Float GLfloat ,GLclampf

5. D 64 bit float Double GLdouble, GLclampd

6. Ub 8 bit unsigned unsigned char GLubyte, GLboolean

7. Us 16 bit unsigned unsigned short GLushort

8. Ui 32 bit unsigned unsigned int GLuint, GLenum,


GLbitfield

9 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

CHAPTER 2

REQUIREMENT ANALYSIS

PROJECT REQUIREMENT:

 The background color of the clock is black.

 Each solid cube is representing seconds.

 It contains 3 needles one for hour, one for minute, and one for seconds.

 Large needle represents minute, small needle represent hour and thin needle represents
seconds.

 There is a proper delay between needle moments and timings.

 Needle moves from 1 to 12 in clockwise direction.

The package which we have designed is a one which requires many graphics packages.
Most of the functions which are needed to design the package are found in Turbo C compiler
with a graphics package .The package requires simple in-built functions found in <GL/glut.h>
library. This header file, in addition to the usual header files is needed for the working of the
project. For running the program, any basic PC running compatible version of Microsoft Visual
Studio is sufficient.
This program should use memory as less as possible, dynamic memory allocation is
preferable to accomplish this task. There is no error message produced in this program.
Requirement analysis phase deals with user requirements, which is to fulfill the user’s
requirement that is known during the problem definition phase. To carry out a requirement
analysis, analysts must develop an understanding of the problem domain. The choice of
appropriate software for the smooth implementation of the project is accomplished by this.

10 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

2.2 SOFTWARE REQUIREMENTS


The project requires access to the OpenGL graphics library functions Some
of these library functions are contained in unique to C++ library header files such as
GL/glut.h , math.h , windows.h ,time .h To write, compile and link the program , a
suitable C integrated development environment is required . Microsoft Visual
Studio/Code Blocks may be suitable in this regard. And other Software
Requirements are:

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

2. Compiler used: Dev C++ compiler

3. Language used: OPENGL C++

2.3 HARDWARE REQUIREMENTS

1. Processor: Intel® CoreTM i3-32 bit

2. Processor Speed: 2.9 GHz

3. RAM Size: 8GB DDR3

4. Graphics – 2GB

5. Cache Memory: 2MB

11 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

CHAPTER 3

SYSTEM DESIGN

3.1 INITIALIZATION
 Initialize to interact with the Windows.
 Initialize the display mode that is double buffer and RGB color system.
 Initialize window position and window size.
 Initialize and create the window to display the output.

3.2 DESIGN

Name of the function:

print_screen

Input parameters:

void print_screen( TYPE xcoord, TYPE ycoord, char *string)

Other functions used:

None

Function description:

This function displays digital clock along with the date.


It includes 2 OpenGL functions glRasterPos3i and glutBitmapCharacter, which renders
the character with ASCII code character at the current raster position using the raster font given
by font.
The raster position is incremented by the width of the character.

Name of the function:

Draw_clock

Input parameters:

void Draw_clock ( TYPE cx, TYPE cy,TYPE cz)

12 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

Other functions used:

None

Function description:

This function draws a analog clock.

 Displays clock face by using the OpenGL function gluDisk.


 Displays large wire cube using the OpenGL function gluWireCube.
 Displays hour hand,second hand and minute hand using the OpenGL
function gluCylinder.
 Displays solid cube using the OpenGL function gluSolidCube which
represents seconds.

Name of the function:

TimeEvent

Input parameter:

void TimeEvent(TYPE variable)

Function description:

This function includes glutTimerFunc it takes 3 Parameters.

 msecs- Number of milliseconds to pass before calling the callback.


 Func- The timer callback function.
 value- Integer value to pass to the timer callback.

glutTimerFunc registers the timer callback func to be triggered in at least msecs


milliseconds. The value parameter to the timer callback will be the value of the value
parameter to glutTimerFunc. Multiple timer callbacks at same or differing times may be
registered simultaneously.
The number of milliseconds is a lower bound on the time before the
callback is generated. GLUT attempts to deliver the timer callback as soon as possible
after the expiration of the callback's time interval.

13 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

14 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

CHAPTER 4

IMPLEMENTATION

4.1 OVERVIEW
This project is a demonstration of “Bus Stop Simulation”. We have taken
the help of built-in functions present in the header file. To provide the
functionality to our project we have written sub-functions. These functions
provide us with an efficient way to design the project. In this chapter, we are
describing the functionality of our project using these functions.

4.2 STRUCTURE

 void Draw_clock( GLfloat cx, GLfloat cy, GLfloat cz )


 void print_screen( int x, int y, char *st)
 void display()
 static void TimeEvent(int te)
 void init(void)
 void Draw_clock( GLfloat cx, GLfloat cy, GLfloat cz )
 int main(int argc, char** argv)

15 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

CHAPTER 5

TESING

Testing process of this code is very simple. When we execute the


program it displays the current system time properly during both day and night.
It also displays proper digital time along with the date.

5.1 TYPES OF TESTING


5.1.1 MANUAL TESTING
Manual testing includes testing a software manually, i.e., without using any
automated tool or any script. In this type, the tester takes over the role of an end-user and tests
the software to identify any unexpected behavior or bug. There a re different stages for manual
testing such as unit testing, integration testing, system testing, and user acceptance
testing.

5.1.2 AUTOMATION TESTING

Automation testing, which is also known as Test Automation, is when the tester
writes scripts and uses another software to test the product. This process involves automation of
a manual process. Automation Testing is used to re-run the test scenarios
that were performed manually, quickly, and repeatedly.

5.1.3 BLACK-BOX TESTING


The technique of testing without having any knowledge of the interior workings of
the application is called black-box testing. The tester is oblivious to the system architecture
and does not have access to the source code. Typically, while performing a black-box test, a
tester will interact with the system's user interface by providing inputs and examining outputs
without knowing how and where the inputs are worked upon.

16 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

5.1.4 WHITE-BOX TESTING


White-box testing is the detailed investigation of internal logic and structure of
the code. White-box testing is also called g lass testing or o pen-box testing. In order to perform
white-box testing on an application, a tester needs to know the internal workings of the code.
The tester needs to have a look inside the source code and find out which unit/chunk
of the code is behaving inappropriately.

5.1.5 GREY-BOX TESTING


Grey-box testing is a technique to test the application with having a limited
knowledge of the internal workings of an application. In software testing, the phrase the
more you know, the better carries a lot of weight while testing an application.

5.1.6 FUNCTIONAL TESTING


This is a type of black-box testing that is based on the specifications of the
software that is to be tested. The application is tested by providing input and then the results are
examined that need to conform to the functionality it was intended for. Functional testing
of a software is conducted on a complete, integrated system to evaluate the system's
compliance with its specified requirements.

5.2.7 UNIT TESTING

This type of testing is performed by developers before the setup is handed over
testing team to formally execute the test cases. Unit testing is performed by the respective
developers on the individual units of source code assigned areas. The developers use test
data that is different from the test data of the quality assurance team. The goal of unit testing
is to isolate each part of the program and show that individual parts are correct in terms of
requirements and functionality.

5.1.8 INTEGRATION TESTING

Integration testing is defined as the testing of combined parts of an application to


determine if they function correctly. Integration testing can be done in two ways: Bottom
up integration testing and Top-down integration testing.

17 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

5.2.9 SYSTEM TESTING

System testing tests the system as a whole. Once all the components are integrated, the
application as a whole is tested rigorously to see that it meets the specified Quality
Standards. This type of testing is performed by a specialized testing team.

5.3.0 REGRESSION TESTING

Whenever a change in a software application is made, it is quite possible that other areas
within the application have been affected by this change. Regression testing is performed
to verify that a fixed bug hasn't resulted in another functionality or business rule violation.
The intent of regression testing is to ensure that a change, such as a bug fix should not result
in another fault being uncovered in the application.

5.3.1 ACCEPTANCE TESTING

This is arguably the most important type of testing, as it is conducted by the Quality
Assurance Team who will gauge whether the application meets the intended specifications
and satisfies the client’s requirement. The QA team will have a set of pre-written scenarios
and test cases that will be used to test the application. By performing acceptance tests on
an application, the testing team will deduce how the application will perform in production.
There are also legal and contractual requirements for acceptance of the system.

5.3.2 ALPHA TESTING

This test is the first stage of testing and will be performed amongst the teams
(developer and QA teams). Unit testing, integration testing and system testing when
combined together is known as alpha testing. During this phase, the following aspects will
be tested in the application:
 Spelling Mistakes
 Broken Links
 Cloudy Directions
 The Application will be tested on machines with the lowest specification to test
loading times and any latency problems.

18 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

5.3.3 BETA TESTING

This test is performed after alpha testing has been successfully performed. In beta
testing, a sample of the intended audience tests the application. Beta testing is also known
as pre-release testing. Beta test versions of software are ideally distributed to a wide
audience on the Web, partly to give the program a "real-world" test and partly to provide a
preview of the next release. In this phase, the audience will be testing the following:
 Users will install, run the application and send their feedback to the project team
 Typographical errors, confusing application flow, and even crashes.
 Getting the feedback, the project team can fix the problems before releasing the
software to the actual users.
5.3.4 NON-FUNCTIONAL TESTING

This section is based upon testing an application from its non-functional attributes. Non
functional testing involves testing a software from the requirements which are
nonfunctional in nature but important such as performance, security, user interface, etc.
Some of the important and commonly used non-functional
 Load Testing
 Performance Testing
 Stress Testing

19 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

SNAPSHOT

Figure 1. Original snapshot

20 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

Figure 2. Clock without digital date and time

21 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

Figure 3. Without lighting effect and different color of


Clock face and hands

22 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

CONCLUSION

SUMMARY:
This project shows the graphical representation of a working analogue clock.
The objective of this program is to implement simple and basic functions of OpenGL.
Computer graphics plays a major role in today’s world where visualization takes the
upper hand as compared to textual interaction. This is largely true as we can see user
interface becoming more and more attractive all thanks to major leaps in the fields of
computer graphics. The project is implemented using graphics OpenGL package
provided by C.

The above argument is equally justified in the fields of computer simulation


which involve complex graphics being highlighted at its peak. It is becoming more and
more popular and the constant dive to improve particular system efficiency by
studying its simulated model attracts more people towards it.

SCOPE OF IMPROVEMENT :
Though the package that is designed here does not include complex OpenGL
package, we intend to improve this by including extra features like lighting effects,
Changing the background color adding alarams. We do this with an aim to attract more
people to use our package.

23 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

BIBLIOGRAPHY

The books and the other sources we referred while doing this project are as
follows:

REFERENCES:

1. Interactive Computer Graphics – A Top-Down Approach Using OpenGL.

2. Computer Graphics Using OpenGL – F.S Hill, Jr.,2nd Edition, Pearson


Education ,2001

3. Computer Graphics – James D Foley , Andries Van Dam , Steven K Feiner ,


John F Hughes , Addison – Wesley 1997

4. Computer Graphics – OpenGL Version – Donald Hearn and Pauline Baker ,


2nd Edition , Pearson Education ,2003

ONLINE REFERENCES:

 www.codecolony.de/opengl
 www.3dcodingtutorial.com
 www.openGL.org
www.nehe.com

24 Dept of CSE , Yenepoya Institute Of Technology


CLASSIC CLOCK USING OPENGL

APPENDIX

 GL: Graphics Library


 GLU: Graphics Utility Library
 GLUT: OpenGL Utility Tool kit
 glutInitDisplayMode(): It sets the initial display mode.
 glutDisplayFunc(): sets the display callback for the current window.
 glutInitWindowPosition(): Initializes GLUT and specifies command-line
options for window system in use.
 glColor():Set the current color.
 2D: Two dimensional.
 glLoadidentity():This replaces the current matrix with the identity matrix.
 glutPostRedisplay(): This marks the current window as needing to be redisplayed.
 API: Application Programming Interface.
 GLX: OpenGL Extension to the X Window System

25 Dept of CSE , Yenepoya Institute Of Technology

You might also like