Cgreportmi
Cgreportmi
Cgreportmi
INTRODUCTION
Computer Graphics is concerned with all aspect of producing pictures or image using
computer. The field began humble almost 50 years ago, with the display of few lines on the
cathode-ray tube (CRT); now, we can create image using computer that are indistinguishable
from photographs from the real objects. We routinely train pilots with simulated airplane,
generating graphical display of the virtual environment in the real time. Feature length movies
made entirely by computer have been successful, both critically and financially; massive
multiplayer game can involve tens of thousands of concurrent participants.
Graphics is created using computers and, more generally, the representation and manipulation
of pictorial 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 had a profound impact on many types of media and
have revolutionized the animation and video game industry. The phrase “Computer Graphics”
was coined in 1960 by William Fetter, a graphic designer for Boeing. In today’s world
advanced technology, interactive computer graphics has become a powerful tool for the
production of realistic features. Today’s we find computer graphics used in various areas that
include science, engineering, medicine, business, industry, art, entertainment etc. The main
reason for effectiveness of the interactive computer graphics is the speed with which the user
can understand the displayed information.
The graphics in OpenGL provides a wide variety of built-in function. The computer graphics
remains one of the most exciting and rapidly growing computer fields. It has become a common
element in user interface, data visualization, TV commercials, motion picture and many other
applications. The current trend of computer graphics is to incorporate more physics principles
into 3D graphics algorithm to better simulate the complex interactions between objects and
lighting environment.
1
1.2 OPEN-GL: HISTORY
OpenGL was developed by ‘Silicon Graphics Inc ‘(SGI) on 1992 and is popular in the gaming
industry where it competes with the Direct3D in the Microsoft Windows platform. OpenGL is
broadly used in CAD (Computer Aided Design), virtual reality, scientific visualization,
information visualization, flight simulation and video games development.
1. Main GL: Library has names that begin with the letter gl and are stored in a library
usually referred to as GL.
2. OpenGL Utility Library (GLU): This library uses only GL functions but contains code
for creating common objects and simplifying viewing.
3. OpenGL Utility Toolkit (GLUT): This provides the minimum functionality that should
be accepted in any modern windowing system.
CHARACTERISTICS
2
CHAPTER 2
REQUIREMENT ANALYSIS
i. Hardware Requirements:
• Processor- Intel or AMD (Advanced Micro Devices)
• RAM- 1 GB (minimum)
• Hard Disk- 40MB (minimum) Graphics Memory- 128MB
OpenGL APIs: If we want to have a control on the flow of program and if we want to interact
with the window system then we use OpenGL API’S. Vertices are represented in the same
manner internally, whether they are specified as two-dimensional or three-dimensional entities,
everything that we do are here will be equally valid in three dimensions. Although OpenGL is
easy to learn, compared with other APIs, it is nevertheless powerful. It supports the simple
three-dimensional programs and also supports the advanced rendering techniques.
GL/glut.h: We use a readily available library called the OpenGL Utility Toolkit (GLUT),
which provides the minimum functionality that should be expected in any modern windowing
system. The application program uses only GLUT functions and can be recompiled with the
GLUT library for other window system. OpenGL makes a heavy use of macros to increase
code readability and avoid the use of magic numbers. In most implementation, one of the
include lines.
3
CHAPTER 3
IMPLEMENTATION
3.1 FUNCTIONS IN OPEN-GL
• void glClear(glEnum mode); Clears the buffers namely color buffer and depth buffer.
mode refers to GL_COLOR_BUFFER_BIT or DEPTH_BUFFER_BIT.
• void glPushMatrix(); void glPopMatrix(); Pushes to and pops from the matrix stack
corresponding to the current matrix mode.
• void glutInit(int *argc, char **argv); Initializes GLUT; the arguments from main are
passed in and can be used by the application.
4
• void glutInitDisplayMode(unsigned int mode); Requests a display with the
properties in the mode; the value of mode is determined by the logical OR of options
including the color model (GLUT_RGB, GLUT_INDEX) and buffering
(GLUT_SINGLE, GLUT_DOUBLE).
• void glutCreateWindow(char *title); Creates a window on display; the string title can
be used to label the window. The return value provides a reference to the window that
can be used when there are multiple windows.
• void glutMouseFunc(void *f(int button, int state, int x, int y) Registers the mouse
callback function f. The callback function returns the button
(GLUT_LEFT_BUTTON,etc., the state of the button after the event (GLUT_DOWN),
and the position of the mouse relative to the top-left corner of the window.
• void glutKeyboardFunc(void *f(char key, int width, int height)) Registers the
keyboard callback function f. The callback function returns the ASCII code of the key
pressed and the position of the mouse.
• void glutInitWindowSize(int width, int height); Specifies the initial height and width
of the window in pixels.
• void glutReshapeFunc(void *f(int width, int height)); Registers the reshape callback
function f. the callback function returns the height and width of the new window. The
reshape callback invokes the display callback.
• void createMenu(void); This function is used to create menus which are used as
options in program.
5
CHAPTER 4
TESTING
4.1 TESTING PROCESS
Testing process started with the testing of individual program units such as
functions or objects. These were then integrated into sub-systems and systems,
and interactions of these units were tested. Testing involves verification and
validation.
With the verification and validation process, there are two complementary
approaches to the system checking and analysis:
6
4.2 SOURCE CODE
#include<windows.h>
#include<stdio.h>
#include <stdlib.h>
#include<gl/glut.h>
#include <iostream>
float m = 0.0;
int i=0;
int boat=0;
int l;
int t=0;
int z=1;
int b=0;
int megh=1;
double front=600;
double back=690;
int c_w=615;
double carfront=630;
double carback=670;
double fronttraingle=550;
double front2=600;
double back2=690;
7
int day=1;
int tree;
int bus=1;
glBegin(GL_POINTS);
glVertex2i(cx, cy);
glEnd();
draw_pixel(x + h, y + k);
draw_pixel(-x + h, y + k);
draw_pixel(x + h, -y + k);
draw_pixel(-x + h, -y + k);
draw_pixel(y + h, x + k);
draw_pixel(-y + h, x + k);
draw_pixel(y + h, -x + k);
draw_pixel(-y + h, -x + k);
GLint d = 1 - r, x = 0, y = r;
while (y>x)
8
plotpixels(h, k, x, y);
if (d<0) d += 2 * x + 3;
else
d += 2 * (x - y) + 5;
--y;
++x;
plotpixels(h, k, x, y);
}
void draw_object()
int l;
if (day == 1)
{
glColor3f(.2,.6,.8);
glBegin(GL_POLYGON);
glVertex2f(0, 450);
glVertex2f(0, 700);
glVertex2f(1100, 700);
glVertex2f(1100, 450);
glEnd();
if(m<300)
9
{
10
draw_circle(470 + m, 615, l);
if(megh==1)
m++;
}
else
m=0;
11
for (l = 0; l <= 20; l++)
glEnd();
if(megh==1)
{ m++;
12
}
draw_circle(700,600 , l);
13
draw_circle(380 , 280, l);
glBegin(GL_POLYGON);
glVertex2f(0, 100);
glVertex2f(0, 450);
glVertex2f(1100, 450);
glVertex2f(1100, 100);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1100, 0);
glVertex2f(0, 0);
glVertex2f(0, 160);
glVertex2f(1100, 160);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(0, 0);
glVertex2f(0, 200);
glVertex2f(200, 160);
glVertex2f(0, 100);
14
glEnd();
if(boat<500)
glBegin(GL_POLYGON);
glVertex2f(647-boat, 66);
glVertex2f(811-boat, 66);
glVertex2f(830-boat, 102);
glVertex2f(588-boat, 102);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(815-boat, 102);
glVertex2f(815-boat, 114);
glVertex2f(772-boat, 114);
glVertex2f(772-boat, 102);
glEnd();
15
if(b==0)
boat=boat+3;
else
boat=0;
glBegin(GL_POLYGON);
glVertex2f(647-boat, 66);
glVertex2f(811-boat, 66);
glVertex2f(830-boat, 102);
glVertex2f(588-boat, 102);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(815-boat, 102);
glVertex2f(815-boat, 114);
glVertex2f(772-boat, 114);
glVertex2f(772-boat, 102);
glEnd();
boat=boat+8;
16
glColor3f(0.2, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(387, 199);
glVertex2f(387, 300);
glVertex2f(410, 300);
glVertex2f(411, 200);
glEnd();
glBegin(GL_QUADS);
glVertex2f(336, 285);
glVertex2f(362, 313);
glVertex2f(443, 313);
glVertex2f(466, 285);
glEnd();
glBegin(GL_QUADS);
glVertex2f(342, 313);
glVertex2f(363, 340);
glVertex2f(438, 340);
glVertex2f(458, 313);
glEnd();
glBegin(GL_TRIANGLES);
17
glVertex2f(351, 340);
glVertex2f(400, 410);
glVertex2f(448, 340);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(780, 360);
glVertex2f(776, 400);
glVertex2f(855, 390);
glVertex2f(860, 340);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(220, 199);
glVertex2f(220, 300);
glVertex2f(243, 300);
glVertex2f(243, 200);
glEnd();
glBegin(GL_QUADS);
glVertex2f(169, 285);
glVertex2f(195, 313);
glVertex2f(276, 313);
glVertex2f(299, 285);
18
glEnd();
glBegin(GL_QUADS);
glVertex2f(175, 313);
glVertex2f(196, 340);
glVertex2f(271, 340);
glVertex2f(291, 313);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(184, 340);
glVertex2f(233, 410);
glVertex2f(281, 340);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(780, 360);
glVertex2f(776, 400);
glVertex2f(855, 390);
glVertex2f(860, 340);
glEnd();
19
glColor3f(1.0, 1.0, .2);
glBegin(GL_POLYGON);
glVertex2f(767, 400);
glVertex2f(781, 435);
glVertex2f(874, 435);
glVertex2f(852, 384);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(860, 340);
glVertex2f(855, 390);
glVertex2f(874, 435);
glVertex2f(896, 404);
glVertex2f(896, 350);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(788, 370);
glVertex2f(787, 380);
glVertex2f(798, 379);
glVertex2f(798, 370);
glEnd();
20
glColor3f(1.0, 0.0, .2);
glBegin(GL_POLYGON);
glVertex2f(808, 352);
glVertex2f(807, 380);
glVertex2f(820, 378);
glVertex2f(817, 352);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(834, 365);
glVertex2f(833, 375);
glVertex2f(844, 374);
glVertex2f(844, 365);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(873, 370);
glVertex2f(873, 383);
glVertex2f(887, 386);
glVertex2f(887, 372);
glEnd();
glutPostRedisplay();
21
if(fronttraingle >360)
draw_circle(carfront,190 , l);
draw_circle(carback,190 , l);
glBegin(GL_TRIANGLES);
glVertex2f(front, 190);
glVertex2f(fronttraingle, 190);
glVertex2f(front, 200);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(back, 190);
glVertex2f(front, 190);
glVertex2f(front, 240);
glVertex2f(back, 240);
glEnd();
22
if(z==1)
front=front-1;
back=back-1;
carfront=carfront-1;
carback=carback-1;
fronttraingle=fronttraingle-1;
else
glColor3f(.2,.6,.8);
glBegin(GL_POLYGON);
glVertex2f(0, 450);
glVertex2f(0, 700);
glVertex2f(1100, 700);
glVertex2f(1100, 450);
glEnd();
23
if(m<300)
24
}
if(megh==1)
m++;
else
m=0;
25
}
26
}
if(megh==1)
m++;
27
{
glBegin(GL_POLYGON);
glVertex2f(0, 100);
glVertex2f(0, 450);
glVertex2f(1100, 450);
glVertex2f(1100, 100);
glEnd();
if(fronttraingle>=500)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
28
glVertex2f(830,400 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1100, 0);
glVertex2f(0, 0);
glVertex2f(0, 160);
glVertex2f(1100, 160);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(0, 0);
glVertex2f(0, 200);
glVertex2f(200, 160);
glVertex2f(0, 100);
glEnd();
if(boat<450)
29
{
glBegin(GL_POLYGON);
glVertex2f(647-boat, 66);
glVertex2f(811-boat, 66);
glVertex2f(830-boat, 102);
glVertex2f(588-boat, 102);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(815-boat, 102);
glVertex2f(815-boat, 114);
glVertex2f(772-boat, 114);
glVertex2f(772-boat, 102);
glEnd();
boat=boat+5;
else
boat=0;
glBegin(GL_POLYGON);
glVertex2f(647-boat, 66);
30
glVertex2f(811-boat, 66);
glVertex2f(830-boat, 102);
glVertex2f(588-boat, 102);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(815-boat, 102);
glVertex2f(815-boat, 114);
glVertex2f(772-boat, 114);
glVertex2f(772-boat, 102);
glEnd();
boat=boat+5;
glBegin(GL_POLYGON);
glVertex2f(220, 199);
glVertex2f(220, 300);
glVertex2f(243, 300);
glVertex2f(243, 200);
glEnd();
glBegin(GL_QUADS);
glVertex2f(169, 285);
glVertex2f(195, 313);
31
glVertex2f(276, 313);
glVertex2f(299, 285);
glEnd();
glBegin(GL_QUADS);
glVertex2f(175, 313);
glVertex2f(196, 340);
glVertex2f(271, 340);
glVertex2f(291, 313);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(184, 340);
glVertex2f(233, 410);
glVertex2f(281, 340);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(780, 360);
glVertex2f(776, 400);
glVertex2f(855, 390);
glVertex2f(860, 340);
glEnd();
32
glColor3f(1.0, 1.0, .2);
glBegin(GL_POLYGON);
glVertex2f(767, 400);
glVertex2f(781, 435);
glVertex2f(874, 435);
glVertex2f(852, 384);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(860, 340);
glVertex2f(855, 390);
glVertex2f(874, 435);
glVertex2f(896, 404);
glVertex2f(896, 350);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(788, 370);
glVertex2f(787, 380);
glVertex2f(798, 379);
glVertex2f(798, 370);
glEnd();
33
glBegin(GL_POLYGON);
glVertex2f(808, 352);
glVertex2f(807, 380);
glVertex2f(820, 378);
glVertex2f(817, 352);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(834, 365);
glVertex2f(833, 375);
glVertex2f(844, 374);
glVertex2f(844, 365);
glEnd();
if(fronttraingle>=350)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
fronttraingle--;
34
else if(fronttraingle>=340)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
fronttraingle--;
35
else if(fronttraingle>=330)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
glLineWidth(3.5);
36
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
fronttraingle--;
else if(fronttraingle>=320)
37
glColor3f(.5, .25, .12);
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
38
glVertex2f(690, 530);
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
fronttraingle--;
}
else if(fronttraingle>=310)
glBegin(GL_POLYGON);
39
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
40
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);//ok
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
glBegin(GL_POLYGON);
41
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,290 );
glVertex2f(680,290 );
42
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
fronttraingle--;
else if(fronttraingle>=280)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
43
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);
glVertex2f(700, 448);
glVertex2f(670, 500);
44
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
45
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
fronttraingle--;
46
}
else if(fronttraingle>=270)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
47
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);//ok
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
48
glVertex2f(670,525);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
49
}
glBegin(GL_POLYGON);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,330 );
glVertex2f(680,330 );
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
50
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,330 );
glVertex2f(680,330 );
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,370 );
glVertex2f(680,370 );
glVertex2f(680,390 );
glVertex2f(650,390 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,370 );
glVertex2f(680,370 );
glVertex2f(680,390 );
glVertex2f(650,390 );
51
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
glVertex2f(610,290 );
glEnd();
52
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
glVertex2f(610,290 );
glEnd();
fronttraingle--;
else if(fronttraingle>=250)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
53
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
54
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
55
{
glBegin(GL_POLYGON);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,330 );
glVertex2f(680,330 );
56
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,330 );
glVertex2f(680,330 );
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,370 );
glVertex2f(680,370 );
glVertex2f(680,390 );
glVertex2f(650,390 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,370 );
glVertex2f(680,370 );
57
glVertex2f(680,390 );
glVertex2f(650,390 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
58
glVertex2f(610,290 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
glVertex2f(610,290 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,310 );
glVertex2f(580,310 );
glVertex2f(580,330 );
glVertex2f(610,330 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,310 );
glVertex2f(580,310 );
glVertex2f(580,330 );
59
glVertex2f(610,330 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,350 );
glVertex2f(580,350 );
glVertex2f(580,370 );
glVertex2f(610,370 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,350 );
glVertex2f(580,350 );
glVertex2f(580,370 );
glVertex2f(610,370 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,230 );
glVertex2f(730,230 );
glVertex2f(730,250 );
glVertex2f(760,250 );
glEnd();
60
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,230 );
glVertex2f(730,230 );
glVertex2f(730,250 );
glVertex2f(760,250 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,270);
glVertex2f(730,270);
glVertex2f(730,290);
glVertex2f(760,290);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,270);
glVertex2f(730,270);
glVertex2f(730,290);
glVertex2f(760,290);
glEnd();
61
glBegin(GL_POLYGON);
glVertex2f(760,310);
glVertex2f(730,310);
glVertex2f(730,330);
glVertex2f(760,330);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,310);
glVertex2f(730,310);
glVertex2f(730,330);
glVertex2f(760,330);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,350);
glVertex2f(730,350);
glVertex2f(730,370);
glVertex2f(760,370);
glEnd();
glLineWidth(2);
62
glBegin(GL_LINE_LOOP);
glVertex2f(760,350);
glVertex2f(730,350);
glVertex2f(730,370);
glVertex2f(760,370);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(873, 370);
glVertex2f(873, 383);
glVertex2f(887, 386);
glVertex2f(887, 372);
glEnd();
fronttraingle--;
else if(fronttraingle>=191)
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
63
glColor3f(.1, .1, .1);
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
64
glVertex2f(700, 448);//ok
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
65
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glLineWidth(2);
66
glColor3f(.1, .1, .1);
glBegin(GL_LINE_LOOP);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,330 );
glVertex2f(680,330 );
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,330 );
glVertex2f(680,330 );
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
67
glBegin(GL_POLYGON);
glVertex2f(650,370 );
glVertex2f(680,370 );
glVertex2f(680,390 );
glVertex2f(650,390 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,370 );
glVertex2f(680,370 );
glVertex2f(680,390 );
glVertex2f(650,390 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glLineWidth(2);
68
glColor3f(.1, .1, .1);
glBegin(GL_LINE_LOOP);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
glVertex2f(610,290 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
glVertex2f(610,290 );
glEnd();
69
glBegin(GL_POLYGON);
glVertex2f(610,310 );
glVertex2f(580,310 );
glVertex2f(580,330 );
glVertex2f(610,330 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,310 );
glVertex2f(580,310 );
glVertex2f(580,330 );
glVertex2f(610,330 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,350 );
glVertex2f(580,350 );
glVertex2f(580,370 );
glVertex2f(610,370 );
glEnd();
glLineWidth(2);
70
glColor3f(.1, .1, .1);
glBegin(GL_LINE_LOOP);
glVertex2f(610,350 );
glVertex2f(580,350 );
glVertex2f(580,370 );
glVertex2f(610,370 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,230 );
glVertex2f(730,230 );
glVertex2f(730,250 );
glVertex2f(760,250 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,230 );
glVertex2f(730,230 );
glVertex2f(730,250 );
glVertex2f(760,250 );
glEnd();
glBegin(GL_POLYGON);
71
glVertex2f(760,270);
glVertex2f(730,270);
glVertex2f(730,290);
glVertex2f(760,290);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,270);
glVertex2f(730,270);
glVertex2f(730,290);
glVertex2f(760,290);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,310);
glVertex2f(730,310);
glVertex2f(730,330);
glVertex2f(760,330);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
72
glVertex2f(760,310);
glVertex2f(730,310);
glVertex2f(730,330);
glVertex2f(760,330);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,350);
glVertex2f(730,350);
glVertex2f(730,370);
glVertex2f(760,370);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,350);
glVertex2f(730,350);
glVertex2f(730,370);
glVertex2f(760,370);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(873, 370);
glVertex2f(873, 383);
73
glVertex2f(887, 386);
glVertex2f(887, 372);
glEnd();
fronttraingle--;
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
74
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
draw_circle(carfront,190 , l);
draw_circle(carback,190 , l);
if(fronttraingle >191)
draw_circle(carfront,190 , l);
75
}
draw_circle(carback,190 , l);
glBegin(GL_TRIANGLES);
glVertex2f(front, 190);
glVertex2f(fronttraingle, 190);
glVertex2f(front, 200);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(back, 190);
glVertex2f(front, 190);
glVertex2f(front, 240);
glVertex2f(back, 240);
front=front-4;
back=back-4;
carfront=carfront-4;
carback=carback-4;
fronttraingle=fronttraingle-4;
glEnd();
76
glutPostRedisplay();
glFlush();
else
glColor3f(.85,.85,.85);
glBegin(GL_POLYGON);
glVertex2f(0, 450);
glVertex2f(0, 700);
glVertex2f(1100, 700);
glVertex2f(1100, 450);
glEnd();
if(m<300)
77
for (l = 0; l <= 35; l++)
78
for (l = 0; l <= 20; l++)
m++;
else
m=0;
//cloud 1
79
for (l = 0; l <= 20; l++)
m++;
}
80
glColor3f(.45, .45, 0.45);
glBegin(GL_POLYGON);
glVertex2f(0, 140);
glVertex2f(0, 450);
glVertex2f(1100, 450);
glVertex2f(1100, 140);
glEnd();
81
for (l = 0; l <= 180; l++)
glBegin(GL_POLYGON);
glVertex2f(0, 100);
glVertex2f(0, 450);
glVertex2f(1100, 450);
glVertex2f(1100, 100);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1100, 0);
glVertex2f(0, 0);
glVertex2f(0, 160);
glVertex2f(1100, 160);
glEnd();
glColor3f(1,1,1);
glBegin(GL_POLYGON);
glVertex2f(950, 40);
82
glVertex2f(730, 40);
glVertex2f(730, 60);
glVertex2f(950, 60);
glEnd();
glColor3f(1,1,1);
glBegin(GL_POLYGON);
glVertex2f(580, 40);
glVertex2f(340, 40);
glVertex2f(340, 60);
glVertex2f(580, 60);
glEnd();
glColor3f(1,1,1);
glBegin(GL_POLYGON);
glVertex2f(210, 40);
glVertex2f(40, 40);
glVertex2f(40, 60);
glVertex2f(210, 60);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1000, 200);
glVertex2f(800, 200);
glVertex2f(800, 500);
83
glVertex2f(1000, 500);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(1000, 200);
glVertex2f(800, 200);
glVertex2f(800, 500);
glVertex2f(1000, 500);
glEnd();
glLineWidth(2);
glBegin(GL_LINES);
glVertex2f(865, 500);
glVertex2f(865, 600);
glEnd();
glBegin(GL_LINES);
glVertex2f(850, 530.33);
glVertex2f(880, 530.33);
glEnd();
glBegin(GL_LINES);
glVertex2f(853, 545.33);
glVertex2f(877, 545.33);
glEnd();
glBegin(GL_LINES);
84
glVertex2f(856, 560.33);
glVertex2f(874, 560.33);
glEnd();
glBegin(GL_LINES);
glVertex2f(859, 575.33);
glVertex2f(871, 575.33);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(983, 200);
glVertex2f(963, 200);
glVertex2f(963, 242);
glVertex2f(983, 242);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(983, 200);
glVertex2f(963, 200);
glVertex2f(963, 242);
glVertex2f(983, 242);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(983, 262);
glVertex2f(963, 262);
85
glVertex2f(963, 282);
glVertex2f(983, 282);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(983, 262);
glVertex2f(963, 262);
glVertex2f(963, 282);
glVertex2f(983, 282);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(983, 302);
glVertex2f(963, 302);
glVertex2f(963, 322);
glVertex2f(983, 322);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(983, 342);
glVertex2f(963, 342);
glVertex2f(963, 362);
glVertex2f(983, 362);
86
glEnd();
glBegin(GL_POLYGON);
glVertex2f(983, 382);
glVertex2f(963, 382);
glVertex2f(963, 402);
glVertex2f(983, 402);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(983, 422);
glVertex2f(963, 422);
glVertex2f(963, 442);
glVertex2f(983, 442);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(940,222);
glVertex2f(900,222 );
glVertex2f(900,242 );
glVertex2f(940,242 );
glEnd();
glBegin(GL_POLYGON);
87
glVertex2f(940,262 );
glVertex2f(900,262 );
glVertex2f(900,282 );
glVertex2f(940,282 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(940,302 );
glVertex2f(900,302 );
glVertex2f(900,322 );
glVertex2f(940,322 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(940,342 );
glVertex2f(900,342 );
glVertex2f(900,362 );
glVertex2f(940,362 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(940,382 );
glVertex2f(900,382 );
glVertex2f(900,402 );
88
glVertex2f(940,402 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(940,422 );
glVertex2f(900,422 );
glVertex2f(900,442 );
glVertex2f(940,442 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(870,222 );
glVertex2f(830,222 );
glVertex2f(830,242 );
glVertex2f(870,242 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(870,262 );
glVertex2f(830,262 );
glVertex2f(830,282 );
glVertex2f(870,282 );
glEnd();
89
glColor3f(1.0, 1., .0);
glBegin(GL_POLYGON);
glVertex2f(870,302 );
glVertex2f(830,302 );
glVertex2f(830,322 );
glVertex2f(870,322 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(870,342 );
glVertex2f(830,342 );
glVertex2f(830,362 );
glVertex2f(870,362 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(870,382 );
glVertex2f(830,382 );
glVertex2f(830,402 );
glVertex2f(870,402 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(870,422 );
90
glVertex2f(830,422 );
glVertex2f(830,442 );
glVertex2f(870,442 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(830,200 );
glVertex2f(510,200 );
glVertex2f(510,400 );
glVertex2f(830,400 );
glEnd();
glLineWidth(3.5);
glBegin(GL_LINES);
glVertex2f(700, 400);
glVertex2f(690, 530);
91
glVertex2f(650, 400);
glVertex2f(670, 530);
glVertex2f(650, 400);
glVertex2f(700, 448);
glVertex2f(700, 448);
glVertex2f(670, 500);
glVertex2f(665, 500);
glVertex2f(690, 530);
glVertex2f(700,400);
glVertex2f(660,450);
glVertex2f(660,450);
glVertex2f(690,500);
glVertex2f(690,500);
glVertex2f(670,525);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
92
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(702,200 );
glVertex2f(635,200 );
glVertex2f(635,240 );
glVertex2f(702,240 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
93
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,290 );
glVertex2f(680,290 );
glVertex2f(680,310 );
glVertex2f(650,310 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650,330 );
glVertex2f(680,330 );
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,330 );
glVertex2f(680,330 );
glVertex2f(680,350 );
glVertex2f(650,350 );
glEnd();
94
glBegin(GL_POLYGON);
glVertex2f(650,370 );
glVertex2f(680,370 );
glVertex2f(680,390 );
glVertex2f(650,390 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(650,370 );
glVertex2f(680,370 );
glVertex2f(680,390 );
glVertex2f(650,390 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glLineWidth(2);
95
glColor3f(.1, .1, .1);
glBegin(GL_LINE_LOOP);
glVertex2f(610,230 );
glVertex2f(580,230 );
glVertex2f(580,250 );
glVertex2f(610,250 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
glVertex2f(610,290 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,270 );
glVertex2f(580,270 );
glVertex2f(580,290 );
glVertex2f(610,290 );
glEnd();
96
glBegin(GL_POLYGON);
glVertex2f(610,310 );
glVertex2f(580,310 );
glVertex2f(580,330 );
glVertex2f(610,330 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(610,310 );
glVertex2f(580,310 );
glVertex2f(580,330 );
glVertex2f(610,330 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(610,350 );
glVertex2f(580,350 );
glVertex2f(580,370 );
glVertex2f(610,370 );
glEnd();
glLineWidth(2);
97
glColor3f(.1, .1, .1);
glBegin(GL_LINE_LOOP);
glVertex2f(610,350 );
glVertex2f(580,350 );
glVertex2f(580,370 );
glVertex2f(610,370 );
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,230 );
glVertex2f(730,230 );
glVertex2f(730,250 );
glVertex2f(760,250 );
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,230 );
glVertex2f(730,230 );
glVertex2f(730,250 );
glVertex2f(760,250 );
glEnd();
98
glBegin(GL_POLYGON);
glVertex2f(760,270);
glVertex2f(730,270);
glVertex2f(730,290);
glVertex2f(760,290);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,270);
glVertex2f(730,270);
glVertex2f(730,290);
glVertex2f(760,290);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,310);
glVertex2f(730,310);
glVertex2f(730,330);
glVertex2f(760,330);
glEnd();
glLineWidth(2);
99
glBegin(GL_LINE_LOOP);
glVertex2f(760,310);
glVertex2f(730,310);
glVertex2f(730,330);
glVertex2f(760,330);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(760,350);
glVertex2f(730,350);
glVertex2f(730,370);
glVertex2f(760,370);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(760,350);
glVertex2f(730,350);
glVertex2f(730,370);
glVertex2f(760,370);
glEnd();
100
glBegin(GL_POLYGON);
glVertex2f(510,200);
glVertex2f(460,200);
glVertex2f(460,530);
glVertex2f(510,530);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(580,400);
glVertex2f(510,400);
glVertex2f(510,530);
glVertex2f(580,530);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(510,200);
glVertex2f(460,200);
glVertex2f(460,530);
glVertex2f(580,530);
glVertex2f(580,400);
glVertex2f(510,400);
101
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,200);
glVertex2f(480,200);
glVertex2f(480,240);
glVertex2f(490,240);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,200);
glVertex2f(480,200);
glVertex2f(480,240);
glVertex2f(490,240);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,250);
glVertex2f(480,250);
glVertex2f(480,260);
glVertex2f(490,260);
glEnd();
102
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,250);
glVertex2f(480,250);
glVertex2f(480,260);
glVertex2f(490,260);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,280);
glVertex2f(480,280);
glVertex2f(480,290);
glVertex2f(490,290);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,280);
glVertex2f(480,280);
glVertex2f(480,290);
glVertex2f(490,290);
103
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,300);
glVertex2f(480,300);
glVertex2f(480,310);
glVertex2f(490,310);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,300);
glVertex2f(480,300);
glVertex2f(480,310);
glVertex2f(490,310);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,320);
glVertex2f(480,320);
glVertex2f(480,330);
glVertex2f(490,330);
glEnd();
104
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,320);
glVertex2f(480,320);
glVertex2f(480,330);
glVertex2f(490,330);
glEnd();
///5
glBegin(GL_POLYGON);
glVertex2f(490,340);
glVertex2f(480,340);
glVertex2f(480,350);
glVertex2f(490,350);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,340);
glVertex2f(480,340);
glVertex2f(480,350);
glVertex2f(490,350);
105
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,360);
glVertex2f(480,360);
glVertex2f(480,370);
glVertex2f(490,370);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,360);
glVertex2f(480,360);
glVertex2f(480,370);
glVertex2f(490,370);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,380);
glVertex2f(480,380);
glVertex2f(480,390);
glVertex2f(490,390);
glEnd();
106
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,380);
glVertex2f(480,380);
glVertex2f(480,390);
glVertex2f(490,390);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,400);
glVertex2f(480,400);
glVertex2f(480,410);
glVertex2f(490,410);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,400);
glVertex2f(480,400);
glVertex2f(480,410);
glVertex2f(490,410);
glEnd();
///9
107
glColor3f(.87, .80, .2);
glBegin(GL_POLYGON);
glVertex2f(490,420);
glVertex2f(480,420);
glVertex2f(480,430);
glVertex2f(490,430);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,420);
glVertex2f(480,420);
glVertex2f(480,430);
glVertex2f(490,430);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,440);
glVertex2f(480,440);
glVertex2f(480,450);
glVertex2f(490,450);
glEnd();
108
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,440);
glVertex2f(480,440);
glVertex2f(480,450);
glVertex2f(490,450);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(490,460);
glVertex2f(480,460);
glVertex2f(480,470);
glVertex2f(490,470);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,460);
glVertex2f(480,460);
glVertex2f(480,470);
glVertex2f(490,470);
glEnd();
109
glBegin(GL_POLYGON);
glVertex2f(490,480);
glVertex2f(480,480);
glVertex2f(480,490);
glVertex2f(490,490);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(490,480);
glVertex2f(480,480);
glVertex2f(480,490);
glVertex2f(490,490);
glEnd();
///13
glBegin(GL_POLYGON);
glVertex2f(490,500);
glVertex2f(480,500);
glVertex2f(480,510);
glVertex2f(490,510);
glEnd();
glLineWidth(2);
110
glColor3f(.1, .1, .1);
glBegin(GL_LINE_LOOP);
glVertex2f(490,500);
glVertex2f(480,500);
glVertex2f(480,510);
glVertex2f(490,510);
glEnd();
///Windows Middle
///1
glBegin(GL_POLYGON);
glVertex2f(550,410);
glVertex2f(530,410);
glVertex2f(530,430);
glVertex2f(550,430);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(550,410);
glVertex2f(530,410);
glVertex2f(530,430);
glVertex2f(550,430);
111
glEnd();
glBegin(GL_POLYGON);
glVertex2f(550,450);
glVertex2f(530,450);
glVertex2f(530,470);
glVertex2f(550,470);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(550,450);
glVertex2f(530,450);
glVertex2f(530,470);
glVertex2f(550,470);
glEnd();
///3
glBegin(GL_POLYGON);
glVertex2f(550,490);
glVertex2f(530,490);
glVertex2f(530,510);
glVertex2f(550,510);
glEnd();
112
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(550,490);
glVertex2f(530,490);
glVertex2f(530,510);
glVertex2f(550,510);
glEnd();
///Building4
glBegin(GL_POLYGON);
glVertex2f(450,200);
glVertex2f(330,200);
glVertex2f(330,400);
glVertex2f(450,400);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(450,200);
glVertex2f(330,200);
glVertex2f(330,400);
113
glVertex2f(450,400);
glEnd();
///DOOr
glBegin(GL_POLYGON);
glVertex2f(440,200);
glVertex2f(420,200);
glVertex2f(420,250);
glVertex2f(440,250);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(440,200);
glVertex2f(420,200);
glVertex2f(420,250);
glVertex2f(440,250);
glEnd();
///windows
glBegin(GL_POLYGON);
glVertex2f(440,270);
114
glVertex2f(400,270);
glVertex2f(400,285);
glVertex2f(440,285);
glEnd();
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2f(440,270);
glVertex2f(400,270);
glVertex2f(400,285);
glVertex2f(440,285);
glEnd();
///2
glBegin(GL_POLYGON);
glVertex2f(440,305);
glVertex2f(400,305);
glVertex2f(400,320);
glVertex2f(440,320);
glEnd();
glBegin(GL_LINE_LOOP);
115
glVertex2f(440,305);
glVertex2f(400,305);
glVertex2f(400,320);
glVertex2f(440,320);
glEnd();
///3
glBegin(GL_POLYGON);
glVertex2f(440,340);
glVertex2f(400,340);
glVertex2f(400,355);
glVertex2f(440,355);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(440,340);
glVertex2f(400,340);
glVertex2f(400,355);
glVertex2f(440,355);
glEnd();
///4
glBegin(GL_POLYGON);
glVertex2f(440,375);
116
glVertex2f(400,375);
glVertex2f(400,390);
glVertex2f(440,390);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(440,375);
glVertex2f(400,375);
glVertex2f(400,390);
glVertex2f(440,390);
glEnd();
///Windows left
///1
glBegin(GL_POLYGON);
glVertex2f(350,235);
glVertex2f(370,235);
glVertex2f(370,250);
glVertex2f(350,250);
glEnd();
glBegin(GL_LINE_LOOP);
117
glVertex2f(350,235);
glVertex2f(370,235);
glVertex2f(370,250);
glVertex2f(350,250);
glEnd();
///2
glBegin(GL_POLYGON);
glVertex2f(350,270);
glVertex2f(370,270);
glVertex2f(370,285);
glVertex2f(350,285);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(350,270);
glVertex2f(370,270);
glVertex2f(370,285);
glVertex2f(350,285);
glEnd();
///3
glBegin(GL_POLYGON);
glVertex2f(350,305);
118
glVertex2f(370,305);
glVertex2f(370,320);
glVertex2f(350,320);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(350,305);
glVertex2f(370,305);
glVertex2f(370,320);
glVertex2f(350,320);
glEnd();
///4
glBegin(GL_POLYGON);
glVertex2f(350,340);
glVertex2f(370,340);
glVertex2f(370,355);
glVertex2f(350,355);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(350,340);
glVertex2f(370,340);
119
glVertex2f(370,355);
glVertex2f(350,355);
glEnd();
///5
glBegin(GL_POLYGON);
glVertex2f(350,375);
glVertex2f(370,375);
glVertex2f(370,390);
glVertex2f(350,390);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(350,375);
glVertex2f(370,375);
glVertex2f(370,390);
glVertex2f(350,390);
glEnd();
if(i<750)
120
//bus
glBegin(GL_POLYGON);
glVertex2f(350 + i, 50);
glVertex2f(350 + i, 210);
glVertex2f(722 + i, 210);
glVertex2f(750 + i, 150);
glVertex2f(750 + i, 50);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(650 + i, 150);
glVertex2f(650 + i, 200);
glVertex2f(720 + i, 200);
glVertex2f(745 + i, 150);
glEnd();
glBegin(GL_POLYGON);
121
glVertex2f(550 + i, 150);
glVertex2f(550 + i, 200);
glVertex2f(625 + i, 200);
glVertex2f(625 + i, 150);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(450 + i, 150);
glVertex2f(450 + i, 200);
glVertex2f(525 + i, 200);
glVertex2f(525 + i, 150);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(375 + i, 150);
glVertex2f(375 + i, 200);
glVertex2f(425 + i, 200);
glVertex2f(425 + i, 150);
glEnd();
122
glColor3f(0.0, 0.0, 0.0);
if(bus==1)
i=i+16;
else
i=-400;
glBegin(GL_POLYGON);
glVertex2f(350 + i, 50);
glVertex2f(350 + i, 275);
glVertex2f(722 + i, 275);
glVertex2f(750 + i, 175);
glVertex2f(750 + i, 50);
glEnd();
123
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(650 + i, 175);
glVertex2f(650 + i, 260);
glVertex2f(720 + i, 260);
glVertex2f(745 + i, 175);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(550 + i, 175);
glVertex2f(550 + i, 260);
glVertex2f(625 + i, 260);
glVertex2f(625 + i, 175);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(450 + i, 175);
glVertex2f(450 + i, 260);
glVertex2f(525 + i, 260);
124
glVertex2f(525 + i, 175);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(375 + i, 175);
glVertex2f(375 + i, 260);
glVertex2f(425 + i, 260);
glVertex2f(425 + i, 175);
glEnd();
if(bus==1)
i=i+16;
}
glutPostRedisplay();
125
glFlush();
126
}
exit(0);
bus=1;
megh=1;
127
}
if(key=='a')
day=1;
glutPostRedisplay();
else if(key=='s')
day=2;
glutPostRedisplay();
else if(key=='d')
day=3;
glutPostRedisplay();
128
else if(key=='f')
day=4;
glutPostRedisplay();
else if(key=='m')
t=1;
glutPostRedisplay();
else if(key=='z')
z=1;
glutPostRedisplay();
else if(key=='x')
b=1;
glutPostRedisplay();
129
glutPostRedisplay();
void myinit()
glPointSize(2.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
void display()
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
draw_object();
130
glFlush();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(1100.0, 700.0);
glutInitWindowPosition(0, 0);
glutCreateWindow("Deforesation");
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glutDisplayFunc(display);
glutKeyboardFunc(keyboardFunc);
glutMouseFunc(mouse);
myinit();
glutMainLoop();
return 0;
131
CHAPTER 5
EXPERIMENTAL RESULTS AND ANALYSIS
The project designed has been tested for its working, and is found to be working properly to
meet all its requirements.
The designed project has been tested for errors and has been found to be meeting all the
requirements of design with which it was started. Thus, the project is declared to be working
properly.
5.1 SNAPSHOT
Fig 1.1 Shows Forest, “A forest is a living thing like a human body . Each part dependent
on all the other parts.”
Fig 1.2 Shows build roads to access more and more remote forests that leads Deforestation.
It shows buildings and roads which are constructed by humans.
132
Fig 1.3 Shows Cutting of Trees and constructing buildings.
133
CONCLUSION
After the completion of this project, we came to know how we can implement a project
using an Open-source OpenGL tool kit. By implementing a project using Open GL we came
to know how to use the functions like menu ‘s, rotation, translation and scaling. With the
completion of this project, we have achieved a sense of happiness and we want to thank all
those who helped us directly or indirectly to make this idea come true.
134
REFERENCES
[1]. Edward Angel, Interactive Computer Graphics A Top-Down Approach with OpenGL,
5th Edition, Addison-Wesley, 2008.
[2]. F.S. Hill,Jr, Computer Graphics Using OpenGL. 2nd Edition, Pearson Education, 2001.
[3]. James D Foley, Andries Van Dam, Steven K Feiner, John F Hughes, Computer
Graphics –Addison-Wesley 1997.
[4]. Donald Hearn and Pauline Baker, Computer Graphics - OpenGL Version –2nd Edition,
Pearson Education, 2003.
135
136