Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
164 views

Computer Graphics Report

This document provides an introduction to computer graphics and OpenGL. It discusses the history and applications of computer graphics, driven by both user needs and hardware/software advances. OpenGL is introduced as a hardware-independent interface for 3D graphics across platforms. It has an abstract pipeline for 2D/3D rendering. GLUT is also described as a windowing toolkit for simple OpenGL programs. The document outlines OpenGL's geometric and raster primitives and applications in CAD, VR, visualization, simulation and games.

Uploaded by

Shalini G Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
164 views

Computer Graphics Report

This document provides an introduction to computer graphics and OpenGL. It discusses the history and applications of computer graphics, driven by both user needs and hardware/software advances. OpenGL is introduced as a hardware-independent interface for 3D graphics across platforms. It has an abstract pipeline for 2D/3D rendering. GLUT is also described as a windowing toolkit for simple OpenGL programs. The document outlines OpenGL's geometric and raster primitives and applications in CAD, VR, visualization, simulation and games.

Uploaded by

Shalini G Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

CLOCK OpenGL

Chapter 1

INTRODUCTION

1.1 Introduction to Computer Graphics

Computer Graphics is concerned with all aspects of producing pictures or images


using a computer. We can create images that are indistinguishable from photographs of real
objects. In other terms, Computer Graphics re the graphics created by the computers, and
more generally, the representation and manipulation of image data by a computer.

The development of computer graphics has been driven both by the needs of the user
community and by advances in hardware and software.

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 images so produced, and manipulating visual content.

1.2 History of Computer Graphics

The phrase Computer Graphics was coined in 1960 by William Fetter, a graphic
designer for Boeing. The field of Computer Graphics developed with the emergence of
computer graphics hardware. Early projects like the Whirlwind and SAGE projects
introduced the CRT as a viable display and interaction interface and introduced the light pen
as an input device.

Further advances in computing led to greater advancements in interactive computer


graphics. In 1959, the TX-2 computer was developed at MIT's Lincoln Laboratory. A light
pen could be used to draw sketches on the computer using Ivan Sutherland’s
revolutionary Sketchpad software.

Also in 1961 another student at MIT, Steve Russell, created the first video
game, Spacewar. 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. In this computer
generated film, Zajac showed how the attitude of a satellite could be altered as it orbits the

Dept of CSE,DR.TTIT,KGF 1 2022-23


CLOCK OpenGL

Earth. Many of the most important early breakthroughs in computer graphics research
occurred at the University of Utah in the 1970s.

The first major advance in 3D computer graphics was created at UU 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.

Graphics and application processing were increasingly migrated to the intelligence in


the workstation, rather than continuing to rely on central mainframe and mini-computers. 3D
graphics became more popular in the 1990s in gaming, multimedia and animation. Computer
graphics used in films and video games gradually began to be realistic to the point of entering
the uncanny valley. Examples include the later Final Fantasy games and animated films
like The Polar Express.

1.3 Applications of Computer Graphics

The development of computer graphics has been driven both by the needs of the user
community and by advances in hardware and software. The applications of computer
graphics are many and varied. We can however divide them into four major areas.

 Display of information: More than 4000 years ago, the Babylonians developed
floor plans of buildings on stones. Today, the same type of information is
generated by architects using computers. Over the past 150 years, workers in
the field of statistics have explored techniques for generating plots. Now, we
have computer plotting packages. Supercomputers now allow researchers in
many areas to solve previously intractable problems. Thus, Computer
Graphics has innumerable applications.
 Design: Professions such as engineering and architecture are concerned with
design. Today, the use of interactive graphical tools in CAD, in VLSI circuits,
characters for animation have developed in a great way.
 Simulation and animation: One of the most important uses has been in pilots’
training. Graphical flight simulators have proved to increase safety and reduce
expenses. Simulators can be used for designing robots, plan it’s path, etc.
Video games and animated movies can now be made with low expenses.

Dept of CSE,DR.TTIT,KGF 2 2022-23


