Analog Clock
Analog Clock
Analog Clock
CHAPTER 1
INTRODUCTION
A computer graphics system is a computer system with all the components of the general
purpose computer system. There are five major elements in system: input devices, proces-
sor, memory, frame buffer, output devices.
In 1992 the OpenGL Architectural Review Board (OpenGL ARB) was established. The
OpenGL ARB is a group of companies that maintain and update the OpenGL standard.
In 2003 the first OpenGL (Exchange Specification) ES specification was released. OpenGL
ES is a subset of OpenGL designed for mobile phones, embedded devices and video game
systems.
In 2004 the OpenGL 2.0 specification was released, including the GLSL (OpenGL Shading
Language) specification.
OpenGL is an API …
Operations
The 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, performing polygon tessellation, and rendering surfaces.
GLU routines use the prefix glu.
The OpenGL Utility Toolkit (GLUT) is a window system-independent toolkit,
written by Mark Kilgard, to hide the complexities of differing window system
APIs. GLUT is the subject of the next section, and it’s described in more detail in
Mark Kilgard’s book OpenGL Programming forthe X Window System (ISBN 0-
201-48359-9). GLUT routines use the prefix glut. "How to Obtain the Sample
Code" in the Preface describes how to obtain the source code for GLUT, using ftp.
CHAPTER 2
REQUIREMENTS SPECIFICATION
CHAPTER 3
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.
3.1 Architecture:
START
main()
about() Display_clock()
Ortho/
Perspectivev view Sprint()
Light
ON/OFF Num()
Quit
Draw_clock()
Draw_gear()
CHAPTER 4
IMPLEMENTATION
The implementation stage of this model involves the following phases.
1. glutInit( ):
glutInit is used to initialize the GLUT library.
Usage: void glutInit(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-ing 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: glutCreateWindow creates a top-level window. The name will be provided
to 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
created window. Each created window has a unique associated OpenGL context.
Dept. Of CSE, DSATM 2013-2014 Page 7
Analog Clock
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.
The display callback is called with no parameters. The entire normal plane region should
be redisplayed in response to the callback.
5. glutMainLoop( ):
glutMainLoop enters the GLUT event processing loop.
Usage: void glutMainLoop(void);
Description: 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.
6. glMatrixMode( ):
The two most important matrices are the model-view and projection matrix. At any time,
the state includes values for both of these matrices, which are initially set to identity
matrices. There is only a single set of functions that can be applied to any type of matrix.
Select the matrix to which the operations apply by first set in the matrix mode, a variable
that is set to one type of matrix and is also part of the state.
7. glutTimerFunc();
1. void init(void):
Here the initialization function init() is used to set the OpenGL state variables dealing
with viewing and attributes-parameters that is prefered to set once, independently of the
display function.
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.
6. void num():
This function is to display the numbers(1 to 12) along with its corresponding seconds on
the face of the clock.
This calls the user defined function “Sprint()” with appropriate co-ordinates and numbers.
7. void about():
This function gives the description of the clock on the visualizer window.
This uses the user defined function “Sprint()” to display the characters.
8. void display_clock():
This function basically renders various views of the clock like ortho view and perspective
view depending upon the “if” condition. Depending upon the input given the user defined
function “draw_clock()” and “num()” are called.
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
with desired properties. After initialization the display function is called with respect to
the window and finally the last statement of this section is the glutMainLoop(). Which is
an event processing function that enters into an infinite loop.
CHAPTER 5
SNAPSHOTS
CHAPTER 6
FUTURE ENHANCEMENT
We have implemented the essential features of the Analog Clock to our best knowledge.
Even still, we would like to enhance the quality and appearance of the clock in the following
ways:
3D View
Enhanced appearance
Lighting and shading
Implementation of Alarm
CHAPTER 7
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, colour swapping etc.
We thus would like to emphasize of the importance of this project that opened our eyes to
many other perspectives of Technical, mathematical, graphical and software concepts which
we were unaware of.
Thus we thank all Principal, the HOD, the faculty and all our classmates for their continuous
support and belief in us.
CHAPTER 8
REFERENCES
Books:
Interactive Computer Graphics, 5th Edition, Edward Angel
Computer Graphics and Multimedia, Udit Sharma
Websites:
http://www.amazon.in/Computer-Graphics-Multimedia-Udit-Agarwal/dp/
935014316X?tag=googinhydr18418-21
http://en.wikipedia.org/wiki/Computer_graphics
http://stackoverflow.com/questionsquickly
http://www.opengl-tutorial.org/intermediate-tutorials/
CHAPTER 9
APPENDIX
Right click on the visualizer window, you will be asked for four options
1. About the project
2. Toggle Ortho/Perspective view
3. Light ON/OFF
4. Quit
Depending on the selection the corresponding output will be displayed.
The clock can be viewed in any degrees by changing the degrees in “Draw_clock()”
function.
Make sure that the folder ‘Analog clock’ is copied to the C:\ drive ONLY
USN: 1DT11CS009
USN: 1DT11CS003