Report
Report
Report
CHAPTER 1
INTRODUCTION
Computer graphics are graphics created using computers and more generally, the
representation and manipulation of image data by a computer.
The development of computer graphics has made computers easier to interact with, and better for
understanding and interpreting many types of data. Developments in computer graphics have a
profound impact on many types of media and have revolutionized animation, movies and the
video game industry.
Today, computers and computer-generated images touch many aspects of daily life.
Computer image is found on television, in newspapers, for example in weather reports, in all
kinds of medical investigation and surgical procedures. A well-constructed graph can present
complex statistics in a form that is easier to understand and interpret. In the media such graphs
are used to illustrate papers, reports, and other presentation material.
Many powerful tools have been developed to visualize data. Computer generated
imagery can be categorized into several different types: 2D , 3D , 5D, and animated graphics. As
technology has improved, 3D computer graphics have become more common, but 2D computer
graphics are still widely used. Computer graphics has emerged as a sub-field of computer science
which studies methods for digitally synthesizing and manipulating visual content. Over the past
decade, other specialized fields have been developed like information visualization, and
scientific visualization more concerned with “the visualization of three dimensional phenomena”
Nowadays Computer Graphics used in almost all the areas ranges from science, engineering,
medicine, business, industry government, art, entertainment, education and training.
Another major application area presentation graphics used to produce illustrations for reports or
generate slides. Presentation graphics is commonly used to summarize financial, statistical,
mathematical, scientific data for research reports and other types of reports.2D and 3D bar chart
to illustrate some mathematical or statistical report.
1.5 Objectives
To implement the concepts of Computer Graphics we have learnt.
Intel®Pentium or AMD
1GB RAM
80GB HDD
Mouse
QWERTY Keyboard
Standard VGA Monitor
CHAPTER 2
INTRODUCTION TO OPENGL
As a software interface for graphics hardware, OpenGL's main purpose is to render two- and
three-dimensional objects into a frame buffer. These objects are described as sequences of
vertices (which define geometric objects) or pixels (which define images). OpenGL performs
several processing steps on this data to convert it to pixels to form the final desired image in the
frame buffer.
eventually ends up in the frame buffer). Primitives are specified, modes are set, and other
OpenGL operations are described by issuing commands in the form of function calls.
Primitives are defined by a group of one or more vertices. A vertex defines a point, an endpoint
of a line, or a corner of a polygon where two edges meet. Data (consisting of vertex coordinates,
colors, normals, texture coordinates, and edge flags) is associated with a vertex, and each vertex
and its associated data are processed independently, in order, and in the same way. The only
exception to this rule is if the group of vertices must be clipped so that a particular primitive fits
within a specified region; in this case, vertex data may be modified and new vertices created. The
type of clipping depends on which primitive the group of vertices represents.
Commands are always processed in the order in which they are received, although there may be
an indeterminate delay before a command takes effect. This means that each primitive is drawn
completely before any subsequent command takes effect. It also means that state-querying
commands return data that's consistent with complete execution of all previously issued OpenGL
commands.
The effects of OpenGL commands on the frame buffer are ultimately controlled by the window
system that allocates frame buffer resources. The window system determines which portions of
the frame buffer OpenGL may access at any given time and communicates to OpenGL how
those portions are structured. Therefore, there are no OpenGL commands to configure the frame
buffer or initialize OpenGL. Frame buffer configuration is done outside of OpenGL in
conjunction with the window system; OpenGL initialization takes place when the window
system allocates a window for OpenGL rendering. (GLX, the X extension of the OpenGL
interface, provides these capabilities).
In the diagram, commands enter from the left and proceed through what can be thought of as a
processing pipeline. Some commands specify geometric objects to be drawn, and others control
how the objects are handled during the various processing stages.
As shown by the first block in the diagram, rather than having all commands proceed
immediately through the pipeline, you can choose to accumulate some of them in a display list
for processing at a later time.
The evaluator stage of processing provides an efficient means for approximating curve and
surface geometry by evaluating polynomial commands of input values. During the next stage,
per-vertex operations and primitive assembly, OpenGL processes geometric primitives—points,
line segments, and polygons, all of which are described by vertices. Vertices are transformed and
lit, and primitives are clipped to the viewport in preparation for the next stage.
Rasterization produces a series of frame buffer addresses and associated values using a two-
dimensional description of a point, line segment, or polygon. Each fragment so produced is fed
into the last stage, per-fragment operations, which performs the final operations on the data
before it's stored as pixels in the frame buffer. These operations include conditional updates to
the frame buffer based on incoming and previously stored z-values (for z-buffering) and
blending of incoming pixel colors with stored colors, as well as masking and other logical
operations on pixel values.
Input data can be in the form of pixels rather than vertices. Such data, which might describe an
image for use in texture mapping, skips the first stage of processing described above and instead
is processed as pixels, in the pixel operations stage. The result of this stage is either stored as
texture memory, for use in the rasterization stage, or rasterized and the resulting fragments
merged into the frame buffer just as if they were generated from geometric data.
All elements of OpenGL state, including the contents of the texture memory and even of the
frame buffer, can be obtained by an OpenGL application.
It’s not just Operating System that provide APIs. Every programming library (and
there are thousands available, both commercial or free) has an API. It’s the job of a programmer
to read and understand APIs so that he/she can make the best use of them.
glutSwapBuffers(void):
Specifies the background color to be used by glClear() , when clearing the buffer.
glClear(GLbitfield mask):
Clears one or more of the existing buffers. The mask is logical or (“|”) of any of the following :
GL_COLOR_BUFFER_BIT,GL_DEPTH_BUFFER_BIT.
glFlush():
OpenGL normally saves or “buffers” drawing commands for greater efficiency. This forces the
image to be redrawn , in case the next update will be far in the future.
glBegin(GLenum mode)…glEnd(void):
glVertex*(…):
glNormal*(...):
Specify the surface normal for subsequent vertices. The normal should be of unit length after the
modelview transformation is applied. Call glEnable (GL_NORMALIZE) to have OpenGL do
normalization automatically.
glColor*(…):
Specify the color of subsequent vertices . This is normally used if lighting is not enabled .
Otherwise , colors are defined by glMaterial*() , defined below under lighting .
glLineWidth(GLfloat width):
glRasterPos*(...):
Set the current raster position (in 3D window coordinates) for subsequent glutBitmapCharacter
() and other pixel copying operations.
Draw the given character of the given font at the current raster position and advance the current
raster position. Fonts include GLUT_BITMAP_9_BY_15, GLUT_BITMAP_8_BY_13,
GLUT_BITMAP_TIMES_ROMAN_10, GLUT_BITMAP_TIMES_ROMAN_24. When a
character is drawn, the raster position is advanced. So to draw a string, initialize the raster
position (using glRasterPos*()) and then call this on each character of the string.
Sets the current viewport, that is, the portion of the window to which everything will be clipped.
Typically this is the entire window: glViewport (0, 0, win width, win height), and hence this
should be called whenever the window is reshaped.
glMatrixMode(GLenum mode):
glLoadIdentity (void):
glPushMatrix (void):
Make a copy of the current matrix and push it onto the stack.
glPopMatrix (void):
GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window
system independent toolkit for writing OpenGL programs. It implements a simple windowing
application programming interface (API) for OpenGL. GLUT makes it considerably 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. While GLUT is well-suited
to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-featured
toolkit so large applications requiring sophisticated user interfaces are better off using native
window system toolkits. GLUT is simple, easy, and small. The GLUT library has C, C++ (same
as C), FORTRAN, and ADA programming bindings. The GLUT source code distribution is
portable to nearly all OpenGL implementations and platforms.
CHAPTER 3
PROJECT DESCRIPTION
Some of the basic requirements for the development of this project are as follows:
Header Files:
glClear( ):
Takes a single argument that is the bitwise OR of several values indicating which buffer is to be
cleared.
glClearColor ():
Specifies the red, green, blue, and alpha values used by glClear to clear the color buffers.
glLoadIdentity( ):
glMatrixMode(mode):
Initializes GLUT, the arguments from main are passed in and can be used by the application.
Requests a display with the properties in mode. The value of mode is determined by the logical
OR of options including the color model and buffering.
Specifies the initial position of the top-left corner of the window in pixels..
Register the display function func that is executed when the window needs to be redrawn.
glutPostReDisplay ( ) :
Which requests that the display callback be executed after the current callback returns.
Cause the program to enter an event-processing loop. It should be the last statement in main
function.
glFlush():
glPushMatrix():
glPopMatrix():
glRasterpos3f(x,y,z):
void screen1( ):
void screen3( ):
void pillars( ):
void bridge( ):
void track( ):
void light( ):
To set the initial coordinates the signal light and set the colors.
void new1( ),void new2( ),void new3( ),void new4( ),void new5( ):
To control the movements of bridge, ship, train, plane and water.
void update( ):
To update the movement values of bridge, ship, train, plane and water.
void mydisplay( ):
To control the display of multiple screens.
void mykeyboard( ):
To get user input through keyboard.
3.3 IMPLEMENTATION
#include<GL/glut.h>
#include<string.h>
int i,flag=0,flag2=0,flagb=1,flags=0,flagt=0,flagp=0,flagw=1,flagx=0;
float a=0.0f , b=0.0f , c=0.0f , m=0.0f , n=0.0f, o=0.0f , p=0.0f , q=0.0f , r=0.0f , x=0.0f , y=0.0f ,
z=0.0f , a1=0.0 , a2=0.0 , a3=0.0,j;
void *currentfont;
void setFont(void *font){
currentfont=font;
}
void drawstring(char string[],float x1,float y1,float z1){
int i , j;
j=strlen(string);
glRasterPos3f(x1,y1,z1);
for (i=0;i<j;i++){
glutBitmapCharacter(currentfont, string[i]);
}
}
void screen1(){
glClearColor(0.5,0.2,0.8,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(1.0,1.0,1.0);
char str1[]="COORG INSTITUTE OF TECHNOLOGY";
drawstring(str1,-0.5,0.9,0.0);
glColor3f(0.9,0.9,0.9);
char str2[]="DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING";
drawstring(str2,-0.7,0.8,0.0);
glColor3f(0.8,0.8,0.8);
char str3[]="A MINI PROJECT ON";
drawstring(str3,-0.3,0.7,0.0);
glColor3f(1.0,0.7,0.7);
char str4[]="-*- VERTICAL LIFT BRIDGE SIMULATION -*-";
drawstring(str4,-0.65,0.6,0.0);
glColor3f(0.2,0.8,0.5);
char str5[]="BY :";
drawstring(str5,-0.5,0.5,0.0);
glColor3f(1.0,1.0,0.0);
char str6[]="AMAL KURIAKOSE (4CI14CS010)";
drawstring(str6,-0.5,0.4,0.0);
char str7[]="M ARJUN PRADEEP (4CI14CS038)";
drawstring(str7,-0.5,0.3,0.0);
glColor3f(0.2,0.8,0.5);
char str8[]="GUIDES :";
drawstring(str8,-0.5,0.1,0.0);
glColor3f(1.0,1.0,0.0);
char str9[]="Mr . BHARATH (Asst.prof. Dept of CSE)";
drawstring(str9,-0.5,0.0,0.0);
char str10[]="Mr . RAVISHANKAR (Asst.prof. Dept of CSE)";
drawstring(str10,-0.5,-0.1,0.0);
glColor3f(1.0,0.9,1.0);
char str11[]="INSTRUCTIONS ";
drawstring(str11,-0.3,-0.5,0.0);
char str12[]="----------------";
drawstring(str12,-0.35,-0.55,0.0);
char str13[]=" * * * PRESS -ENTER - TO START AND -ESC- TO EXIT * *
*";
drawstring(str13,-0.9,-0.7,0.0);
char str14[]="PRESS -S- TO START ANIMATION AND PRESS -T- TO STOP
ANIMATION";
drawstring(str14,-1.05,-0.85,0.0);
glFlush();
}
void screen3(){
glClearColor(1.0,0.5,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,0.0,0.0);
char str1[]=" * * * THANK YOU * * * ";
drawstring(str1,-0.2,0.2,0.0);
char str2[]=" ------------------------- ";
drawstring(str2,-0.3,0.1,0.0);
glFlush();
}
void water(){
glBegin(GL_QUADS);
glColor3f(0.0,0.4,0.7);
glVertex3f(-5.0,-0.415,5.0);
glVertex3f(5.0,-0.415,5.0);
glVertex3f(5.0,-0.415,-5.0);
glVertex3f(-5.0,-0.415,-5.0);
glEnd();
}
void lines(){
float t1,t2;
glBegin(GL_LINES);
for(t1=0.0;t1<=10.0;t1+=0.4){
for(t2=0.0;t2<=10.0;t2+=0.4){
glColor3f(0.7,0.7,0.7);
glVertex3f(-5.0+t2,-0.41,-4.5+t1);
glVertex3f(-4.95+t2,-0.41,-4.5+t1);
}
}
glEnd();
}
void base()
{
float i;
for(i=0.0;i<1.0;i+=0.8) {
glBegin(GL_QUADS);
glColor3f(0.1,0.1,0.1); //front
glVertex3f(-0.5+i,-0.4,0.2);
glVertex3f(-0.3+i,-0.4,0.2);
glVertex3f(-0.3+i,-0.25,0.2);
glVertex3f(-0.5+i,-0.25,0.2);
glColor3f(0.3,0.3,0.3); //left
glVertex3f(-0.5+i,-0.4,0.2);
glVertex3f(-0.5+i,-0.4,-0.2);
glVertex3f(-0.5+i,-0.25,-0.2);
glVertex3f(-0.5+i,-0.25,0.2);
glColor3f(0.1,0.1,0.1); //back
glVertex3f(-0.5+i,-0.4,-0.2);
glVertex3f(-0.3+i,-0.4,-0.2);
glVertex3f(-0.3+i,-0.25,-0.2);
glVertex3f(-0.5+i,-0.25,-0.2);
glColor3f(0.3,0.3,0.3); //right
glVertex3f(-0.3+i,-0.4,0.2);
glVertex3f(-0.3+i,-0.4,-0.2);
glVertex3f(-0.3+i,-0.25,-0.2);
glVertex3f(-0.3+i,-0.25,0.2);
glColor3f(0.5,0.5,0.5); //top
glVertex3f(-0.5+i,-0.25,0.2);
glVertex3f(-0.3+i,-0.25,0.2);
glVertex3f(-0.3+i,-0.25,-0.2);
glVertex3f(-0.5+i,-0.25,-0.2);
glEnd();
}
}
void earth(){
float i;
for(i=0.0;i<4.0;i+=3.5){
glBegin(GL_QUADS);
glColor3f(0.0,0.6,0.0);
glVertex3f(-3.0+i,-0.4,0.17); //front
glVertex3f(-0.5+i,-0.4,0.17);
glVertex3f(-0.5+i,-0.25,0.17);
glVertex3f(-3.0+i,-0.25,0.17);
glVertex3f(-3.0+i,-0.4,-0.17); //back
glVertex3f(-0.5+i,-0.4,-0.17);
glVertex3f(-0.5+i,-0.25,-0.17);
glVertex3f(-3.0+i,-0.25,-0.17);
glColor3f(0.0,0.5,0.0); //top
glVertex3f(-3.0+i,-0.25,0.17);
glVertex3f(-0.5+i,-0.25,0.17);
glVertex3f(-0.5+i,-0.25,-0.17);
glVertex3f(-3.0+i,-0.25,-0.17);
glEnd();
}
}
void pillars(){
glBegin(GL_QUADS);
glColor3f(0.1,0.1,0.5); //front
glVertex3f(-0.35,-0.25,0.2);
glVertex3f(-0.31,-0.25,0.2);
glVertex3f(-0.31,0.2,0.2);
glVertex3f(-0.35,0.2,0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(-0.35,-0.25,0.2);
glVertex3f(-0.35,-0.25,0.15);
glVertex3f(-0.35,0.2,0.15);
glVertex3f(-0.35,0.2,0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(-0.35,-0.25,0.15);
glVertex3f(-0.31,-0.25,0.15);
glVertex3f(-0.31,0.2,0.15);
glVertex3f(-0.35,0.2,0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(-0.31,-0.25,0.2);
glVertex3f(-0.31,-0.25,0.15);
glVertex3f(-0.31,0.2,0.15);
glVertex3f(-0.31,0.2,0.2);
glColor3f(0.1,0.1,0.5); //front
glVertex3f(-0.35,-0.25,-0.2);
glVertex3f(-0.31,-0.25,-0.2);
glVertex3f(-0.31,0.2,-0.2);
glVertex3f(-0.35,0.2,-0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(-0.35,-0.25,-0.2);
glVertex3f(-0.35,-0.25,-0.15);
glVertex3f(-0.35,0.2,-0.15);
glVertex3f(-0.35,0.2,-0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(-0.35,-0.25,-0.15);
glVertex3f(-0.31,-0.25,-0.15);
glVertex3f(-0.31,0.2,-0.15);
glVertex3f(-0.35,0.2,-0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(-0.31,-0.25,-0.2);
glVertex3f(-0.31,-0.25,-0.15);
glVertex3f(-0.31,0.2,-0.15);
glVertex3f(-0.31,0.2,-0.2);
glColor3f(0.2,0.2,0.5);//top
glVertex3f(-0.35,0.2,0.3);
glVertex3f(-0.31,0.2,0.3);
glVertex3f(-0.31,0.25,0.3);
glVertex3f(-0.35,0.25,0.3);
glColor3f(0.3,0.3,0.5);
glVertex3f(-0.35,0.2,0.3);
glVertex3f(-0.35,0.2,-0.3);
glVertex3f(-0.35,0.25,-0.3);
glVertex3f(-0.35,0.25,0.3);
glColor3f(0.2,0.2,0.5);
glVertex3f(-0.35,0.2,-0.3);
glVertex3f(-0.31,0.2,-0.3);
glVertex3f(-0.31,0.25,-0.3);
glVertex3f(-0.35,0.25,-0.3);
glColor3f(0.3,0.3,0.5);
glVertex3f(-0.31,0.2,0.3);
glVertex3f(-0.31,0.2,-0.3);
glVertex3f(-0.31,0.25,-0.3);
glVertex3f(-0.31,0.25,0.3);
glColor3f(0.3,0.3,0.6);
glVertex3f(-0.35,0.25,0.3);
glVertex3f(-0.31,0.25,0.3);
glVertex3f(-0.31,0.25,-0.3);
glVertex3f(-0.35,0.25,-0.3);
//top piller
glColor3f(0.1,0.1,0.5); //front
glVertex3f(-0.35,0.25,0.2);
glVertex3f(-0.31,0.25,0.2);
glVertex3f(-0.31,0.35,0.2);
glVertex3f(-0.35,0.35,0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(-0.35,0.25,0.2);
glVertex3f(-0.35,0.25,0.15);
glVertex3f(-0.35,0.35,0.15);
glVertex3f(-0.35,0.35,0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(-0.35,0.25,0.15);
glVertex3f(-0.31,0.25,0.15);
glVertex3f(-0.31,0.35,0.15);
glVertex3f(-0.35,0.35,0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(-0.31,0.25,0.2);
glVertex3f(-0.31,0.25,0.15);
glVertex3f(-0.31,0.35,0.15);
glVertex3f(-0.31,0.35,0.2);
glColor3f(0.1,0.1,0.5); //front
glVertex3f(-0.35,0.25,-0.2);
glVertex3f(-0.31,0.25,-0.2);
glVertex3f(-0.31,0.35,-0.2);
glVertex3f(-0.35,0.35,-0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(-0.35,0.25,-0.2);
glVertex3f(-0.35,0.25,-0.15);
glVertex3f(-0.35,0.35,-0.15);
glVertex3f(-0.35,0.35,-0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(-0.35,0.25,-0.15);
glVertex3f(-0.31,0.25,-0.15);
glVertex3f(-0.31,0.35,-0.15);
glVertex3f(-0.35,0.35,-0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(-0.31,0.25,-0.2);
glVertex3f(-0.31,0.25,-0.15);
glVertex3f(-0.31,0.35,-0.15);
glVertex3f(-0.31,0.35,-0.2);
glEnd();
//right side
glBegin(GL_QUADS);
glColor3f(0.1,0.1,0.5); //front
glVertex3f(0.35,-0.25,0.2);
glVertex3f(0.31,-0.25,0.2);
glVertex3f(0.31,0.2,0.2);
glVertex3f(0.35,0.2,0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(0.35,-0.25,0.2);
glVertex3f(0.35,-0.25,0.15);
glVertex3f(0.35,0.2,0.15);
glVertex3f(0.35,0.2,0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(0.35,-0.25,0.15);
glVertex3f(0.31,-0.25,0.15);
glVertex3f(0.31,0.2,0.15);
glVertex3f(0.35,0.2,0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(0.31,-0.25,0.2);
glVertex3f(0.31,-0.25,0.15);
glVertex3f(0.31,0.2,0.15);
glVertex3f(0.31,0.2,0.2);
glColor3f(0.1,0.1,0.5); //front
glVertex3f(0.35,-0.25,-0.2);
glVertex3f(0.31,-0.25,-0.2);
glVertex3f(0.31,0.2,-0.2);
glVertex3f(0.35,0.2,-0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(0.35,-0.25,-0.2);
glVertex3f(0.35,-0.25,-0.15);
glVertex3f(0.35,0.2,-0.15);
glVertex3f(0.35,0.2,-0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(0.35,-0.25,-0.15);
glVertex3f(0.31,-0.25,-0.15);
glVertex3f(0.31,0.2,-0.15);
glVertex3f(0.35,0.2,-0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(0.31,-0.25,-0.2);
glVertex3f(0.31,-0.25,-0.15);
glVertex3f(0.31,0.2,-0.15);
glVertex3f(0.31,0.2,-0.2);
glColor3f(0.2,0.2,0.5);//top
glVertex3f(0.35,0.2,0.3);
glVertex3f(0.31,0.2,0.3);
glVertex3f(0.31,0.25,0.3);
glVertex3f(0.35,0.25,0.3);
glColor3f(0.3,0.3,0.5);
glVertex3f(0.35,0.2,0.3);
glVertex3f(0.35,0.2,-0.3);
glVertex3f(0.35,0.25,-0.3);
glVertex3f(0.35,0.25,0.3);
glColor3f(0.2,0.2,0.5);
glVertex3f(0.35,0.2,-0.3);
glVertex3f(0.31,0.2,-0.3);
glVertex3f(0.31,0.25,-0.3);
glVertex3f(0.35,0.25,-0.3);
glColor3f(0.3,0.3,0.5);
glVertex3f(0.31,0.2,0.3);
glVertex3f(0.31,0.2,-0.3);
glVertex3f(0.31,0.25,-0.3);
glVertex3f(0.31,0.25,0.3);
glColor3f(0.3,0.3,0.6);
glVertex3f(0.35,0.25,0.3);
glVertex3f(0.31,0.25,0.3);
glVertex3f(0.31,0.25,-0.3);
glVertex3f(0.35,0.25,-0.3);
//top piller
glColor3f(0.1,0.1,0.5); //front
glVertex3f(0.35,0.25,0.2);
glVertex3f(0.31,0.25,0.2);
glVertex3f(0.31,0.35,0.2);
glVertex3f(0.35,0.35,0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(0.35,0.25,0.2);
glVertex3f(0.35,0.25,0.15);
glVertex3f(0.35,0.35,0.15);
glVertex3f(0.35,0.35,0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(0.35,0.25,0.15);
glVertex3f(0.31,0.25,0.15);
glVertex3f(0.31,0.35,0.15);
glVertex3f(0.35,0.35,0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(0.31,0.25,0.2);
glVertex3f(0.31,0.25,0.15);
glVertex3f(0.31,0.35,0.15);
glVertex3f(0.31,0.35,0.2);
glColor3f(0.1,0.1,0.5); //front
glVertex3f(0.35,0.25,-0.2);
glVertex3f(0.31,0.25,-0.2);
glVertex3f(0.31,0.35,-0.2);
glVertex3f(0.35,0.35,-0.2);
glColor3f(0.1,0.1,0.3); //left
glVertex3f(0.35,0.25,-0.2);
glVertex3f(0.35,0.25,-0.15);
glVertex3f(0.35,0.35,-0.15);
glVertex3f(0.35,0.35,-0.2);
glColor3f(0.1,0.1,0.5); //back
glVertex3f(0.35,0.25,-0.15);
glVertex3f(0.31,0.25,-0.15);
glVertex3f(0.31,0.35,-0.15);
glVertex3f(0.35,0.35,-0.15);
glColor3f(0.1,0.1,0.3); //right
glVertex3f(0.31,0.25,-0.2);
glVertex3f(0.31,0.25,-0.15);
glVertex3f(0.31,0.35,-0.15);
glVertex3f(0.31,0.35,-0.2);
glEnd();
//slops front
glBegin(GL_QUADS);
glColor3f(0.8,0.6,0.5);
glVertex3f(-0.6,-0.25,0.17);
glVertex3f(-0.5,-0.25,0.17);
glVertex3f(-0.35,0.2,0.17);
glVertex3f(-0.35,0.25,0.17);
//BACK
glVertex3f(-0.6,-0.25,-0.17);
glVertex3f(-0.5,-0.25,-0.17);
glVertex3f(-0.35,0.2,-0.17);
glVertex3f(-0.35,0.25,-0.17);
//right front
glVertex3f(0.6,-0.25,0.17);
glVertex3f(0.5,-0.25,0.17);
glVertex3f(0.35,0.2,0.17);
glVertex3f(0.35,0.25,0.17);
//Back
glVertex3f(0.6,-0.25,-0.17);
glVertex3f(0.5,-0.25,-0.17);
glVertex3f(0.35,0.2,-0.17);
glVertex3f(0.35,0.25,-0.17);
glEnd();
}
void bridge(){
glBegin(GL_QUADS);
glColor3f(0.1,0.2,0.3);
glVertex3f(-0.3,-0.25,0.15);
glVertex3f(0.3,-0.25,0.15);
glVertex3f(0.3,-0.23,0.15);
glVertex3f(-0.3,-0.23,0.15);
glColor3f(0.3,0.2,0.3);
glVertex3f(-0.3,-0.25,0.15);
glVertex3f(-0.3,-0.25,-0.15);
glVertex3f(-0.3,-0.23,-0.15);
glVertex3f(-0.3,-0.23,0.15);
glColor3f(0.1,0.2,0.3);
glVertex3f(-0.3,-0.25,-0.15);
glVertex3f(0.3,-0.25,-0.15);
glVertex3f(0.3,-0.23,-0.15);
glVertex3f(-0.3,-0.23,-0.15);
glColor3f(0.3,0.2,0.3);
glVertex3f(0.3,-0.25,0.15);
glVertex3f(0.3,-0.25,-0.15);
glVertex3f(0.3,-0.23,-0.15);
glVertex3f(0.3,-0.23,0.15);
glColor3f(0.3,0.3,0.4);
glVertex3f(-0.3,-0.23,0.15);
glVertex3f(0.3,-0.23,0.15);
glVertex3f(0.3,-0.23,-0.15);
glVertex3f(-0.3,-0.23,-0.15);
glEnd();
//pillers
//left front
glBegin(GL_QUADS);
glColor3f(0.3,0.2,0.1);
glVertex3f(-0.3,-0.23,0.15);
glVertex3f(-0.28,-0.23,0.15);
glVertex3f(-0.28,0.1,0.15);
glVertex3f(-0.3,0.1,0.15);
glColor3f(0.3,0.2,0.3);
glVertex3f(-0.3,-0.23,0.15);
glVertex3f(-0.3,-0.23,0.12);
glVertex3f(-0.3,0.1,0.12);
glVertex3f(-0.3,0.1,0.15);
glColor3f(0.3,0.2,0.1);
glVertex3f(-0.3,-0.23,0.12);
glVertex3f(-0.28,-0.23,0.12);
glVertex3f(-0.28,0.1,0.12);
glVertex3f(-0.3,0.1,0.12);
glColor3f(0.3,0.2,0.3);
glVertex3f(-0.28,-0.23,0.15);
glVertex3f(-0.28,-0.23,0.12);
glVertex3f(-0.28,0.1,0.12);
glVertex3f(-0.28,0.1,0.15);
glEnd();
//right front
glBegin(GL_QUADS);
glColor3f(0.3,0.2,0.1);
glVertex3f(0.3,-0.23,0.15);
glVertex3f(0.28,-0.23,0.15);
glVertex3f(0.28,0.1,0.15);
glVertex3f(0.3,0.1,0.15);
glColor3f(0.3,0.2,0.3);
glVertex3f(0.3,-0.23,0.15);
glVertex3f(0.3,-0.23,0.12);
glVertex3f(0.3,0.1,0.12);
glVertex3f(0.3,0.1,0.15);
glColor3f(0.3,0.2,0.1);
glVertex3f(0.3,-0.23,0.12);
glVertex3f(0.28,-0.23,0.12);
glVertex3f(0.28,0.1,0.12);
glVertex3f(0.3,0.1,0.12);
glColor3f(0.3,0.2,0.3);
glVertex3f(0.28,-0.23,0.15);
glVertex3f(0.28,-0.23,0.12);
glVertex3f(0.28,0.1,0.12);
glVertex3f(0.28,0.1,0.15);
glEnd();
//left back
glBegin(GL_QUADS);
glColor3f(0.3,0.2,0.1);
glVertex3f(-0.3,-0.23,-0.15);
glVertex3f(-0.28,-0.23,-0.15);
glVertex3f(-0.28,0.1,-0.15);
glVertex3f(-0.3,0.1,-0.15);
glColor3f(0.3,0.2,0.3);
glVertex3f(-0.3,-0.23,-0.15);
glVertex3f(-0.3,-0.23,-0.12);
glVertex3f(-0.3,0.1,-0.12);
glVertex3f(-0.3,0.1,-0.15);
glColor3f(0.3,0.2,0.1);
glVertex3f(-0.3,-0.23,-0.12);
glVertex3f(-0.28,-0.23,-0.12);
glVertex3f(-0.28,0.1,-0.12);
glVertex3f(-0.3,0.1,-0.12);
glColor3f(0.3,0.2,0.3);
glVertex3f(-0.28,-0.23,-0.15);
glVertex3f(-0.28,-0.23,-0.12);
glVertex3f(-0.28,0.1,-0.12);
glVertex3f(-0.28,0.1,-0.15);
glEnd();
//right back
glBegin(GL_QUADS);
glColor3f(0.3,0.2,0.1);
glVertex3f(0.3,-0.23,-0.15);
glVertex3f(0.28,-0.23,-0.15);
glVertex3f(0.28,0.1,-0.15);
glVertex3f(0.3,0.1,-0.15);
glColor3f(0.3,0.2,0.3);
glVertex3f(0.3,-0.23,-0.15);
glVertex3f(0.3,-0.23,-0.12);
glVertex3f(0.3,0.1,-0.12);
glVertex3f(0.3,0.1,-0.15);
glColor3f(0.3,0.2,0.1);
glVertex3f(0.3,-0.23,-0.12);
glVertex3f(0.28,-0.23,-0.12);
glVertex3f(0.28,0.1,-0.12);
glVertex3f(0.3,0.1,-0.12);
glColor3f(0.3,0.2,0.3);
glVertex3f(0.28,-0.23,-0.15);
glVertex3f(0.28,-0.23,-0.12);
glVertex3f(0.28,0.1,-0.12);
glVertex3f(0.28,0.1,-0.15);
glEnd();
//top left
glBegin(GL_QUADS);
glColor3f(0.4,0.3,0.2);
glVertex3f(-0.3,0.1,0.15);
glVertex3f(-0.28,0.1,0.15);
glVertex3f(-0.28,0.13,0.15);
glVertex3f(-0.3,0.13,0.15);
glColor3f(0.5,0.3,0.2);
glVertex3f(-0.3,0.1,0.15);
glVertex3f(-0.3,0.1,-0.15);
glVertex3f(-0.3,0.13,-0.15);
glVertex3f(-0.3,0.13,0.15);
glColor3f(0.4,0.3,0.2);
glVertex3f(-0.3,0.1,-0.15);
glVertex3f(-0.28,0.1,-0.15);
glVertex3f(-0.28,0.13,-0.15);
glVertex3f(-0.3,0.13,-0.15);
glColor3f(0.5,0.3,0.2);
glVertex3f(-0.28,0.1,0.15);
glVertex3f(-0.28,0.1,-0.15);
glVertex3f(-0.28,0.13,-0.15);
glVertex3f(-0.28,0.13,0.15);
glEnd();
//top roght
glBegin(GL_QUADS);
glColor3f(0.4,0.3,0.2);
glVertex3f(0.3,0.1,0.15);
glVertex3f(0.28,0.1,0.15);
glVertex3f(0.28,0.13,0.15);
glVertex3f(0.3,0.13,0.15);
glColor3f(0.5,0.3,0.2);
glVertex3f(0.3,0.1,0.15);
glVertex3f(0.3,0.1,-0.15);
glVertex3f(0.3,0.13,-0.15);
glVertex3f(0.3,0.13,0.15);
glColor3f(0.4,0.3,0.2);
glVertex3f(0.3,0.1,-0.15);
glVertex3f(0.28,0.1,-0.15);
glVertex3f(0.28,0.13,-0.15);
glVertex3f(0.3,0.13,-0.15);
glColor3f(0.5,0.3,0.2);
glVertex3f(0.28,0.1,0.15);
glVertex3f(0.28,0.1,-0.15);
glVertex3f(0.28,0.13,-0.15);
glVertex3f(0.28,0.13,0.15);
glEnd();
//sides front
glBegin(GL_QUADS);
glColor3f(0.4,0.3,0.5);
glVertex3f(-0.28,-0.15,0.15);
glVertex3f(0.28,-0.15,0.15);
glVertex3f(0.28,-0.12,0.15);
glVertex3f(-0.28,-0.12,0.15);
glVertex3f(-0.28,-0.15,0.12);
glVertex3f(0.28,-0.15,0.12);
glVertex3f(0.28,-0.12,0.12);
glVertex3f(-0.28,-0.12,0.12);
//back
glVertex3f(-0.28,-0.15,-0.15);
glVertex3f(0.28,-0.15,-0.15);
glVertex3f(0.28,-0.12,-0.15);
glVertex3f(-0.28,-0.12,-0.15);
glVertex3f(-0.28,-0.15,-0.12);
glVertex3f(0.28,-0.15,-0.12);
glVertex3f(0.28,-0.12,-0.12);
glVertex3f(-0.28,-0.12,-0.12);
glEnd();
//top
glBegin(GL_QUADS);
glColor3f(0.4,0.3,0.5);
glVertex3f(-0.28,0.1,0.15);
glVertex3f(0.28,0.1,0.15);
glVertex3f(0.28,0.13,0.15);
glVertex3f(-0.28,0.13,0.15);
glVertex3f(-0.28,0.1,0.12);
glVertex3f(0.28,0.1,0.12);
glVertex3f(0.28,0.13,0.12);
glVertex3f(-0.28,0.13,0.12);
//back
glVertex3f(-0.28,0.1,-0.15);
glVertex3f(0.28,0.1,-0.15);
glVertex3f(0.28,0.13,-0.15);
glVertex3f(-0.28,0.13,-0.15);
glVertex3f(-0.28,0.1,-0.12);
glVertex3f(0.28,0.1,-0.12);
glVertex3f(0.28,0.13,-0.12);
glVertex3f(-0.28,0.13,-0.12);
glEnd();
//house
glColor3f(0.8,0.1,0.1);
glPushMatrix();
glTranslatef(0.0,0.25,0.0);
glutSolidCube(0.25);
glPopMatrix();
glBegin(GL_QUADS); //WINDOW
glColor3f(1.0,1.0,1.0);
glVertex3f(-0.05,0.18,0.16);
glVertex3f(0.05,0.18,0.16);
glVertex3f(0.05,0.25,0.16);
glVertex3f(-0.05,0.25,0.16);
glEnd();
glBegin(GL_TRIANGLES); //ROOF
glColor3f(1.0,0.8,0.0);
glVertex3f(-0.16,0.35,0.16);
glVertex3f(0.16,0.35,0.16);
glVertex3f(0.0,0.5,0.0);
glVertex3f(-0.16,0.35,0.16);
glVertex3f(-0.16,0.35,-0.16);
glVertex3f(0.0,0.5,0.0);
glVertex3f(-0.16,0.35,-0.16);
glVertex3f(0.16,0.35,-0.16);
glVertex3f(0.0,0.5,0.0);
glVertex3f(0.16,0.35,0.16);
glVertex3f(0.16,0.35,-0.16);
glVertex3f(0.0,0.5,0.0);
glEnd();
}
void track(){
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);//left
glVertex3f(-3.0,-0.23,0.12);
glVertex3f(-0.3,-0.23,0.12);
glVertex3f(-3.0,-0.23,0.1);
glVertex3f(-0.3,-0.23,0.1);
glVertex3f(-3.0,-0.23,-0.12);
glVertex3f(-0.3,-0.23,-0.12);
glVertex3f(-3.0,-0.23,-0.1);
glVertex3f(-0.3,-0.23,-0.1);
glVertex3f(3.0,-0.23,0.12);
glVertex3f(0.3,-0.23,0.12);
glVertex3f(3.0,-0.23,0.1);
glVertex3f(0.3,-0.23,0.1);
glVertex3f(3.0,-0.23,-0.12);
glVertex3f(0.3,-0.23,-0.12);
glVertex3f(3.0,-0.23,-0.1);
glVertex3f(0.3,-0.23,-0.1);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
for(j=0.0;j<=2.6;j+=0.1) {
glVertex3f(-3.0+j,-0.23,0.1);
glVertex3f(-3.0+j,-0.23,-0.1);
}
for(j=0.0;j<=3;j+=0.1){
glVertex3f(0.3+j,-0.23,0.1);
glVertex3f(0.3+j,-0.23,-0.1);
}
glEnd();
}
void ship(){
glBegin(GL_QUADS);
glColor3f(0.8,0.8,0.8); //base
glVertex3f(-0.2,-0.4,-3.5);
glVertex3f(0.2,-0.4,-3.5);
glVertex3f(0.2,-0.3,-3.5);
glVertex3f(-0.2,-0.3,-3.5);
glColor3f(0.8,0.8,1.0);
glVertex3f(-0.2,-0.4,-3.5);
glVertex3f(-0.2,-0.4,-4.8);
glVertex3f(-0.2,-0.3,-5.0);
glVertex3f(-0.2,-0.3,-3.5);
glColor3f(0.8,0.8,0.8);
glVertex3f(-0.2,-0.4,-4.8);
glVertex3f(0.2,-0.4,-4.8);
glVertex3f(0.2,-0.3,-5.0);
glVertex3f(-0.2,-0.3,-5.0);
glColor3f(0.8,0.8,1.0);
glVertex3f(0.2,-0.4,-3.5);
glVertex3f(0.2,-0.4,-4.8);
glVertex3f(0.2,-0.3,-5.0);
glVertex3f(0.2,-0.3,-3.5);
glColor3f(1.0,0.8,1.0);
glVertex3f(-0.2,-0.3,-3.5);
glVertex3f(0.2,-0.3,-3.5);
glVertex3f(0.2,-0.3,-5.0);
glVertex3f(-0.2,-0.3,-5.0);
glColor3f(1.0,0.0,0.7);
glVertex3f(-0.18,-0.3,-3.7);
glVertex3f(0.18,-0.3,-3.7);
glVertex3f(0.18,-0.2,-3.7);
glVertex3f(-0.18,-0.2,-3.7);
glColor3f(1.0,0.0,0.5);
glVertex3f(-0.18,-0.3,-3.7);
glVertex3f(-0.18,-0.3,-4.8);
glVertex3f(-0.18,-0.2,-4.8);
glVertex3f(-0.18,-0.2,-3.7);
glColor3f(1.0,0.0,0.7);
glVertex3f(-0.18,-0.3,-3.7);
glVertex3f(0.18,-0.3,-4.8);
glVertex3f(0.18,-0.2,-4.8);
glVertex3f(-0.18,-0.2,-3.7);
glColor3f(1.0,0.0,0.5);
glVertex3f(0.18,-0.3,-3.7);
glVertex3f(0.18,-0.3,-4.8);
glVertex3f(0.18,-0.2,-4.8);
glVertex3f(0.18,-0.2,-3.7);
glColor3f(1.0,0.1,0.8);
glVertex3f(-0.18,-0.2,-3.7);
glVertex3f(0.18,-0.2,-3.7);
glVertex3f(0.18,-0.2,-4.8);
glVertex3f(-0.18,-0.2,-4.8);
glEnd();
//front
glBegin(GL_TRIANGLES);
glColor3f(0.5,0.5,0.7);
glVertex3f(-0.2,-0.4,-3.5);
glVertex3f(-0.2,-0.3,-3.5);
glVertex3f(0.0,-0.15,-2.2);
glColor3f(0.5,0.8,0.7);
glVertex3f(-0.2,-0.4,-3.5);
glVertex3f(0.2,-0.4,-3.5);
glVertex3f(0.0,-0.15,-2.2);
glColor3f(0.5,0.5,0.7);
glVertex3f(0.2,-0.4,-3.5);
glVertex3f(0.2,-0.3,-3.5);
glVertex3f(0.0,-0.15,-2.2);
glEnd();
//TOP PILLARS
glBegin(GL_QUADS);
glColor3f(1.0,0.8,0.1);
glVertex3f(-0.05,-0.2,-3.8);
glVertex3f(0.05,-0.2,-3.8);
glVertex3f(0.05,0.1,-3.8);
glVertex3f(-0.05,0.1,-3.8);
glColor3f(1.0,0.8,0.2);
glVertex3f(-0.05,-0.2,-3.8);
glVertex3f(-0.05,-0.2,-4.0);
glVertex3f(-0.05,0.1,-4.0);
glVertex3f(-0.05,0.1,-3.8);
glColor3f(1.0,0.8,0.1);
glVertex3f(-0.05,-0.2,-4.0);
glVertex3f(0.05,-0.2,-4.0);
glVertex3f(0.05,0.1,-4.0);
glVertex3f(-0.05,0.1,-4.0);
glColor3f(1.0,0.8,0.2);
glVertex3f(0.05,-0.2,-3.8);
glVertex3f(0.05,-0.2,-4.0);
glVertex3f(0.05,0.1,-4.0);
glVertex3f(0.05,0.1,-3.8);
//back
glColor3f(1.0,0.5,0.1);
glVertex3f(-0.05,-0.2,-4.2);
glVertex3f(0.05,-0.2,-4.2);
glVertex3f(0.05,0.2,-4.2);
glVertex3f(-0.05,0.2,-4.2);
glColor3f(1.0,0.6,0.2);
glVertex3f(-0.05,-0.2,-4.2);
glVertex3f(-0.05,-0.2,-4.5);
glVertex3f(-0.05,0.2,-4.5);
glVertex3f(-0.05,0.2,-4.2);
glColor3f(1.0,0.5,0.1);
glVertex3f(-0.05,-0.2,-4.5);
glVertex3f(0.05,-0.2,-4.5);
glVertex3f(0.05,0.2,-4.5);
glVertex3f(-0.05,0.2,-4.5);
glColor3f(1.0,0.6,0.2);
glVertex3f(0.05,-0.2,-4.2);
glVertex3f(0.05,-0.2,-4.5);
glVertex3f(0.05,0.2,-4.5);
glVertex3f(0.05,0.2,-4.2);
glEnd();
}
void train(){
glBegin(GL_QUADS); //engine
glColor3f(0.8,0.6,0.4);
glVertex3f(1.0,-0.23,0.1);
glVertex3f(1.15,-0.23,0.1);
glVertex3f(1.15,-0.14,0.1);
glVertex3f(1.0,-0.14,0.1);
glColor3f(0.5,0.5,0.8);
glVertex3f(1.0,-0.23,0.1);
glVertex3f(1.0,-0.23,-0.1);
glVertex3f(1.0,-0.14,-0.1);
glVertex3f(1.0,-0.14,0.1);
glColor3f(0.8,0.6,0.4);
glVertex3f(1.0,-0.23,-0.1);
glVertex3f(1.15,-0.23,-0.1);
glVertex3f(1.15,-0.14,-0.1);
glVertex3f(1.0,-0.14,-0.1);
//FRONT
glColor3f(0.0,0.1,0.9);
glVertex3f(1.0,-0.14,0.1);
glVertex3f(1.15,-0.05,0.1);
glVertex3f(1.15,-0.05,-0.1);
glVertex3f(1.0,-0.14,-0.1);
glColor3f(0.8,0.6,0.2);
glVertex3f(1.02,-0.12,0.1);
glVertex3f(1.13,-0.05,0.1);
glVertex3f(1.13,-0.05,-0.06);
glVertex3f(1.02,-0.12,-0.06);
glEnd();
//side
glBegin(GL_TRIANGLES);
glColor3f(0.0,0.0,0.0);
glVertex3f(1.0,-0.14,0.1);
glVertex3f(1.15,-0.14,0.1);
glVertex3f(1.15,-0.05,0.1);
glVertex3f(1.0,-0.14,-0.1);
glVertex3f(1.15,-0.14,-0.1);
glVertex3f(1.15,-0.05,-0.1);
glEnd();
//bogies
glBegin(GL_QUADS);
for(j=0.0;j<2;j+=0.27){
glColor3f(0.5,0.0,0.1);
glVertex3f(1.15+j,-0.23,0.1);
glVertex3f(1.4+j,-0.23,0.1);
glVertex3f(1.4+j,-0.05,0.1);
glVertex3f(1.15+j,-0.05,0.1);
glColor3f(0.5,0.0,0.5);
glVertex3f(1.15+j,-0.23,0.1);
glVertex3f(1.15+j,-0.23,-0.1);
glVertex3f(1.15+j,-0.05,-0.1);
glVertex3f(1.15+j,-0.05,0.1);
glColor3f(0.5,0.0,0.1);
glVertex3f(1.15+j,-0.23,-0.1);
glVertex3f(1.4+j,-0.23,-0.1);
glVertex3f(1.4+j,-0.05,-0.1);
glVertex3f(1.15+j,-0.05,-0.1);
glColor3f(0.5,0.0,0.5);
glVertex3f(1.4+j,-0.23,0.1);
glVertex3f(1.4+j,-0.23,-0.1);
glVertex3f(1.4+j,-0.05,-0.1);
glVertex3f(1.4+j,-0.05,0.1);
glColor3f(0.8,0.3,0.5);
glVertex3f(1.15+j,-0.05,0.1);
glVertex3f(1.4+j,-0.05,0.1);
glVertex3f(1.4+j,-0.05,-0.1);
glVertex3f(1.15+j,-0.05,-0.1);
}
glEnd();
}
void aero(){
glBegin(GL_POLYGON);
glColor3f(0.9,0.9,.9);
glVertex3f(-3.2,0.7,-0.8);
glVertex3f(-3.0,0.67,-0.8);
glVertex3f(-2.4,0.67,-0.8);
glVertex3f(-2.4,0.73,-0.8);
glVertex3f(-3.2,0.73,-0.8);
glVertex3f(-3.2,0.7,-0.65);
glVertex3f(-3.0,0.67,-0.65);
glVertex3f(-2.4,0.67,-0.65);
glVertex3f(-2.4,0.73,-0.65);
glVertex3f(-3.2,0.73,-0.65);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.7,0.7,.7);
glVertex3f(-3.2,0.7,-0.65);
glVertex3f(-3.2,0.7,-0.8);
glVertex3f(-3.2,0.73,-0.8);
glVertex3f(-3.2,0.73,-0.65);
glColor3f(0.7,0.7,.7);
glVertex3f(-2.4,0.67,-0.65);
glVertex3f(-2.4,0.67,-0.8);
glVertex3f(-2.4,0.73,-0.8);
glVertex3f(-2.4,0.73,-0.65);
glColor3f(0.7,0.8,0.8);
glVertex3f(-3.2,0.73,-0.65);
glVertex3f(-2.4,0.73,-0.65);
glVertex3f(-2.4,0.73,-0.8);
glVertex3f(-3.2,0.73,-0.8);
//wings
glColor3f(0.8,0.2,0.5);
glVertex3f(-2.8,0.7,-0.7);
glVertex3f(-2.62,0.7,-0.7);
glVertex3f(-2.75,0.7,-0.2);
glVertex3f(-2.85,0.7,-0.2);
glVertex3f(-2.8,0.7,-0.8);
glVertex3f(-2.62,0.7,-0.8);
glVertex3f(-2.75,0.7,-1.3);
glVertex3f(-2.85,0.7,-1.3);
glVertex3f(-3.2,0.73,-0.725);
glVertex3f(-3.1,0.73,-0.725);
glVertex3f(-3.18,0.82,-0.725);
glVertex3f(-3.25,0.82,-0.725);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(1.0,0.5,0.2);
glVertex3f(-2.4,0.73,-0.8);
glVertex3f(-2.4,0.73,-0.65);
glVertex3f(-2.2,0.68,-0.725);
glColor3f(1.0,0.7,0.4);
glVertex3f(-2.4,0.67,-0.65);
glVertex3f(-2.4,0.73,-0.65);
glVertex3f(-2.2,0.68,-0.725);
glColor3f(1.0,0.5,0.2);
glVertex3f(-2.4,0.68,-0.65);
glVertex3f(-2.4,0.68,-0.65);
glVertex3f(-2.2,0.68,-0.725);
glColor3f(1.0,0.7,0.4);
glVertex3f(-2.4,0.69,-0.8);
glVertex3f(-2.4,0.73,-0.8);
glVertex3f(-2.2,0.68,-0.725);
glEnd();
char str[]=" AIR CIT . . .";
setFont(GLUT_BITMAP_HELVETICA_18);
glColor3f(0.0,0.0,0.0);
drawstring(str,-3.05,0.69,-0.65);
}
void lighthouse(){
glBegin(GL_QUADS);
glColor3f(0.8,0.2,0.0);
glVertex3f(0.2,-0.42,-5.01);
glVertex3f(0.35,-0.42,-5.01);
glVertex3f(0.3,-0.1,-5.01);
glVertex3f(0.25,-0.1,-5.01);
glColor3f(1.0,1.0,1.0);
glVertex3f(0.23,-0.1,-5.01);
glVertex3f(0.32,-0.1,-5.01);
glVertex3f(0.32,0.0,-5.01);
glVertex3f(0.23,0.0,-5.01);
glColor3f(1.0,1.0,1.0);
glVertex3f(0.215,-0.3,-5.0);
glVertex3f(0.33,-0.3,-5.0);
glVertex3f(0.315,-0.2,-5.0);
glVertex3f(0.23,-0.2,-5.0);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(1.0,0.2,0.2);
glVertex3f(0.2,0.0,-5.0);
glVertex3f(0.35,0.0,-5.0);
glVertex3f(0.27,0.05,-5.0);
glEnd();
}
void signal(){
glBegin(GL_QUADS);
glColor3f(0.1,0.2,0.1);
glVertex3f(0.7,-0.25,-0.17);
glVertex3f(0.73,-0.25,-0.17);
glVertex3f(0.73,0.15,-0.17);
glVertex3f(0.7,0.15,-0.17);
glColor3f(0.1,0.1,0.2);
glVertex3f(0.67,0.15,-0.17);
glVertex3f(0.76,0.15,-0.17);
glVertex3f(0.76,0.3,-0.17);
glVertex3f(0.67,0.3,-0.17);
glEnd();
}
void light(){
if(b>0.0)
glColor3f(1.0,0.0,0.0);
else
glColor3f(0.0,1.0,0.0);
if(p<-3.5)
glColor3f(1.0,0.0,0.0);
glPushMatrix();
glTranslatef(0.715,0.25,-0.17);
glutSolidSphere(0.03,10,10);
glPopMatrix();
}
void new1(){
glTranslatef(a,b,c);
bridge();
}
void new2(){
glTranslatef(m,n,o);
ship();
}
void new3(){
glTranslatef(p,q,r);
train();
}
void new4(){
glTranslatef(x,y,z);
aero();
}
void new5(){
glTranslatef(a1,a2,a3);
lines();
}
if(flagt==1){
p-=0.05f;
}
if(flagp==1){
x+=0.035;
}
if(flagw==1){
a1+=0.006;
}
}
glutPostRedisplay();
glutTimerFunc(100,update,0);
}
void display(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0,0.5,1.0,0.0);
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
base();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
pillars();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
earth();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
track();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
new1();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
new2();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
new3();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
new4();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
water();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
new5();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,0.0);
glTranslatef(1.2,0.9,-5.1);
glutSolidSphere(0.08,20,20);
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
lighthouse();
glTranslatef(0.28,-0.05,-5.0);
glColor3f(0.0,0.0,0.0);
glutSolidSphere(0.02,20,20);
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
signal();
glPopMatrix();
glPushMatrix();
glRotatef(20.0,0.25,0.5,0.0);
light();
glPopMatrix();
glFlush();
}
void mydisplay(){
if(flag==0)
screen1();
if(flag==1)
display();
if(p<-6.0)
screen3();
if(p<-6.8)
exit(0);
}
void mykeyboard(unsigned char key,int x,int y){
switch(key){
case 13 :flag=1;break;
case 83 :if(flag==1)
flagx=1;break;
case 115:if(flag==1)
flagx=1;break;
case 84 :flagx=0;break;
case 116 :flagx=0;break;
case 27:exit(0);
}
}
void reshape(int w,int h){
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-1.1,1.1,1.1*(GLfloat)h/(GLfloat)w,1.1*(GLfloat)h/(GLfloat)w,-10.0,10.0);
else
glOrtho(-1.1*(GLfloat)w/(GLfloat)h,1.1*(GLfloat)w/(GLfloat)h,-1.1,1.1,-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc,char **argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(1500,1000);
glutCreateWindow("VLBS");
glClearColor(0.0,0.0,0.0,0.0);
glEnable(GL_DEPTH_TEST);
glutReshapeFunc(reshape);
glutDisplayFunc(mydisplay);
glutKeyboardFunc(mykeyboard);
glutTimerFunc(200,update,0);
glutMainLoop();
return 0;
}
CHAPTER 4
SNAPSHOTS
WELCOME SCREEN
EXIT SCREEN
CHAPTER 5
5.1 CONCLUSION
The development of the mini project has given us a good exposure to openGL by which
we have learnt some of the techniques which help in the development of interactive application
This application is like open source where anyone can design and add his own codes to
REFERENCES
TEXT BOOKS:
WEBSITE:
[1]. www.OpenGL.org
[2]. www.Github.com
[3]. www.stackoverflow.com
[4]. www.youtube.com
[5]. www.openglprojects.in