CLOCK OpenGL

 User interfaces: Our interaction with computers has become dominated by a


visual paradigm. The users’ access to internet is through graphical network
browsers. Thus Computer Graphics plays a major role in all fields.

1.4 Introduction to OpenGL

OpenGL is a software interface to graphics hardware. This interface consists of about


150 distinct commands that are used to specify the objects and operations needed to produce
interactive three-dimensional applications. OpenGL is designed as a streamlined hardware-
independent interface to be implemented on many different hardware platforms.

These are certain characteristics of OpenGL:

 OpenGL is a better documented API.


 OpenGL is much easier to learn and program.
 OpenGL has the best demonstrated 3D performance for any API.

The OpenGL specification describes an abstract API for drawing 2D and 3D graphics.


Although it's possible for the API to be implemented entirely in software, it's designed to be
implemented mostly or entirely in hardware.

In addition to being language-independent, OpenGL is also platform-independent.


The specification says nothing on the subject of obtaining, and managing, an OpenGL
context, leaving this as a detail of the underlying windowing system. For the same reason,
OpenGL is purely concerned with rendering, providing no APIs related to input, audio, or
windowing.

OpenGL is an evolving API. New versions of the OpenGL specification are regularly
released by the Khronos Group, each of which extends the API to support various new
features.In addition to the features required by the core API, GPU vendors may provide
additional functionality in the form of extensions. Extensions may introduce new functions
and new constants, and may relax or remove restrictions on existing OpenGL functions.
Vendors can use extensions to expose custom APIs without needing support from other
vendors or the Khronos Group as a whole, which greatly increases the flexibility of OpenGL.
All extensions are collected in, and defined by, the OpenGL Registry.

Dept of CSE,DR.TTIT,KGF 3 2022-23


CLOCK OpenGL

Figure 1.4 OpenGL Pipeline

1.5 Introduction to GLUT

GLUT is the OpenGL utility toolkit, a window system independent toolkit for writing
OpenGL programs. It implements a simple windowing API for OpenGL. GLUT makes it
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. GLUT is designed for constructing small to medium sized OpenGL programs.

While GLUT is well-suited to learning OpenGL and developing simple OpenGL


applications, GLUT is not a full-featured toolkit so large applications requiring sophisticated
user interfaces are better off using native window system toolkits.The GLUT library has both
C, C++ (same as C), FORTRAN, and ADA programming bindings. The GLUT source code
distribution is portable to nearly all OpenGL implementations and platforms.

Dept of CSE,DR.TTIT,KGF 4 2022-23


CLOCK OpenGL

GLU

Frame
GL buffer
OpenGL
Application
program Xlib, Xtk

GLUT

GLX

Figure 1.5 library organization of OpenGL

1.6 Applications of OpenGL


 OpenGL (Open Graphics Library) is a cross-language, multi-platform API for
rendering 2D and 3D computer graphics.
 The API is typically used to interact with a GPU, to achieve hardware-
accelerated rendering.
 It is widely used in CAD, virtual reality, scientific visualization, information
visualization, flight simulation, and video games. 

1.7 OpenGL primitives

OpenGL supports two classes of primitives:

 Geometric Primitives
 Image(Raster) Primitives

Geometric primitives are specified in the problem domain and include points, line
segments, polygons, curves and surfaces.

Dept of CSE,DR.TTIT,KGF 5 2022-23


CLOCK OpenGL

Raster primitives, such as arrays of pixels pass through a separate parallel pipeline on
their way to the frame buffer.

There are ten basic OpenGL primitives:

Figure 1.7 OpenGL Primitives

Dept of CSE,DR.TTIT,KGF 6 2022-23


CLOCK OpenGL

Chapter 2

HARDWARE AND SOFTWARE REQUIREMENTS

2.1 Hardware Requirements:

 Pentium 90MHz Processor or Higher


 VGA 640x480 or higher-resolution screen supported by Microsoft Windows.
 Recommended 128 MB RAM or Higher (24 MB RAM for Windows 95/98, 32
MB for Windows NT)
 100GB SATA (Serial Advanced Technology Attachment) Hard Drive
 5400 RPM hard disk drive
 DirectX 9 capable video card running at 1024 x 768
 DVD-ROM Drive
 Input devices: Keyboard, Mouse.
 Output devices: Monitor.

