Computer Graphics Report
Computer Graphics Report
Computer Graphics Report
Chapter 1
INTRODUCTION
• Graphics provides one of the most natural means of communicating with a computer, since our
data rapidly.
• Computers have become a powerful medium for the rapid and economical production of
pictures.
• There is virtually no area in which graphical displays cannot be used to some advantage.
• Graphics provide a so natural means of communicating with the computer that they have
become widespread.
• Interactive graphics is the most important means of producing pictures since the invention of
• We can make pictures of not only the real world objects but also of abstract objects such as
graphics applications. Since its introduction in 1992, OpenGL has become the industry's most
widely used and supported 2D and 3D graphics application programming interface (API),
broad set of rendering, texture mapping, special effects, and other powerful visualization
functions. Developers can leverage the power of OpenGL across all popular desktop and
Supported on all UNIX® workstations, and shipped standard with every Windows 95/98/2000/NT
and MacOS PC, no other graphics API operates on a wider range of hardware platforms and
software environments.
OpenGL runs on every major operating system including Mac OS, OS/2, UNIX,
Windows 95/98, Windows 2000, Windows NT, Linux, OPENStep, and BeOS; it also works with
every major windowing system, including Win32, MacOS, Presentation Manager, and X-Window
System. OpenGL is callable from Ada, C, C++, Fortran, Python, Perl and Java and offers complete
Chapter 2
SOFTWARE AND HARDWARE REQUIREMENTS
2.1 Hardware Requirements
The standard output device is assumed to be a Color Monitor. It is quite essential for
any graphics package to have this, as provision of color options to the user is a must. The mouse,
the main input device, has to be functional i.e. used to give input in the game. A keyboard is used
for controlling and inputting data in the form of characters, numbers i.e. to change the user views
. Apart from these hardware requirements there should be sufficient hard disk space and primary
memory available for proper working of the package to execute the program. Pentium III or higher
processor, 16MB or more RAM. A functional display card.
Minimum Requirements expected are cursor movement, creating objects like lines,
squares, rectangles, polygons, etc. Transformations on objects/selected area should be possible.
Filling of area with the specified color should be possible.
Developed Platform
Windows 10
C-language
Developer C++
Chapter 3
PROPOSED SYSTEM :
platforms.
3. With OpenGL, we can draw a small set of geometric primitives such as points, lines and
polygons etc.
SYSTEM DESIGN :
Existing System Existing system for a graphics is the TC++ . This system will support
only the 2D graphics. 2D graphics package being designed should be easy to use and understand.
It should provide various option such as free hand drawing , line drawing , polygon drawing , filled
polygons, flood fill, translation , rotation , scaling , clipping etc. Even though these properties were
supported, it was difficult to render 2D graphics cannot be . Very difficult to get a 3Dimensional
object. Even the effects like lighting , shading cannot be provided. So we go for Eclipse software.
Chapter 4
IMPLEMENTATION
This function is used to mention the color in which the pixel should appear. The number
3 specifies the number of arguments that the function would take. ‘f ’ gives the type that is float.
The arguments are in the order RGB(Red, Green, Blue). The color of the pixel can be specified
This function is used to clear the color of the screen. The 4 values that are passed as
arguments for this function are (RED, GREEN, BLUE, ALPHA) where the red green and blue
components are taken to set the background color and alpha is a value that specifies depth of the
Void glutKeyboardFunc();
where func is the new keyboard callback function. glutKeyboardFunc sets the keyboard callback
for the current window. When a user types into the window, each key press generating an ASCII
character will generate a keyboard callback. The key callback parameter is the generated ASCII
character. The x and y callback parameters indicate the mouse location in window relative
coordinates when the key was pressed. When a new window is created, no keyboard
callbacinitially registered, and ASCII key strokes in the window are ignored. Passing NULL to
Void glFlush();
where mode Specifies which matrix stack is the target for subsequent matrix operations.
Three values are accepted: GL_MODELVIEW, GL_PROJECTION, and GL_TEXTURE. The
initial value is GL_MODELVIEW.
glMatrixMode sets the current matrix mode. mode can assume one of three values:
where x, y Specify the lower left corner of the viewport rectangle, in pixels. The initial value is
(0, 0).
width, height Specify the width and height of the viewport. When a GL context is first attached to
a surface (e.g. window), width and height are set to the dimensions of that surface. glViewport
specifies the affine transformation of x and y from normalized device coordinates to window
coordinates. Let (xnd, ynd) be normalized device coordinates. Then the window coordinates (xw,
yw) are computed as follows:
xw = ( xnd + 1 ) width/2 + x
yw = ( ynd + 1 ) height/2 + y
Viewport width and height are silently clamped to a range that depends on the implementation. To
query this range, call glGetInteger with argument GL_MAX_VIEWPORT_DIMS.
glutInit will initialize the GLUT library and negotiate a session with the window system.
During this process, glutInit may cause the termination of the GLUT program with an error
message to the user if GLUT cannot be properly initialized. Examples of this situation include the
failure to connect to the window system, the lack of window system support for OpenGL, and
invalid command line options.glutInit also processes command line options, but the specific
options parse are window system dependent.
glutReshapeFunc sets the reshape callback for the current window. The reshape callback
is triggered when a window is reshaped. A reshape callback is also triggered immediately before
a window's first display callback after a window is created or whenever an overlay for the window
is established. The width andheight parameters of the callback specify the new window size in
pixels. Before the callback, the current window is set to the window that has been reshaped.
If a reshape callback is not registered for a window or NULL is passed to glutReshapeFunc (to
deregister a previously registered callback), the default reshape callback is used. This default
callback will simply void
glutMainLoop(void);
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
4.2 ALGORITHM
// Tic Tac Toe or X's and 0's.
// Keyboard input
#include <GL/glut.h> // glut (gl utility toolkit) basic windows functions, keyboard, mouse.
#include<string.h>
// lighting
int abc=0;
// player or computer; 1 = X, -1 = O
//
// 0 | 1 | 2
// 3 | 4 | 5
// 6 | 7 | 8
int computer_move()
if ( blocking_win() == 1) return( 1 );
if ( check_corner() == 1) return( 1 );
return( 0 );
if (spin > 360) spin = 180; // if over 360 degress, start back at zero.
Cylinder = gluNewQuadric();
glPushMatrix();
glTranslatef(x, y, z);
glRotatef(a, 1, 0, 0);
glPopMatrix();
glPushMatrix();
glTranslatef(x, y, z);
glPushMatrix();
glRotatef(a, 1, 0, 0);
glRotatef(90, 0, 1, 0);
glRotatef(45, 1, 0, 0);
glTranslatef( 0, 0, -3);
void display(void)
if(abc==3)
//int mk=0;
// glColor3f(0.0,1.0,0.0);
glColor3f(0.0,1.0,0.0);
glMatrixMode (GL_PROJECTION); // Tell opengl that we are doing project matrix work
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
glutSwapBuffers();
// Main program
glutInit(&argc, argv);
glutInitWindowSize (850,600);
glutCreateWindow (argv[0]);
init ();
glutCreateMenu(menu);
glutAddMenuEntry("start game",1);
glutAddMenuEntry("prespective view",2);
glutAddMenuEntry("help",3);
glutAddMenuEntry("Quit",4);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
//glutMouseFunc(mouse);
glutMainLoop();
return 0;
Chapter 5
SNAPSHOTS :
Fig 5.2 : Snapshot Showing of player view of tic-tac-toe game with help of X’s and 0’s
Chapter 6
CONCLUSION
The full designing and creating of Tic-Tac-Toe has been executed under windows
operating system using dev c++, this platform provides a and satisfies the basic need of a good
compiler. Using GL/glut.h library and built in functions make it easy to design good graphics
package such as this simple game.
A player can play perfect tic-tac-toe (win or draw) given they move according to the highest
possible moves:
1. Win: If the player has two in a row, play the third to get three in a row.
2. Block: If the opponent has two in a row, play the third to block them.
Option 1: Create two in a row to force the opponent into defending, as long as it doesn't result in
them creating a fork or winning. For example, if "X" has a corner, "O" has the center, and "X" has
the opposite corner as well, "O" must not play a corner in order to win. (Playing a corner in this
scenario creates a fork for "X" to win.)
Option 2: If there is a configuration where the opponent can fork, block that fork.
6. Opposite corner: If the opponent is in the corner, play the opposite corner.
REFERENCES
1. Reference from Interactive Computer Graphics by EDWARD ANGEL
2. Internet source
www.angelfire.com
Wikipedia.org.
Opengl.org