Airplane Project

Public

08 December 2020

Views: 35

#include <stdio.h>
#include <GL/glut.h>
#include <math.h>
GLfloat a = 0, b = 0, c = 0, d = 0, e = 0;
int flag = 0, i = 0;
char start[100] = "PRESS ‘S’ TO START";
char exi[40] = "PRESS ‘Q’ TO QUIT";
char college[100] = "SAHYADRI COLLEGE OF ENGINEERING AND MANAGEMENT";
char dept[100] = "DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING";
char project[100] = "A Mini Project On:- Airplane TakeOff simulation";
char name1[50] = "By: Gladson Regan Dsouza 4SF17CS057";
char name2[50] = "Jeethen Crasta 4SF17CS063";
char inst[50] = "Hold 'A' to move the plane";

void runway();
void display();
void display2();
void display3();
void grass();
void treesSet1();
void treesSet2();
void treesSet3();
void mudRoad();
void building();
void mountain();
void houses();
void mudRoad()
{
//road
glColor3f(0.5f, 0.35f, 0.05f);
glBegin(GL_POLYGON);
glVertex2f(0.0, 379.0);
glVertex2f(0.0, 454.0);
glVertex2f(1920.0, 454.0);
glVertex2f(1920.0, 379.0);
glEnd();

//grass
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(0.0, 454.0);
glVertex2f(0.0, 549.0);
glVertex2f(1920.0, 549.0);
glVertex2f(1920.0, 454.0);
glEnd();

// house
glColor3f(0.4f, 0.0f, 0.5f);
glBegin(GL_POLYGON);
glVertex2f(1101.0, 509.0);
glVertex2f(1101.0, 621.0);
glVertex2f(1160.0, 549.0);
glVertex2f(1160.0, 475.0);
glEnd();
glColor3f(1.0f, 0.5f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1160.0, 475.0);
glVertex2f(1160.0, 549.0);
glVertex2f(1313.0, 549.0);
glVertex2f(1313.0, 475.0);
glEnd();
glColor3f(0.2f, 0.2f, 0.1f);
glBegin(GL_POLYGON);
glVertex2f(1224.0, 475.0);
glVertex2f(1224.0, 521.0);
glVertex2f(1248.0, 521.0);
glVertex2f(1248.0, 475.0);
glEnd();
glColor3f(0.0f, 0.0f, 0.6f);
glBegin(GL_POLYGON);
glVertex2f(1155.0, 543.0);
glVertex2f(1090.0, 625.0);
glVertex2f(1269.0, 625.0);
glVertex2f(1336.0, 543.0);
glEnd();
}
void sky()
{
glColor3f(0.0f, 0.5f, 1.0f);
glBegin(GL_POLYGON);
glVertex2f(0.0, 0.0);
glVertex2f(0.0, 960.0);
glVertex2f(1920.0, 960.0);
glVertex2f(1920.0, 0.0);
glEnd();
}
void building()
{
//building
glColor3f(0.8, 0.8, 0.8);
glBegin(GL_POLYGON);
glVertex2f(420.0, 466.0);
glVertex2f(420.0, 863.0);
glVertex2f(696.0, 863.0);
glVertex2f(696.0, 466.0);
glEnd();

// door
glColor3f(0.4, 0.4, 0.4);
glBegin(GL_POLYGON);
glVertex2f(536.0, 466.0);
glVertex2f(536.0, 522.0);
glVertex2f(572.0, 522.0);
glVertex2f(572.0, 466.0);
glEnd();

// window
glColor3f(0.6, 0.6, 0.6);
glBegin(GL_POLYGON);
glVertex2f(465.0, 575.0);
glVertex2f(465.0, 616.0);
glVertex2f(506.0, 616.0);
glVertex2f(506.0, 575.0);
glEnd();

glColor3f(0.6, 0.6, 0.6);
glBegin(GL_POLYGON);
glVertex2f(465.0, 769.0);
glVertex2f(465.0, 817.0);
glVertex2f(515.0, 817.0);
glVertex2f(515.0, 769.0);
glEnd();

glColor3f(0.6, 0.6, 0.6);
glBegin(GL_POLYGON);
glVertex2f(602.0, 679.0);
glVertex2f(602.0, 733.0);
glVertex2f(653.0, 733.0);
glVertex2f(653.0, 679.0);
glEnd();
}