2.2 Software Requirements:

 Operating System: Microsoft Windows NT 4.0 or later, or Microsoft Windows 95


or later.
 Microsoft Visual Studio 6.0
 glut.h header file
 glut.dll library files

Dept of CSE,DR.TTIT,KGF 7 2022-23


CLOCK OpenGL

Chapter 3

ABOUT THE PROJECT

3.1 Introduction to the project

This mini project on <TITLE> displays a scientific calculator with all the
mathematic functions. Geometrically it is a rectangular calculator with small rectangular
boxes represents the key pad keys and Upper left and right two rectangular boxes indicate the
display screens. It compute normal mathematical calculations and also graphical functions
which generate graphs. Mainly it has calculator key pad which is indicating all the numeric
and function keys, and two display screens.

The calculator keys takes input from keyboard stroke and mouse clicks. The
left side display shows all the inputs and result in normal mathematical form. The right side
display gives the graphical display of mathematical functions.

3.2 User Defined Functions

There are eight user defined functions in the source code of <TITLE>

1. void set_properties()
Used to set properties of the surface material, light source properties and the
camera position.

2. void mouse(int button, int state, int x, int y)


Displays and updates the needles of the clock as per the current time read by the
program.

3. void Draw_gear( void )


Updates the position of the clock gear as per the current matrix stack.

4. void Draw_clock( GLfloat cx, GLfloat cy, GLfloat cz )

Dept of CSE,DR.TTIT,KGF 8 2022-23


CLOCK OpenGL

Used to draw the analog wall clock on the screen.

5. void num()
Displays the numbers on the clock according to orthogonal view.

6. void about()
Displays a small description about the project when the user clicks the
respective mouse button.

7. void display_clock()
Displays the wall clock on the output window.

8. void options(int id)


Used to display a menu along with options regarding the light state, view of the
clock, description and perform the corresponding action.

Dept of CSE,DR.TTIT,KGF 9 2022-23


CLOCK OpenGL

Chapter 4

DESIGN
Initialization
Initialize the interaction with the windows. Initialize the display mode- double buffer
and depth buffer. Initialize the various callback functions for drawing and redrawing, for
mouse and keyboard interfaces. Initialize the input and calculate functions for various
mathematical calculations. Initialize the window position and size and create the window to
display the output.

Flow of control
The flow of control in the below flow chart is respected to the Texture Package. For
any of the program flow chart is compulsory to understand the program. We consider the
flow chart for the texture project in which the flow starts from start and proceeds to the main
function after which it comes to the initialization of call back functions and further it
proceeds to mouse and keyboard functions, input and calculation functions. Finally, it comes
to quit, the end of flow chart.

Dept of CSE,DR.TTIT,KGF 10 2022-23


CLOCK OpenGL

START

MAIN

INITIALIZE CALLBACK FUNCTIONS

MAIN SCREEN DISPLAYED

KEYBOARD MOUSE INTERUPT

READING INPUT STRING


AND ANIMATE MOUSE

END OF INPUT

CALCULATE

PRINT OUTPUT

STOP

Figure 4.1 Project Design

Dept of CSE,DR.TTIT,KGF 11 2022-23


CLOCK OpenGL

Chapter 5

IMPLEMENTATION

5.1 Built-in functions


