Professional Documents
Culture Documents
c
Chapter 1
INTRODUCTION
OpenGL :
OpenGL provides a set of commands to render a three dimensional scene. That means
you provide the data in an OpenGL-useable form and OpenGL will show this data on the screen
(render it). It is developed by many companies and it is free to use. You can develop OpenGL-
applications without licensing.
GLUT :
GLUT is a complete API written by Mark Kilgard which lets you create windows and
handle the messages. It exists for several platforms, that means that a program which uses GLUT
can be compiled on many platforms without (or at least with very few) changes in the code.
Use of GLUT:
GLUT provides some routines for the initialization and creating the window (or
fullscreen mode, if you want to). Those functions are called first in a GLUT application. In your
first line you always write g
. After this, you must tell GLUT, which display
mode you want ± single or double buffering, color index mode or RGB and so on. This is done
by calling .
The symbolic constants are connected by a logical OR, so you could use
!. In later tutorials we will use some more
constants here. After the initialization you call "#$ with the window name as
OpenGL Pipeline
Also clipping non visible parts of the scene in order to produce viewing volume.
dvantages of OpenGL:
REQUIREMENT SPECIFICTION
Software Requirements
Operating System : -indows
Version of Operating System : -indows XP, -indows NT
Memory : 128MB of RAM
Language : C++
Compiler : Visual C++ 6.0
Hardware Requirements
Hardware Type : Pentium
Version : Pentium 4.0
DESIGN
Road ();
Bus_stop();
Display function
Bus_move();
Main function
Keyboard function
Man_draw();
Bus_draw();
CreateMenu function
IMPLEMENTTION
HEDER FILES
#include<stdio.h>
It is a standard input/output file. Standard I/O refers to the most usual places where data is either
read from, the keyboard, or written to, the video monitor. Since they are used so much, they are
used as the default I/O devices and do not need to be named in the Input/output instructions.
#include<GL/glut.h>
GL is the fundamental openGL library. It provides functions that are permanent part of OpenGL.
The functions start with characters µgl¶.
GLUT, the GL utility tool kit supports developing and managing menus, and managing events.
The functions start with characters µglut¶.
GLU, the GL Utility Library provides high-level routines to handle certain matrix operations,
drawing of quadric surfaces such as sphere and cylinders. The functions start with characters
µglu¶.
2
cc
PARAMETERS:
func
The new display callback function.
glutDisplayFunc(display);
glutKeyboardFunc Function: -hen the keyboard event occurs, the ASCII code for the
key that generated the event and the location of the mouse are returned.
"c!2c
c!cc#ccc
c
glClearColor Function: The glClearColor function specifies clear values for the color
buffers.
SYNTAX:"c2 cc&%
cc &%
c2&%
c &%
cc
The red, green, blue and alpha values that glClear uses to clear the color buffers. The default
values are all zero.
Initial view from front:This is the initial output screen obtained on executing the program. This
scene, as we can see includes a man waiting at the bus stop and a bus.
Bus at bus stop:This is the snapshot when bus reaches the bus stop. The movement of bus can
be manually done by arrow keys & automatically by enabling timer function.
CONCLUSION
This project called BUS STOP is an implementation to demonstrate the skills I have
learnt in while executing the graphics laboratory programs. -hile working out with the project, I
came out with various aspects and interesting facts about OpenGL functions & the relevant way
of using those functions.
BIBLIOGRPHY
Chapter 2
REQUIREMENTS
Software Requirements:
¦c An MS-DOS based operating system like -indows 98, -indows 2000 or -indows XP
is the platform required to develop the 2D and 3D graphics applications.
¦c A Visual C/C++ compiler is required for compiling the source code to make the
executable file which can then be directly executed.
¦c A built in graphics library like glut and glut32, and header file like glut.h and also
dynamic link libraries like glut and glut32 are required for creating the 3D layout.
Hardware Requirements:
The hardware requirements are very minimal and the software can run on most of the
machines.
¦c Processor - Intel 486/Pentium processor or above.
DESIGN
The design part of the game deals with how the game has divided and designed
according to the interaction and implementation. Each subsystem provides its own functionalities
independent of the services provided by the other subsystem. Each subsystem then further
divided into modules which explain the subsystem in detail.
The diagram below is used to represent the control relationship between the subsystems,
which is shown below
Relationship diagram
Game Subsystem
These modules are most important modules of the project and implement the Rapid-Roll
game.
ëc Play module
ëc Displayscores module
c
Play Module:
This module initializes the variables and data structures used in the game. The data
structures are initialized to represent the initial state of the game.
Displayscore module:
This module helps the for getting the information about the current score of the user
when the game ends.
The game basically consists of a player who has to control the object moving around the
play area in the order specified. The game has six levels based on the speed of movement of
objects on the screen. The level of difficulty increases as the game goes further. The speed of
movement of the objects will increase in the higher rounds. The details of points scoring are
present.
The game consists of a user interface provided by keyboard along with graphical output
consisting of different objects like polygons. Each stage has one or more objects moving around
in the screen. On completing each stage, the player advances to next stage, which is of greater
difficulty, in terms of speed of the movement of the objects.
The game begins with a welcome screen and following that will have a menu screen
where in the player can view the rules and how to play information. The inputs to the game are
the name of player and the level number. After the game is loaded the play area will displayed
along with the scoreboard which shows the current players detailed score.
There are three objects rectangles, diamond and thorns which are moving upward. There
are 6 levels in the game with increasing speed of movement of the objects. The objects are filled
with color which helps in identifying the objects clicked so that the order is followed and points
are awarded accordingly. The game starts displaying the player name and level number. The
game enters to higher level automatically. The game ends if crashed and the final score is
displayed. ESC key is used to exit from the game.
IMPLEMENTTION
HEDER FILES
#include<stdio.h>
It is a standard input/output file. Standard I/O refers to the most usual places where data is either
read from, the keyboard, or written to, the video monitor. Since they are used so much, they are
used as the default I/O devices and do not need to be named in the Input/output instructions.
#include<GL/glut.h>
GL is the fundamental openGL library. It provides functions that are permanent part of OpenGL.
The functions start with characters µgl¶.
GLUT, the GL utility tool kit supports developing and managing menus, and managing events.
The functions start with characters µglut¶.
GLU, the GL Utility Library provides high-level routines to handle certain matrix operations,
drawing of quadric surfaces such as sphere and cylinders. The functions start with characters
µglu¶.
¦c glClear Function
¦c glColor3f Function
¦c glRasterpos2f Function
¦c glClearColor Function
¦c glutBitmapCharacter Function
¦c glBegin, glEnd Function
¦c glRectf Function
¦c glVertex2f Function
¦c glFlush Function
¦c glPostRedisplay Function
¦c glMatrixMode Function
¦c glLoadIdentity Function
¦c gluOrtho2D Function
Main Functions:
¦c glutInit Function
¦c glutInitWindowSize Functions
¦c glutCreateWindow Function
¦c glutDisplayFunc Function
¦c glutKeyboardFunc Function
¦c glutMouseFunc Function
¦c glutMainLoop Function
glColor3f Function:
SYNTAX:
PARAMETERS:
wc red
The new red value for the current color.
wc green
The new green value for the current color.
glRasterpos2f Function:
SYNTAX:
PARAMETERS:c
x, y, z, w
The x, y, z, and w object coordinates (if present) for the raster position.
SYNTAX:
PARAMETERS:
mode
The primitive or primitives that will be created from vertices presented between
GL_POLYGON:
glRectf Function:
SYNTAX:
c2 (
c
cc&% c#-c
cc&% c-c
cc&% c#*c
cc&% c*c
wc x1, y1
wc x2, y2
glVertex2f Function:
Specifies a vertex.
SYNTAX:
PARAMETERS:
wc x
Specifies the x-coordinate of a vertex.
wc y
Specifies the y-coordinate of a vertex.
glVertex2f(-3.0,3.0);
glClear Function:
SYNTAX:
mask
Bitwise OR operators of masks that indicate the buffers to be cleared. The four
masks are as follows.
Value Meaning
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity Function:
The glLoadIdentity function replaces the current matrix with the identity matrix.
SYNTAX:
c2 %c
PARAMETERS:
glLoadIdentity();
glMatrixMode Function:
SYNTAX:
mode
wc glMatrixMode(GL_MODELVIE-);
wc glMatrixMode(GL_PROJECTION);
glFlush Function:
Forces any buffered OpenGL commands to execute.
SYNTAX:
2
ccc
glutBitmapCharacter Function:
It renders the character with ASCII code char at the current raster position using the
raster font given by font.
SYNTAX:
cc2 +
ccccc
cc
PARAMETERS:
wc GLUT_BITMAP_TIMES_ROMAN_10
wc GLUT_BITMAP_TIMES_ROMAN_8_BY_13
glPostRedisplay Function:
It request that the display callback be executed after current callback return.
gluOrtho2D:
SYNTAX:
"c2 . *cc
c c &% cc 2 c
c c &% c c
c c &% cc
ccccccccc
PARAMETERS:
wc left, right
The coordinates for the left and right vertical clipping planes.
wc bottom, top
The coordinates for the bottom and top horizontal clipping planes.
MIN FUNCTIONS:
glutInit Function:
glutInit is used to initialize the GLUT library.
SYNTAX:
2 c 2
c
c 2c
SYNTAX:
glutCreateWindow Function:
2
cc
glutDisplayFunc Function:
SYNTAX:
PARAMETERS:
func
The new display callback function.
glutDisplayFunc(display);
glutKeyboardFunc Function:
-hen the keyboard event occurs, the ASCII code for the key that generated the event and
the location of the mouse are returned.
SYNTAX:
2
!c
"c!2c
c!cc#ccc
glutMainLoop Function:
SYNTAX:
2 $%c
c
glClearColor Function:
The glClearColor function specifies clear values for the color buffers.
SYNTAX:
The red, green, blue and alpha values that glClear uses to clear the color buffers. The default
values are all zero.
SNPSHOTS
CONCLUSION
-e started out with the intention of designing a simple game with the objective that the
object should avoid obstacles in its way. -ith little experience in programming projects such as
this, we ended up learning many things.
The game Rapid-Roll that we have designed currently has features such as
increase/decrease speed, menus, lighting in 6 levels of game play. Adding more levels is simple
and we intend to do so in the future. This project has all the features which makes for a small
Graphics project. The code is open source and the user is free to alter it for feature enhancement.
-hile designing this project we learnt a lot of things like the software engineering
techniques required to code a project, debugging skills required to remove the bugs from a code
and also learnt how to optimize a code so that it runs on lower end machines as well.
-e thus conclude by saying that we are extremely happy we got a chance to design a
project such as this and are looking forward to designing more such projects in the future.
Chapter 9
BIBLIOGRPHY
V
wc Edward Angel: Interactive Computer Graphics A TOP DO-N APPROACH with opengl,
second edition, Addison -esley,2000
-
wc www.opengl.org/resources/code/samples/sig99/advanced99/notes/notes.html
wc www.wikipedia.org