Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

INTRODUCTION

• Overview:

The aim of the project is to implement an application of computer


graphics using OpenGL. Here we represent the concepts displaying
analog clock in OpenGL.

• About graphics OpenGL:

Activities as wideranging as filmmaking,publishing,banking and


education continue to undergo revolutionary changes as these
technologies alter the ways in which we conduct our daily activities.
The combination of computers, network and the complex human
visual system, through computer graphics, has led to new ways of
displaying information seeing virtual worlds and communicating with
people and machines. A class in computer graphics allows the
instructor to build all these topics in away that can be both informative
and fun. Low level algorithms such as those that draw lines or fill
polygons are used in OpenGL. The development of OpenGL resolved
both of the difficulties that was experienced with other APIs and with
the alternative of using home-brewed s/w. OpenGL today is supported
in all platforms.

A clock or watch “analog” when it has moving hands and hours


marked from1 to12 to show you the time. Analog usually indicate time
using angles. The most common clock face uses a fixed numbered dial
or dials and moving hand or hands. It usually has a circular scale of 12
hours, which can also serve as a scale of 60minutes, and 60seconds if
the clock has a second hand. Many other styles and designs have been
used clock face today is the 24 hour analog dial, because of the use of
24 hour time inmiliatly organizations and timetables.
APPLICATION

• Software reqirement:

The project requires acces to the OpenGL graphics library functions.


Some of these library functions are contained in unique to c++ library
header files such as

1. GL/glut.h
2. math.h
3. windows.h
4. time.h

to write ,compile and link the program a suitable C intergrated


development environment is required. Microsoft virsual studio/code
blocks may be suitable in this regard.

Software requirement are:

1. window operating system


2. Microsoft virsual studio
3. Code blocks

• HARDWARE REQUIREMENT:-
The minimum/recommended hardware configuration required for
developing the proposed software is given below:
1. PENTIUM-2 and above compatible systems.
2. 128 MB RAM
3. Approximetly 1 MB free space in the hard disk.
4. Hard disk access time must be less than 19 milliseconds
IMPLEMENTATION

/* Graphical Analog Clock designed in C*/


/*Note press ctrl+pause break to stop the clock while executing in
TC*/

#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
#include<math.h>
#include<dos.h>
#include<time.h>

#define PI 3.147

void clockLayout();
void secHand();
void hrHand();
void minHand();
int maxx,maxy;

void main()
{
int gdriver=DETECT,gmode,error;
initgraph(&gdriver,&gmode,"c:\turboc3\bgi\");
error=graphresult();
if(error!=grOk)
{
printf("Error in graphics, code= %d",grapherrormsg(error));
exit(0);
}

while(1)
{
clockLayout();
secHand();
minHand();
hrHand();
sleep(1); /* pausing the outputscreen for 1 sec */
cleardevice(); /* clearing the previous picture of clock */
}
}

void clockLayout()
{
int i,x,y,r;
float j;
maxx=getmaxx();
maxy=getmaxy();

for(i=1;i<5;i++)
{ /* printing a round ring with outer radius of 5 pixel */
setcolor(YELLOW);
circle(maxx/2,maxy/2,120-i);
}

pieslice(maxx/2,maxy/2,0,360,5); /* displaying a circle in the middle


of clock */
x=maxx/2+100;y=maxy/2;
r=100;
setcolor(BLUE);
for(j=PI/6;j<=(2*PI);j+=(PI/6))
{ /* marking the hours for every 30 degrees */
pieslice(x,y,0,360,4);
x=(maxx/2)+r*cos(j);
y=(maxy/2)+r*sin(j);
}

x=maxx/2+100;y=maxy/2;
r=100;
setcolor(RED);

for(j=PI/30;j<=(2*PI);j+=(PI/30))
{ /* marking the minutes for every 6 degrees */
pieslice(x,y,0,360,2);
x=(maxx/2)+r*cos(j);
y=(maxy/2)+r*sin(j);
}
}

void secHand()
{
struct time t;
int r=80,x=maxx/2,y=maxy/2,sec;
float O;

maxx=getmaxx();maxy=getmaxy();
gettime(&t); /*getting the seconds in system clock */
sec=t.ti_sec;
O=sec*(PI/30)-(PI/2); /* determining the angle of the line with
respect to vertical */
setcolor(YELLOW);
line(maxx/2,maxy/2,x+r*cos(O),y+r*sin(O));
}
void hrHand()
{
int r=50,hr,min;
int x,y;
struct time t;
float O;

maxx=getmaxx();
maxy=getmaxy();
x=maxx/2,y=maxy/2;
gettime(&t); /*getting the seconds in system clock */
hr=t.ti_hour;
min=t.ti_min;

/* determining the angle of the line with respect to vertical */


if(hr<=12)O=(hr*(PI/6)-(PI/2))+((min/12)*(PI/30));
if(hr>12) O=((hr-12)*(PI/6)-(PI/2))+((min/12)*(PI/30));
setcolor(BLUE);
line(maxx/2,maxy/2,x+r*cos(O),y+r*sin(O));
}
void minHand()
{
int r=60,min;
int x,y;
float O;
struct time t;
maxx=getmaxx();
maxy=getmaxy();
x=maxx/2;
y=maxy/2;
gettime(&t); /*getting the seconds in system clock */
min=t.ti_min;
O=(min*(PI/30)-(PI/2)); /* determining the angle of the line with
respect to vertical */
setcolor(RED);
line(maxx/2,maxy/2,x+r*cos(O),y+r*sin(O));
}
In my collection, here are the main advantages and disadvantages of
both.

Analog pros

• easy to read quickly


• easy to estimate elapsed time

• often more reliable

• can run on electricity or be mechanically driven (springs or

weights)
Analog cons

• requires learning how to tell time


• hard to see in the dark

• often loud ticking


• alarm clocks don’t always go off at the precise time set

Digital pros

• easy to read
• often well lit

• alarm goes off at precise time


• silent

Digital cons

• easy to misread (sometimes an 8 looks like a 0)


• very limited viewing angle

• only run on electricity

• lit screens can sometimes too bright enough to make it difficult


to sleep
These are some of the main advantages and disadvantages of analog
and digital clocks. Watches are a completely different set of pros and
cons, however.
ADVANTAGES AND DISADVANTAGES

In my collection, here are the main advantages and disadvantages of


both.

Analog pros Analog cons

• easy to read quickly • requires learning how to


tell time

• often more reliable • hard to see in the dark

• can run on electricity or be • often loud ticking


mechanically driven
(springs or weights)

• easy to estimate elapsed • alarm clocks don’t always


time go off at the precise time
set

Digital pros Digital cons

• easy to read • easy to misread


(sometimes an 8 looks like
a 0)

• often well lit • very limited viewing angle

• alarm goes off at precise • only run on electricity


time
These are some of the main advantages and disadvantages of analog
and digital clocks. Watches are a completely different set of pros and
cons, however.

CONCLUSION

This project shows the graphical representation of a


working analogue clock.The objective of the program is to
implement simple and basic functionsof openGL. Computer
graphics play a mojor role in todays world where virsulization
takes the upper hand as compare to textual interaction. This
is largely true as we can she filds 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 simulization which involved complex
graphics being highlighted at its peular system efficiency by
studying its simulated model attracts more people towards it
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 Hunghes, Addison-Wesley 1997
4) Computer Graphics- OpenGL Version-Donald Hearn and
Pauline Baker, 2nd Editon, pearson Education

You might also like