1. glRasterPos3f( x, y, -1)
Specifies the raster position for pixel operations.
2. glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, st[i])
Renders a bitmap charater using OpenGL from the specified array of characters,
and in the specified font style.
3. glutPostRedisplay()
Marks the current window as needing to be redisplayed.
4. glutTimerFunc( 100, TimeEvent, 1)
Registers a timer callback to be triggered in a specified number of milliseconds.
5. glClearColor (0.0, 0.0, 0.0, 0.0)
Specifies clear values for the color buffers.
6. glShadeModel (GL_SMOOTH)
Select flat or smooth shading. Specifies a symbolic value representing a shading
technique. Accepted values are GL_FLAT and GL_SMOOTH.
7. glEnable(GL_DEPTH_TEST)
Enables the OpenGL capabilities, Specifies the conditions under which the pixels
will be drawn.
8. glLightfv(GL_LIGHT1 ,GL_AMBIENT, LightAmbient)
Returns light source parameter values.
9. gluQuadricDrawStyle( Cylinder, GLU_FILL)
Specifies the draw style required for quadrics.
10. glPushMatrix() and glPopMatrix()
Push and pop the current matrix stack.
11. glTranslatef() and glRotatef()

Dept of CSE,DR.TTIT,KGF 12 2022-23


CLOCK OpenGL

Multiplies current matrix by Translation and Rotation matrix respectively.


12. glMatrixMode (GL_PROJECTION)
Specifies which matrix is the current matrix.

13. glLoadIdentity()
Replaces current matrix with identity matrix.
14. gluLookAt()
Defines a viewing transformation.
15. glutSwapBuffers()
Swaps the buffers of the current window if double buffered.
16. glViewport()
Sets the viewport.
17. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB)
Sets the initial display mode.
18. glutInitWindowSize (500, 500) and glutInitWindowPosition (50, 50)
Set the initial window size and position respectively.
19. glutCreateWindow()
Creates a top level window with the window name as specified.
20. glutAddMenuEntry()
 Adds a menu entry to the bottom of the current menu.
21. glutAttachMenu(GLUT_RIGHT_BUTTON)
Attaches a mouse button for the current window to the identifier of the current
menu.
22. glutDisplayFunc(display)
Sets the display callback for the current window.
23. glutReshapeFunc(reshape)
Sets the reshape callback for the current window.
24. glutMainLoop()
Enters the GLUT event processing loop. This routine should be called at most
once in a GLUT program. Once called, this routine will never return. It will call as
necessary any callbacks that have been registered.

Dept of CSE,DR.TTIT,KGF 13 2022-23


CLOCK OpenGL

5.2 Source Code

#include <GL/glut.h>

#include <string.h>

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include <time.h>

int about_int=0;

GLUquadricObj *Cylinder;

GLUquadricObj *Disk;

struct tm *newtime;

time_t ltime;

int M_TWOPI=0;

GLfloat rx, ry, rz, angle;

// lighting

GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };

GLfloat LightDiffuse[]= { 0.5f, 0.5f, 0.5f, 1.0f };

GLfloat LightPosition[]= { 5.0f, 25.0f, 15.0f, 1.0f };

GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };

static int light_state = 1; // light on = 1, light off = 0

static int view_state = 1; // Ortho view = 1, Perspective = 0

void Sprint( float x, float y, char *st)

Dept of CSE,DR.TTIT,KGF 14 2022-23


CLOCK OpenGL

int l,i;

l=strlen( st );

glRasterPos3f( x, y, -1);

for( i=0; i < l; i++)

glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, st[i]);

static void TimeEvent(int te)

rx = 30 * cos( angle );

ry = 30 * sin( angle );

rz = 30 * cos( angle );

angle += 0.01;

if (angle > M_TWOPI) angle = 0;

glutPostRedisplay();

glutTimerFunc( 100, TimeEvent, 1);

void init(void)

glClearColor (0.0, 0.0, 0.0, 0.0);

glShadeModel (GL_SMOOTH);

glEnable(GL_DEPTH_TEST);

// Lighting is added to scene

glLightfv(GL_LIGHT1 ,GL_AMBIENT, LightAmbient);

glLightfv(GL_LIGHT1 ,GL_DIFFUSE, LightDiffuse);

glLightfv(GL_LIGHT1 ,GL_POSITION, LightPosition);

glEnable(GL_LIGHTING);

Dept of CSE,DR.TTIT,KGF 15 2022-23


CLOCK OpenGL