void grass()
{
//this function has grass and houses below mud road
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(0.0, 0.0);
glVertex2f(0.0, 379.0);
glVertex2f(1920.0, 379.0);
glVertex2f(1920.0, 0.0);
glEnd();
}

void houses()
{
//house 1
glColor3f(0.4f, 0.0f, 0.5f);
glBegin(GL_POLYGON);
glVertex2f(541.0, 295.0);
glVertex2f(541.0, 407.0);
glVertex2f(600.0, 335.0);
glVertex2f(600.0, 261.0);
glEnd();
glColor3f(1.0f, 0.5f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(600.0, 261.0);
glVertex2f(600.0, 335.0);
glVertex2f(753.0, 335.0);
glVertex2f(753.0, 261.0);
glEnd();
glColor3f(0.2f, 0.2f, 0.1f);
glBegin(GL_POLYGON);
glVertex2f(664.0, 261.0);
glVertex2f(664.0, 307.0);
glVertex2f(688.0, 307.0);
glVertex2f(688.0, 261.0);
glEnd();
glColor3f(0.0f, 0.0f, 0.6f);
glBegin(GL_POLYGON);
glVertex2f(595.0, 329.0);
glVertex2f(530.0, 411.0);
glVertex2f(709.0, 411.0);
glVertex2f(776.0, 329.0);
glEnd();

// house2

glColor3f(1.0f, 0.5f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1437.0, 283.0);
glVertex2f(1437.0, 395.0);
glVertex2f(1496.0, 323.0);
glVertex2f(1496.0, 249.0);
glEnd();
glColor3f(0.4f, 0.0f, 0.5f);
glBegin(GL_POLYGON);
glVertex2f(1496.0, 249.0);
glVertex2f(1496.0, 323.0);
glVertex2f(1649.0, 323.0);
glVertex2f(1649.0, 249.0);
glEnd();
glColor3f(0.1f, 0.1f, 0.1f);
glBegin(GL_POLYGON);
glVertex2f(1560.0, 249.0);
glVertex2f(1560.0, 295.0);
glVertex2f(1584.0, 295.0);
glVertex2f(1584.0, 249.0);
glEnd();
glColor3f(0.0f, 0.0f, 0.6);
glBegin(GL_POLYGON);
glVertex2f(1491.0, 317.0);
glVertex2f(1426.0, 399.0);
glVertex2f(1605.0, 399.0);
glVertex2f(1672.0, 317.0);
glEnd();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
if (flag == 0)
{
// glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glColor3f(0.0, 1.0, 0.0);
//college name
glRasterPos3f(640, 735, 0);
for (i = 0; college[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, college[i]);
//department name
glRasterPos3f(640, 697, 0);
for (i = 0; dept[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, dept[i]);

//project name
glColor3f(0.0, 0.0, 1.0);
glRasterPos3f(707, 480, 0);
for (i = 0; project[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, project[i]);
//name1
glColor3f(1.0, 1.0, 0.0);
glRasterPos3f(1275, 180, 0);
for (i = 0; name1[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, name1[i]);
//name2
glRasterPos3f(1312, 142, 0);
for (i = 0; name2[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, name2[i]);

//Start and exit
glColor3f(1.0, 0.0, 0.0);
glRasterPos3f(151, 180, 0);
for (i = 0; start[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, start[i]);

glRasterPos3f(151, 142, 0);
for (i = 0; exi[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, exi[i]);
}
else
{
sky();
mudRoad();
grass();
houses();
runway();
treesSet1();
treesSet2();
building();

glColor3f(0.0, 0.0, 0.0);
//instructions
glRasterPos3f(50, 900, 0);
for (i = 0; inst[i] != ''; i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, inst[i]);

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //rectangular body
glVertex2f(116.0, 162.0);
glVertex2f(116.0, 225.0);
glVertex2f(503.0, 225.0);
glVertex2f(503.0, 162.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //upper triangle construction plane
glVertex2f(503.0, 225.0);
glVertex2f(554.0, 210.0);
glVertex2f(569.0, 190.0);
glVertex2f(503.0, 190.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //lower triangle
glVertex2f(503.0, 162.0);
glVertex2f(554.0, 171.0);
glVertex2f(572.0, 179.0);
glVertex2f(569.0, 190.0);
glVertex2f(503.0, 190.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //back wing
glVertex2f(116.0, 162.0);
glVertex2f(63.0, 279.0);
glVertex2f(137.0, 279.0);
glVertex2f(209.0, 225.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //left side wing
glVertex2f(319.0, 225.0);
glVertex2f(286.0, 258.0);
glVertex2f(345.0, 258.0);
glVertex2f(378.0, 225.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //rightside wing
glVertex2f(273.0, 136.0);
glVertex2f(319.0, 189.0);
glVertex2f(391.0, 189.0);
glVertex2f(334.0, 136.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //rightside back wing
glVertex2f(108.0, 154.0);
glVertex2f(139.0, 189.0);
glVertex2f(186.0, 189.0);
glVertex2f(155.0, 154.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //front wheel stand
glVertex2f(462.0, 154.0);
glVertex2f(462.0, 162.0);
glVertex2f(467.0, 162.0);
glVertex2f(467.0, 154.0);
glEnd();
glPopMatrix();

float theta;

glPushMatrix();
glTranslated(a, c, 0.0);
glBegin(GL_POLYGON); //front wheel
for (int i = 0; i < 360; i++)
{
theta = i * 3.142 / 180;
glColor3f(0.5, 0.5, 0.5);
glVertex2f(465 + 7.5 * cos(theta), 147 + 7.5 * sin(theta));
}
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //back wheel stand right
glVertex2f(230.0, 154.0);
glVertex2f(230.0, 162.0);
glVertex2f(235.0, 162.0);
glVertex2f(235.0, 154.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glBegin(GL_POLYGON); //back wheel right
for (int i = 0; i < 360; i++)
{
theta = i * 3.142 / 180;
glColor3f(0.5, 0.5, 0.5);
glVertex2f(232 + 7.5 * cos(theta), 147 + 7.5 * sin(theta));
}
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //back wheel stand left
glVertex2f(251.0, 157.0);
glVertex2f(251.0, 162.0);
glVertex2f(255.0, 162.0);
glVertex2f(255.0, 157.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(a, c, 0.0);
glBegin(GL_POLYGON); //back wheel left
for (int i = 0; i < 360; i++)
{
theta = i * 3.142 / 180;
glColor3f(0.5, 0.5, 0.5);
glVertex2f(253 + 7.5 * cos(theta), 151 + 7.5 * sin(theta));
}
glEnd();
glPopMatrix();

if (a < 1400)
{
c = 0.0;
}

if (a > 1920)
{
display2();
d += 10.0;
}

if (d > 1720)
{
display3();
e += 5;
}
}
glFlush();
glutSwapBuffers();
}

void treesSet1()
{
//below mud road
//tree 1
//tree trunk
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(240.0, 290.0);
glVertex2f(240.0, 320.0);
glVertex2f(266.0, 320.0);
glVertex2f(266.0, 290.0);
glEnd();

//leaves
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(200.0, 320.0);
glVertex2f(222.0, 365.0);
glVertex2f(283.0, 365.0);
glVertex2f(312.0, 320.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(200.0, 365.0);
glVertex2f(222.0, 407.0);
glVertex2f(279.0, 407.0);
glVertex2f(301.0, 365.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(205.0, 407.0);
glVertex2f(232.0, 449.0);
glVertex2f(270.0, 449.0);
glVertex2f(302.0, 407.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(223.0, 449.0);
glVertex2f(253.0, 494.0);
glVertex2f(278.0, 449.0);
glEnd();

// tree2
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(830.0, 305.0);
glVertex2f(830.0, 335.0);
glVertex2f(856.0, 335.0);
glVertex2f(856.0, 305.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(788.0, 335.0);
glVertex2f(810.0, 380.0);
glVertex2f(870.0, 380.0);
glVertex2f(892.0, 335.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(788.0, 380.0);
glVertex2f(810.0, 422.0);
glVertex2f(866.0, 422.0);
glVertex2f(888.0, 380.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(793.0, 422.0);
glVertex2f(820.0, 464.0);
glVertex2f(858.0, 464.0);
glVertex2f(885.0, 422.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(811.0, 464.0);
glVertex2f(841.0, 509.0);
glVertex2f(864.0, 464.0);
glEnd();

// tree3
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1143.0, 258.0);
glVertex2f(1143.0, 288.0);
glVertex2f(1169.0, 288.0);
glVertex2f(1169.0, 258.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1103.0, 288.0);
glVertex2f(1125.0, 333.0);
glVertex2f(1185.0, 333.0);
glVertex2f(1207.0, 288.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1103.0, 333.0);
glVertex2f(1125.0, 375.0);
glVertex2f(1181.0, 375.0);
glVertex2f(1203.0, 333.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1108.0, 375.0);
glVertex2f(1135.0, 417.0);
glVertex2f(1173.0, 417.0);
glVertex2f(1200.0, 375.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1126.0, 417.0);
glVertex2f(1156.0, 462.0);
glVertex2f(1179.0, 417.0);
glEnd();

//tree4
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1346.0, 313.0);
glVertex2f(1346.0, 343.0);
glVertex2f(1372.0, 343.0);
glVertex2f(1372.0, 313.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1306.0, 343.0);
glVertex2f(1328.0, 388.0);
glVertex2f(1388.0, 388.0);
glVertex2f(1410.0, 343.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1306.0, 388.0);
glVertex2f(1328.0, 430.0);
glVertex2f(1384.0, 430.0);
glVertex2f(1406.0, 388.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1311.0, 430.0);
glVertex2f(1338.0, 472.0);
glVertex2f(1376.0, 472.0);
glVertex2f(1403.0, 430.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1329.0, 472.0);
glVertex2f(1359.0, 517.0);
glVertex2f(1382.0, 472.0);
glEnd();

//tree5
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1672.0, 318.0);
glVertex2f(1672.0, 348.0);
glVertex2f(1698.0, 348.0);
glVertex2f(1698.0, 318.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1632.0, 348.0);
glVertex2f(1654.0, 393.0);
glVertex2f(1714.0, 393.0);
glVertex2f(1736.0, 348.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1632.0, 393.0);
glVertex2f(1654.0, 435.0);
glVertex2f(1710.0, 435.0);
glVertex2f(1732.0, 393.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1637.0, 435.0);
glVertex2f(1664.0, 477.0);
glVertex2f(1702.0, 477.0);
glVertex2f(1729.0, 435.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1655.0, 477.0);
glVertex2f(1685.0, 522.0);
glVertex2f(1708.0, 477.0);
glEnd();
//tree6

glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1823.0, 261.0);
glVertex2f(1823.0, 291.0);
glVertex2f(1849.0, 291.0);
glVertex2f(1849.0, 261.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1783.0, 291.0);
glVertex2f(1805.0, 336.0);
glVertex2f(1865.0, 336.0);
glVertex2f(1887.0, 291.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1783.0, 336.0);
glVertex2f(1805.0, 378.0);
glVertex2f(1861.0, 378.0);
glVertex2f(1883.0, 336.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1788.0, 378.0);
glVertex2f(1815.0, 420.0);
glVertex2f(1853.0, 420.0);
glVertex2f(1880.0, 378.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1806.0, 420.0);
glVertex2f(1836.0, 465.0);
glVertex2f(1859.0, 420.0);
glEnd();
}

void treesSet2()
{
// tree 1
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(78.0, 514.0);
glVertex2f(78.0, 544.0);
glVertex2f(104.0, 544.0);
glVertex2f(104.0, 514.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(38.0, 544.0);
glVertex2f(60.0, 589.0);
glVertex2f(120.0, 589.0);
glVertex2f(142.0, 544.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(38.0, 589.0);
glVertex2f(60.0, 631.0);
glVertex2f(116.0, 631.0);
glVertex2f(138.0, 589.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(43.0, 631.0);
glVertex2f(70.0, 673.0);
glVertex2f(108.0, 673.0);
glVertex2f(135.0, 631.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(61.0, 673.0);
glVertex2f(91.0, 718.0);
glVertex2f(114.0, 673.0);
glEnd();

//tree - 2
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(260.0, 482.0);
glVertex2f(260.0, 512.0);
glVertex2f(286.0, 512.0);
glVertex2f(286.0, 482.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(220.0, 512.0);
glVertex2f(242.0, 557.0);
glVertex2f(302.0, 557.0);
glVertex2f(324.0, 512.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(220.0, 557.0);
glVertex2f(242.0, 599.0);
glVertex2f(298.0, 599.0);
glVertex2f(320.0, 557.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(225.0, 599.0);
glVertex2f(252.0, 641.0);
glVertex2f(290.0, 641.0);
glVertex2f(317.0, 599.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(243.0, 641.0);
glVertex2f(273.0, 686.0);
glVertex2f(296.0, 641.0);
glEnd();
//tree - 3
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(773.0, 460.0);
glVertex2f(773.0, 490.0);
glVertex2f(799.0, 490.0);
glVertex2f(799.0, 460.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(733.0, 490.0);
glVertex2f(755.0, 535.0);
glVertex2f(815.0, 535.0);
glVertex2f(837.0, 490.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(733.0, 535.0);
glVertex2f(755.0, 577.0);
glVertex2f(811.0, 577.0);
glVertex2f(833.0, 535.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(738.0, 577.0);
glVertex2f(765.0, 619.0);
glVertex2f(803.0, 619.0);
glVertex2f(830.0, 577.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(756.0, 619.0);
glVertex2f(786.0, 664.0);
glVertex2f(809.0, 619.0);
glEnd();
//tree - 4
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(953.0, 494.0);
glVertex2f(953.0, 524.0);
glVertex2f(979.0, 524.0);
glVertex2f(979.0, 494.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(913.0, 524.0);
glVertex2f(935.0, 569.0);
glVertex2f(995.0, 569.0);
glVertex2f(1017.0, 524.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(913.0, 569.0);
glVertex2f(935.0, 611.0);
glVertex2f(991.0, 611.0);
glVertex2f(1013.0, 569.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(918.0, 611.0);
glVertex2f(945.0, 653.0);
glVertex2f(983.0, 653.0);
glVertex2f(1010.0, 611.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(936.0, 653.0);
glVertex2f(966.0, 698.0);
glVertex2f(989.0, 653.0);
glEnd();

// tree - 5
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1554.0, 471.0);
glVertex2f(1554.0, 501.0);
glVertex2f(1580.0, 501.0);
glVertex2f(1580.0, 471.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1514.0, 501.0);
glVertex2f(1536.0, 546.0);
glVertex2f(1596.0, 546.0);
glVertex2f(1618.0, 501.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1514.0, 546.0);
glVertex2f(1536.0, 588.0);
glVertex2f(1592.0, 588.0);
glVertex2f(1614.0, 546.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1519.0, 588.0);
glVertex2f(1546.0, 630.0);
glVertex2f(1584.0, 630.0);
glVertex2f(1611.0, 588.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1537.0, 630.0);
glVertex2f(1567.0, 675.0);
glVertex2f(1590.0, 630.0);
glEnd();

glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(496.0, 501.0);
glVertex2f(496.0, 531.0);
glVertex2f(522.0, 531.0);
glVertex2f(522.0, 501.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(456.0, 531.0);
glVertex2f(478.0, 576.0);
glVertex2f(538.0, 576.0);
glVertex2f(560.0, 531.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(456.0, 576.0);
glVertex2f(478.0, 618.0);
glVertex2f(534.0, 618.0);
glVertex2f(556.0, 576.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(461.0, 618.0);
glVertex2f(488.0, 660.0);
glVertex2f(526.0, 660.0);
glVertex2f(553.0, 618.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(479.0, 660.0);
glVertex2f(509.0, 705.0);
glVertex2f(532.0, 660.0);
glEnd();
}

void treesSet3()
{
// tree -1
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(78.0, 72.0);
glVertex2f(78.0, 102.0);
glVertex2f(104.0, 102.0);
glVertex2f(104.0, 72.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(38.0, 102.0);
glVertex2f(60.0, 147.0);
glVertex2f(120.0, 147.0);
glVertex2f(142.0, 102.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(38.0, 147.0);
glVertex2f(60.0, 189.0);
glVertex2f(116.0, 189.0);
glVertex2f(138.0, 147.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(43.0, 189.0);
glVertex2f(70.0, 231.0);
glVertex2f(108.0, 231.0);
glVertex2f(135.0, 189.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(61.0, 231.0);
glVertex2f(91.0, 276.0);
glVertex2f(114.0, 231.0);
glEnd();

// tree 2

// tree 3
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(439.0, 116.0);
glVertex2f(439.0, 146.0);
glVertex2f(465.0, 146.0);
glVertex2f(465.0, 116.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(399.0, 146.0);
glVertex2f(421.0, 191.0);
glVertex2f(481.0, 191.0);
glVertex2f(503.0, 146.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(399.0, 191.0);
glVertex2f(421.0, 233.0);
glVertex2f(477.0, 233.0);
glVertex2f(499.0, 191.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(404.0, 233.0);
glVertex2f(431.0, 275.0);
glVertex2f(469.0, 275.0);
glVertex2f(496.0, 233.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(422.0, 275.0);
glVertex2f(452.0, 320.0);
glVertex2f(475.0, 275.0);
glEnd();

//tree 4
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(738.0, 36.0);
glVertex2f(738.0, 66.0);
glVertex2f(764.0, 66.0);
glVertex2f(764.0, 36.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(698.0, 66.0);
glVertex2f(720.0, 111.0);
glVertex2f(780.0, 111.0);
glVertex2f(802.0, 66.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(698.0, 111.0);
glVertex2f(720.0, 153.0);
glVertex2f(776.0, 153.0);
glVertex2f(798.0, 111.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(703.0, 153.0);
glVertex2f(730.0, 195.0);
glVertex2f(768.0, 195.0);
glVertex2f(795.0, 153.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(721.0, 195.0);
glVertex2f(751.0, 240.0);
glVertex2f(774.0, 195.0);
glEnd();

//tree 5
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1126.0, 67.0);
glVertex2f(1126.0, 97.0);
glVertex2f(1152.0, 97.0);
glVertex2f(1152.0, 67.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1086.0, 97.0);
glVertex2f(1108.0, 142.0);
glVertex2f(1168.0, 142.0);
glVertex2f(1190.0, 97.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1086.0, 142.0);
glVertex2f(1108.0, 184.0);
glVertex2f(1164.0, 184.0);
glVertex2f(1186.0, 142.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1091.0, 184.0);
glVertex2f(1118.0, 226.0);
glVertex2f(1156.0, 226.0);
glVertex2f(1183.0, 184.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1109.0, 226.0);
glVertex2f(1139.0, 271.0);
glVertex2f(1162.0, 226.0);
glEnd();

//tree 6
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1537.0, 58.0);
glVertex2f(1537.0, 88.0);
glVertex2f(1563.0, 88.0);
glVertex2f(1563.0, 58.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1497.0, 88.0);
glVertex2f(1519.0, 133.0);
glVertex2f(1579.0, 133.0);
glVertex2f(1601.0, 88.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1497.0, 133.0);
glVertex2f(1519.0, 175.0);
glVertex2f(1575.0, 175.0);
glVertex2f(1597.0, 133.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1502.0, 175.0);
glVertex2f(1529.0, 217.0);
glVertex2f(1567.0, 217.0);
glVertex2f(1594.0, 175.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1520.0, 217.0);
glVertex2f(1550.0, 262.0);
glVertex2f(1573.0, 217.0);
glEnd();
//tree 7
glColor3f(0.4f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1785.0, 85.0);
glVertex2f(1785.0, 115.0);
glVertex2f(1811.0, 115.0);
glVertex2f(1811.0, 85.0);
glEnd();
glColor3f(0.0f, 0.3f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(1745.0, 115.0);
glVertex2f(1767.0, 160.0);
glVertex2f(1827.0, 160.0);
glVertex2f(1849.0, 115.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1745.0, 160.0);
glVertex2f(1767.0, 202.0);
glVertex2f(1823.0, 202.0);
glVertex2f(1845.0, 160.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1750.0, 202.0);
glVertex2f(1777.0, 244.0);
glVertex2f(1815.0, 244.0);
glVertex2f(1842.0, 202.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(1768.0, 244.0);
glVertex2f(1798.0, 289.0);
glVertex2f(1821.0, 244.0);
glEnd();
}

void mountain()
{
// glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.3f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(0.0, 368.0);
glVertex2f(0.0, 588.0);
glVertex2f(304.0, 759.0);
glVertex2f(751.0, 439.0);
glVertex2f(990.0, 553.0);
glVertex2f(1135.0, 436.0);
glVertex2f(1640.0, 577.0);
glVertex2f(1920.0, 414.0);
glVertex2f(1920.0, 368.0);
glEnd();
}
void display2(void)
{
glClear(GL_COLOR_BUFFER_BIT);
sky();
mudRoad();
grass();
houses();
treesSet1();
treesSet2();
treesSet3();

//aeroplane
glPushMatrix();
glTranslated(d, c, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //rectangular body
glVertex2f(116.0, 162.0);
glVertex2f(116.0, 225.0);
glVertex2f(503.0, 225.0);
glVertex2f(503.0, 162.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(d, c, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //upper triangle construction plane
glVertex2f(503.0, 225.0);
glVertex2f(554.0, 210.0);
glVertex2f(569.0, 190.0);
glVertex2f(503.0, 190.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(d, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //lower triangle
glVertex2f(503.0, 162.0);
glVertex2f(554.0, 171.0);
glVertex2f(572.0, 179.0);
glVertex2f(569.0, 190.0);
glVertex2f(503.0, 190.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(d, c, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //back wing
glVertex2f(116.0, 162.0);
glVertex2f(63.0, 279.0);
glVertex2f(137.0, 279.0);
glVertex2f(209.0, 225.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(d, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //left side wing
glVertex2f(319.0, 225.0);
glVertex2f(286.0, 258.0);
glVertex2f(345.0, 258.0);
glVertex2f(378.0, 225.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(d, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //rightside wing
glVertex2f(273.0, 136.0);
glVertex2f(319.0, 189.0);
glVertex2f(391.0, 189.0);
glVertex2f(334.0, 136.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(d, c, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //rightside back wing
glVertex2f(108.0, 154.0);
glVertex2f(139.0, 189.0);
glVertex2f(186.0, 189.0);
glVertex2f(155.0, 154.0);
glEnd();
glPopMatrix();
}

void display3(void)
{
glClear(GL_COLOR_BUFFER_BIT);
sky();
mountain();
grass();
treesSet1();
treesSet3();

//aeroplane
glPushMatrix();
glTranslated(e, 600, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //rectangular body
glVertex2f(116.0, 162.0);
glVertex2f(116.0, 225.0);
glVertex2f(503.0, 225.0);
glVertex2f(503.0, 162.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(e, 600, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //upper triangle construction plane
glVertex2f(503.0, 225.0);
glVertex2f(554.0, 210.0);
glVertex2f(569.0, 190.0);
glVertex2f(503.0, 190.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(e, 600, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //lower triangle
glVertex2f(503.0, 162.0);
glVertex2f(554.0, 171.0);
glVertex2f(572.0, 179.0);
glVertex2f(569.0, 190.0);
glVertex2f(503.0, 190.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(e, 600, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON); //back wing
glVertex2f(116.0, 162.0);
glVertex2f(63.0, 279.0);
glVertex2f(137.0, 279.0);
glVertex2f(209.0, 225.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(e, 600, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //left side wing
glVertex2f(319.0, 225.0);
glVertex2f(286.0, 258.0);
glVertex2f(345.0, 258.0);
glVertex2f(378.0, 225.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(e, 600, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //rightside wing
glVertex2f(273.0, 136.0);
glVertex2f(319.0, 189.0);
glVertex2f(391.0, 189.0);
glVertex2f(334.0, 136.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(e, 600, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON); //rightside back wing
glVertex2f(108.0, 154.0);
glVertex2f(139.0, 189.0);
glVertex2f(186.0, 189.0);
glVertex2f(155.0, 154.0);
glEnd();
glPopMatrix();
}
void runway()
{
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POLYGON); //black road
glVertex2f(0.0, 80.0);
glVertex2f(0.0, 215.0);
glVertex2f(1920.0, 215.0);
glVertex2f(1920.0, 80.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);

glBegin(GL_POLYGON); //white strips on road
glVertex2f(0.0, 133.0);
glVertex2f(10.0, 151.0);
glVertex2f(150.0, 151.0);
glVertex2f(140.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(200.0, 133.0);
glVertex2f(210.0, 151.0);
glVertex2f(350.0, 151.0);
glVertex2f(340.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(400.0, 133.0);
glVertex2f(410.0, 151.0);
glVertex2f(550.0, 151.0);
glVertex2f(540.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(600.0, 133.0);
glVertex2f(610.0, 151.0);
glVertex2f(750.0, 151.0);
glVertex2f(740.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(800.0, 133.0);
glVertex2f(810.0, 151.0);
glVertex2f(950.0, 151.0);
glVertex2f(940.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(1000.0, 133.0);
glVertex2f(1010.0, 151.0);
glVertex2f(1150.0, 151.0);
glVertex2f(1140.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(1200.0, 133.0);
glVertex2f(1210.0, 151.0);
glVertex2f(1350.0, 151.0);
glVertex2f(1340.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(1400.0, 133.0);
glVertex2f(1410.0, 151.0);
glVertex2f(1550.0, 151.0);
glVertex2f(1540.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(1600.0, 133.0);
glVertex2f(1610.0, 151.0);
glVertex2f(1750.0, 151.0);
glVertex2f(1740.0, 133.0);
glEnd();
glPopMatrix();

glPushMatrix();
glTranslated(b, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(1800.0, 133.0);
glVertex2f(1810.0, 151.0);
glVertex2f(1950.0, 151.0);
glVertex2f(1940.0, 133.0);
glEnd();
glPopMatrix();
}

void myinit()
{
// glClearColor(0.0f, 0.5f, 1.0f, 0.0f); //background color
glColor3f(1.0, 0.0, 0.0);
glPointSize(1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1920.0, 0.0, 960.0); // this is like a viewing region
}

void keys(unsigned char key, int x, int y)
{
if (key == 's' || key == 'S')
{

flag = 1;
a = 0, c = 0, d = 0, e = 0; //resetting these values after one flight
}
if (key == 'q' || key == 'Q')
return;
if (key == 'a' || key == 'A')
{
a += 5.0; //Plane position takeoff on x axis
b -= 5.0; //Road Strip backward movement
c += 2; //take off at certain angle on y axis
if (b <= -78.0) // moving of run way
b = 0.0;
; //take off at certain angle on y axis
if (e > 1720) //back to home page after the third display
flag = 0;
}
display();
}

int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(1920.0, 960.0);
glutInitWindowPosition(0, 0);
glutCreateWindow("Airplane Takeoff computer graphics projects");
glutDisplayFunc(display);
myinit();
glutKeyboardFunc(keys);
glutMainLoop();
return 0;
}
Disable Third Party Ads

Share