Computer Graphics Report
Computer Graphics Report
Chapter 1
INTRODUCTION
The development of computer graphics has been driven both by the needs of the user
community and by advances in hardware and software.
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.
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
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.
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.
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.
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.
GLU
Frame
GL buffer
OpenGL
Application
program Xlib, Xtk
GLUT
GLX
Geometric Primitives
Image(Raster) Primitives
Geometric primitives are specified in the problem domain and include points, line
segments, polygons, curves and surfaces.
Raster primitives, such as arrays of pixels pass through a separate parallel pipeline on
their way to the frame buffer.
Chapter 2
Chapter 3
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.
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.
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.
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.
START
MAIN
END OF INPUT
CALCULATE
PRINT OUTPUT
STOP
Chapter 5
IMPLEMENTATION
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.
#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;
// lighting
int l,i;
l=strlen( st );
glRasterPos3f( x, y, -1);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, st[i]);
rx = 30 * cos( angle );
ry = 30 * sin( angle );
rz = 30 * cos( angle );
angle += 0.01;
glutPostRedisplay();
void init(void)
glShadeModel (GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT1);
Cylinder = gluNewQuadric();
Disk = gluNewQuadric();
int i;
glPushMatrix();
glTranslatef(0,0,1);
glPopMatrix();
glPushMatrix();
glutSolidCube( 1.0 );
glPopMatrix();
glPushMatrix();
glTranslatef(cx,cy,cz);
glutWireCube(14.0);
glPopMatrix();*/
glTranslatef( 0, 0, 1.0);
glPopMatrix();
glTranslatef( 0, 0, 0.0);
glPushMatrix();
Draw_gear();
glPopMatrix();
glPopMatrix();
glTranslatef( 0, 0, 0.0);
glPushMatrix();
Draw_gear();
glPopMatrix();
glPopMatrix();
glTranslatef( 0, 0, -0.0);
glPushMatrix();
Draw_gear();
glPopMatrix();
glPopMatrix();
glutSolidCube(1.0);
glPopMatrix();
glPushMatrix();
glutSolidCube(0.25);
glPopMatrix();
glPopMatrix();
void num()
if(view_state == 1)
Sprint(-0.2,-6.2,"6");
Sprint(-0.4,5.7,"12");
Sprint(5.8,-0.2,"3");
void about()
//glClear(GL_COLOR_BUFFER_BIT);
Sprint(-5,-3.6," is displayed");
//glFlush();
void display_clock()
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
else
about();
Sprint(-4,-7.7, asctime(newtime));
if (view_state == 0)
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if (light_state == 1)
glEnable(GL_LIGHTING);
}else
glDisable(GL_LIGHTING);
num();
glutSwapBuffers();
void display(void)
glClear(GL_COLOR_BUFFER_BIT);
display_clock();
glFlush();
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
switch(id)
case 1:
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
break;
case 2:
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
break;
case 3:
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
break;
case 4 :
exit(0);
glutInit(&argc, argv);
glutCreateWindow (argv[0]);
glutSetWindowTitle("GLclock");
init ();
glutCreateMenu(options);
glutAddMenuEntry("Light on/off",3);
glutAddMenuEntry("Quit",4);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
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.
Chapter 7
SNAPSHOTS
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.
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.
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