glEnable(GL_LIGHT1);

Cylinder = gluNewQuadric();

gluQuadricDrawStyle( Cylinder, GLU_FILL);

gluQuadricNormals( Cylinder, GLU_SMOOTH);

gluQuadricOrientation( Cylinder, GLU_OUTSIDE);

gluQuadricTexture( Cylinder, GL_TRUE);

Disk = gluNewQuadric();

gluQuadricDrawStyle( Disk, GLU_FILL);

gluQuadricNormals( Disk, GLU_SMOOTH);

gluQuadricOrientation( Disk, GLU_OUTSIDE);

gluQuadricTexture( Disk, GL_TRUE);

void Draw_gear( void )

int i;

glPushMatrix();

gluCylinder(Cylinder, 2.5, 2.5, 1, 16, 16);

gluDisk(Disk, 0, 2.5, 32, 16);

glTranslatef(0,0,1);

gluDisk(Disk, 0, 2.5, 32, 16);

glPopMatrix();

for( i = 0; i < 8; i++)

glPushMatrix();

glTranslatef( 0.0, 0.0, 0.50);

glRotatef( (360/8) * i, 0.0, 0.0, 1.0);

glTranslatef( 3.0, 0.0, 0.0);

glutSolidCube( 1.0 );

Dept of CSE,DR.TTIT,KGF 16 2022-23


CLOCK OpenGL

glPopMatrix();

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

int hour_ticks , sec_ticks;

glPushMatrix();

glTranslatef(cx,cy,cz);

glRotatef( 180, 1.0, 0.0, 0.0);

/*glPushMatrix(); // Draw large wire cube (outside of disk clock)

glColor3f(1.0, 1.0, 1.0);

glTranslatef( 0.0, 0.0, 6.0);

glutWireCube(14.0);

glPopMatrix();*/

glPushMatrix(); // Draw clock face

glTranslatef( 0, 0, 1.0);

gluDisk(Disk, 0, 6.75, 32, 16);

glPopMatrix();

glPushMatrix();// Draw hour hand

glColor3f(1.0, 0.5, 0.5);

glTranslatef( 0, 0, 0.0);

glRotatef( (360/12) * newtime->tm_hour + (360/60) * (60 / (newtime->tm_min+1)), 0.0, 0.0, 1.0);

glPushMatrix();

glTranslatef(0.0, 0.0, 2.0);

Draw_gear();

glPopMatrix();

glRotatef( 90, 1.0, 0.0, 0.0);

gluCylinder(Cylinder, 0.75, 0, 4, 16, 16);

Dept of CSE,DR.TTIT,KGF 17 2022-23


CLOCK OpenGL

glPopMatrix();

glPushMatrix();// Draw minute hand

glColor3f(1.0, 0.5, 1.0);

glTranslatef( 0, 0, 0.0);

glRotatef( (360/60) * newtime->tm_min, 0.0, 0.0, 1.0);

glPushMatrix();

glTranslatef(0.0, 0.0, 3.0);

glScalef(0.5, 0.5, 1.0);

Draw_gear();

glPopMatrix();

glRotatef( 90, 1.0, 0.0, 0.0);

gluCylinder(Cylinder, 0.5, 0, 6, 16, 16);

glPopMatrix();

glPushMatrix();// Draw second hand

glColor3f(1.0, 0.0, 0.5);

glTranslatef( 0, 0, -0.0);

glRotatef( (360/60) * newtime->tm_sec, 0.0, 0.0, 1.0);

glPushMatrix();

glTranslatef(0.0, 0.0, 4.0);

glScalef(0.25, 0.25, 1.0);

Draw_gear();

glPopMatrix();

glRotatef( 90, 1.0, 0.0, 0.0);

gluCylinder(Cylinder, 0.25, 0, 6, 16, 16);

glPopMatrix();

for(hour_ticks = 0; hour_ticks < 12; hour_ticks++)

glPushMatrix();// Draw next arm axis.

Dept of CSE,DR.TTIT,KGF 18 2022-23


CLOCK OpenGL

glColor3f(0.0, 1.0, 1.0); // give it a color

glTranslatef(0.0, 0.0, 0.0);

glRotatef( (360/12) * hour_ticks, 0.0, 0.0, 1.0);

glTranslatef( 6.0, 0.0, 0.0);

glutSolidCube(1.0);

glPopMatrix();

for(sec_ticks = 0; sec_ticks < 60; sec_ticks++)

glPushMatrix();

glTranslatef(0.0, 0.0, 0.0);

glRotatef( (360/60) * sec_ticks, 0.0, 0.0, 1.0);

glTranslatef(6.0, 0.0, 0.0);

glutSolidCube(0.25);

glPopMatrix();

glPopMatrix();

void num()

if(view_state == 1)

glColor3f( 0.0, 0.0, 1.0);

Sprint(-6.2,-0.2,"9"); //counting from center

Sprint(-0.2,-6.2,"6");

Sprint(-0.4,5.7,"12");

Sprint(5.8,-0.2,"3");

Dept of CSE,DR.TTIT,KGF 19 2022-23


CLOCK OpenGL

void about()

//glClear(GL_COLOR_BUFFER_BIT);

glColor3f( 1.0, 1.0, 1.0);

Sprint(-5,-2,"This project implements the clock");

Sprint(-5,-2.8," Both Wall clock and digit clock");

Sprint(-5,-3.6," is displayed");

Sprint(-5,-4.4," Clock shows the local time");

Sprint(-5,-5.2," fetching from computer");

//glFlush();

void display_clock()

time(&ltime); // Get time

newtime = localtime(&ltime); // Convert to local time

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// easy way to put text on the screen.

glMatrixMode (GL_PROJECTION);

glLoadIdentity();

glOrtho(-8.0, 8.0, -8.0, 8.0, 1.0, 60.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glDisable(GL_LIGHTING);

glDisable(GL_COLOR_MATERIAL);

// Put view state on screen

glColor3f( 1.0, 1.0, 1.0);

if (view_state == 0 && about_int==0)

Dept of CSE,DR.TTIT,KGF 20 2022-23


CLOCK OpenGL

Sprint(-3, -4, "Perspective view");

else if (view_state != 0 && about_int==0)

Sprint(-2, -4, "Ortho view");

else

about();

Sprint(-4,-7.7, asctime(newtime));

// Turn Perspective mode on/off

if (view_state == 0)

glMatrixMode (GL_PROJECTION);

glLoadIdentity();

gluPerspective(60.0, 1, 1.0, 60.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt( rx, 0.0, rz, 0.0, 0.0, -14.0, 0, 1, 0);

if (light_state == 1)

glEnable(GL_LIGHTING);

glEnable(GL_COLOR_MATERIAL); // Enable for lighing

}else

Dept of CSE,DR.TTIT,KGF 21 2022-23


CLOCK OpenGL

glDisable(GL_LIGHTING);

glDisable(GL_COLOR_MATERIAL); // Disable for no lighing

Draw_clock( 0.0, 0.0, -14.0);

num();

glutSwapBuffers();

void display(void)

glClear(GL_COLOR_BUFFER_BIT);

display_clock();

glFlush();

void reshape (int w, int h)

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

void options(int id)

switch(id)

case 1:

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

about_int= abs(about_int - 1);

break;

case 2:

Dept of CSE,DR.TTIT,KGF 22 2022-23


CLOCK OpenGL

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

view_state = abs(view_state - 1);

break;

case 3:

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

light_state = abs(light_state - 1);

break;

case 4 :

exit(0);

int main(int argc, char** argv)

glutInit(&argc, argv);

glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);

glutInitWindowSize (500, 500);

glutInitWindowPosition (50, 50);

glutCreateWindow (argv[0]);

glutSetWindowTitle("GLclock");

init ();

glutCreateMenu(options);

glutAddMenuEntry("About the Project",1);

glutAddMenuEntry("Toggle Ortho/Perspective view",2);

glutAddMenuEntry("Light on/off",3);

glutAddMenuEntry("Quit",4);

glutAttachMenu(GLUT_RIGHT_BUTTON);

glutDisplayFunc(display);

glutReshapeFunc(reshape);

Dept of CSE,DR.TTIT,KGF 23 2022-23


CLOCK OpenGL

glutTimerFunc( 10, TimeEvent, 1);

glutMainLoop();

return 0;

Chapter 6

TESTING
Testing in general means validation and verification. It shows that the system
conforms to its specifications and system meets all expectation of the user.

6.1 Test case for mouse:

Sl. No. Test Case Expected Result Actual Result Remarks


Description
1. Click the RIGHT Menu with Menu with Pass
mouse button on  Toggle  Toggle
the display screen. Ortho/Perspective Ortho/Perspective
View View
 Light ON/OFF  Light ON/OFF
 About the project  About the project
 Quit  Quit
Should be displayed. Is displayed.

6.2 Test case for menu options:

Sl. No. Test Case Expected Result Actual Result Remarks


Description
1. Click on Toggle The user should be able The user is able to toggle Pass
Ortho/Perspective to toggle between these between these two views.
view option two views.
2. Click on Light The user should be able The user is able to turn Pass
ON/OFF option to turn ON or OFF the ON or OFF the
brightness feature. brightness feature.
3. Click on About A short description of the A short description of the Pass
the project option project should be project is displayed on
displayed on the window. the window.
4. Click on Quit The window should be The window is Pass
option terminated. terminated.

Dept of CSE,DR.TTIT,KGF 24 2022-23


CLOCK OpenGL

Chapter 7

SNAPSHOTS

Figure 7.1 Initial View

Dept of CSE,DR.TTIT,KGF 25 2022-23


CLOCK OpenGL

Figure 7.2 Menu with options:

Figure7.3 Ortho view:

Dept of CSE,DR.TTIT,KGF 26 2022-23


CLOCK OpenGL

Figure 7.4 Perspective view

Figure 7.5 Brightness ON

Dept of CSE,DR.TTIT,KGF 27 2022-23


CLOCK OpenGL

Figure7.6 Brightness OFF

Dept of CSE,DR.TTIT,KGF 28 2022-23


CLOCK OpenGL

Figure7.7 Window with description of the project

Chapter 8

CONCLUSION
This mini project on CLOCK using OpenGL is a reliable graphics package that
provides the user with the basic working of an analog as well as a digital clock. It provides
the user with certain other operations like toggling between two different kinds of views,
adjusting the brightness by turning the lights on or off, also allows the user to read a short
description of what the project is about. The user-friendly interface allows the user to interact
with it very effectively.

Dept of CSE,DR.TTIT,KGF 29 2022-23


CLOCK OpenGL

Chapter 9

FUTURE ENHANCEMENTS
This project has been designed such that it works on the windows platform. The
project can be designed using different languages and better graphical interfaces. The
following features can be incorporated.

 A simple monthly calendar can be displayed along with the clock.


 A simple digital timer can be implemented.
 Better graphical features like options for the user to change the clock’s color
and shape of the clock.
 A different style for the digits on the clock, for example, Roman Numbers.

Dept of CSE,DR.TTIT,KGF 30 2022-23


CLOCK OpenGL

BIBLIOGRAPHY

BOOKS:
 Edward Angel, “Interactive Computer Graphics”,5th edition, Pearson Education,2005
 Jackie L. Neider, Mark Warhol, Tom R. Davies, ”OpenGL Red Book”, 2 nd Revised
Edition,2005
 Donald D Hearn and M. Pauline Baker, “Computer Graphics with OpenGL”, 3rd
edition.
 F.S.Hill and Stephen M.Kelly,”Computer Graphics using OpenGL”, 3rd edition.

WEBSITES:
 http://www.opengl.org
 http://www.wikipedia.com

 http://basic4gl.wikispaces.com

 http://openglprojects.in

Dept of CSE,DR.TTIT,KGF 31 2022-23

You might also like