0% found this document useful (0 votes)
2 views

CG project

The document contains a C++ OpenGL program that simulates a moving boat on a river. It includes functions to update the boat's position, handle keyboard inputs for speed control, and draw various graphical elements such as the river, boat, and buildings. The program utilizes GLUT for rendering and event handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CG project

The document contains a C++ OpenGL program that simulates a moving boat on a river. It includes functions to update the boat's position, handle keyboard inputs for speed control, and draw various graphical elements such as the river, boat, and buildings. The program utilizes GLUT for rendering and event handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 18

#include <windows.

h>
#include <GL/glut.h>
#include <math.h>

GLfloat boatPosition = 0.0f; // Boat position

GLfloat speed = 0.01f; // Speed of movement


bool moving = true;

void updateBoat(int value) {


if (moving) {
boatPosition += speed;
if (boatPosition > 1.0f) {
boatPosition = -1.0f;
} else if (boatPosition < -1.0f) {
boatPosition = 1.0f;
}
glutPostRedisplay();
}
glutTimerFunc(100, updateBoat, 0);
}

void init() {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}

void handleSpecialKeys(int key, int x, int y) {


switch (key) {
case GLUT_KEY_UP:
speed = 0.1f;
moving = true;
break;
case GLUT_KEY_DOWN:
speed = -0.1f;
moving = true;
break;
case GLUT_KEY_LEFT:
speed = 0.0f;
moving = false;
break;
case GLUT_KEY_RIGHT:
speed = 0.1f;
moving = true;
break;
}
glutPostRedisplay();
}

void River() {

glColor3ub(29,120,189); // River color


glBegin(GL_QUADS);
glVertex2f(-1.0f, -0.6f);
glVertex2f(1.0f, -0.6f);
glVertex2f(1.0f, -1.0f);
glVertex2f(-1.0f, -1.0f);
glEnd();
}
void Boat(){
// Draw the boat
glPushMatrix();
glTranslatef(boatPosition, 0.0f, 0.0f);
glColor3ub(10,0,129);//31, 63, 96
glBegin(GL_QUADS);//..........................................boats lowre
glVertex2f(0.3f,-0.8f);
glVertex2f(0.6f,-0.8f);
glVertex2f(0.5f,-0.9f);
glVertex2f(0.4f,-0.9f);
glEnd();

glColor3ub(10,38,129);//31, 63, 96
glBegin(GL_QUADS);//..........................................boats lower
glVertex2f(-0.4f,-0.7f);
glVertex2f(-0.7f,-0.7f);
glVertex2f(-0.6f,-0.8f);
glVertex2f(-0.5f,-0.8f);
glEnd();

glColor3ub(7,1196,165);//31, 63, 96
glBegin(GL_QUADS);//..........................................boats upper
glVertex2f(0.35f,-0.8f);
glVertex2f(0.4f,-0.75f);
glVertex2f(0.5f,-0.75f);
glVertex2f(0.55f,-0.8f);
glEnd();

glColor3ub(32,212,232);
glBegin(GL_QUADS);//..........................................boats upper
glVertex2f(-0.45f,-0.7f);
glVertex2f(-0.5f,-0.65f);
glVertex2f(-0.6f,-0.65f);
glVertex2f(-0.65f,-0.7f);
glEnd();

glColor3ub(183,49,15);
glBegin(GL_QUADS);//..........................................boats lower
triangle
glVertex2f(0.7f,-0.9f);
glVertex2f(0.99f,-0.9f);
glVertex2f(0.9f,-0.99f);
glVertex2f(0.8f,-0.99f);
glEnd();

glColor3ub(223,125,27);
glBegin(GL_TRIANGLES);//..........................................boats upper
triangle
glVertex2f(0.75f,-0.9f);
glVertex2f(0.75f,-0.75f);
glVertex2f(0.9f,-0.9f);
glEnd();

glColor3ub(127,33,10); //----------------------------boat line


glLineWidth(5);
glBegin(GL_LINES);
glVertex2f(0.75f,-0.9f);
glVertex2f(0.75f,-0.75f);
glEnd();

glColor3ub(183,49,15);
glBegin(GL_QUADS);//..........................................boats lower
triangle
glVertex2f(-0.7f,-0.9f);
glVertex2f(-0.99f,-0.9f);
glVertex2f(-0.9f,-0.99f);
glVertex2f(-0.8f,-0.99f);
glEnd();

glColor3ub(111,111,111);//31, 63, 96
glBegin(GL_TRIANGLES);//..........................................boats upper
triangle
glVertex2f(-0.75f,-0.9f);
glVertex2f(-0.75f,-0.75f);
glVertex2f(-0.9f,-0.9f);
glEnd();

glColor3ub(127,33,10); //----------------------------boat line


glLineWidth(5);
glBegin(GL_LINES);
glVertex2f(-0.75f,-0.9f);
glVertex2f(-0.75f,-0.75f);
glEnd();
glPopMatrix();

}
void Building()
{

glColor3ub(14,147,195); //-----light tower lower floor


glBegin(GL_QUADS);
glVertex2f(-0.75f,-0.59f);
glVertex2f(-0.5f,-0.59f);
glVertex2f(-0.51f,-0.4f);
glVertex2f(-0.74f,-0.4f);

glColor3ub(14,147,195); //--------light tower top floor


glVertex2f(-0.72f,0.3f);
glVertex2f(-0.52f,0.3f);
glVertex2f(-0.52f,0.4f);
glVertex2f(-0.72f,0.4f);

glColor3ub(14,147,195); //----------light tower


glVertex2f(-0.74f,-0.4f);
glVertex2f(-0.51f,-0.4f);
glVertex2f(-0.52f,0.3f);
glVertex2f(-0.72f,0.3f);

glEnd();

glPushMatrix();
glTranslatef(-0.62,0.45,0);
glScalef(0.08,0.08,1);
//------light tower matha
glPopMatrix();

glColor3ub(0,172,235); //----- light tower triangle


glBegin(GL_TRIANGLES);
glVertex2f(-0.6f,0.55f);
glVertex2f(-0.64f,0.55f);
glVertex2f(-0.62f,0.7f);
glEnd();

glColor3ub(183, 237, 255); //------- light tower er mathar janala


glBegin(GL_QUADS);
glVertex2f(-0.7f,0.4f);
glVertex2f(-0.53f,0.4f);
glVertex2f(-0.53f,0.55f);
glVertex2f(-0.7f,0.55f);

glColor3ub(14,147,195); //------- trangle er nicher square


glVertex2f(-0.66f,0.55f);
glVertex2f(-0.58f,0.55f);
glVertex2f(-0.58f,0.5f);
glVertex2f(-0.66f,0.5f);

glColor3ub(183, 237, 255); //------- light tower er sob light

glVertex2f(-0.55f,0.44f);
glVertex2f(-0.68f,0.44f);
glVertex2f(-0.68f,0.47f);
glVertex2f(-0.55f,0.47f);

glVertex2f(-0.6f,0.31f);
glVertex2f(-0.63f,0.31f);
glVertex2f(-0.63f,0.34f);
glVertex2f(-0.6f,0.34f);

glVertex2f(-0.65f,0.31f);
glVertex2f(-0.68f,0.31f);
glVertex2f(-0.68f,0.34f);
glVertex2f(-0.65f,0.34f);

glVertex2f(-0.7f,0.31f);
glVertex2f(-0.72f,0.31f);
glVertex2f(-0.72f,0.34f);
glVertex2f(-0.7f,0.34f);

glVertex2f(-0.55f,0.31f);
glVertex2f(-0.58f,0.31f);
glVertex2f(-0.58f,0.34f);
glVertex2f(-0.55f,0.34f);

glVertex2f(-0.52f,0.31f);
glVertex2f(-0.53f,0.31f);
glVertex2f(-0.53f,0.34f);
glVertex2f(-0.52f,0.34f);
glVertex2f(-0.6f,0.21f);
glVertex2f(-0.63f,0.21f);
glVertex2f(-0.63f,0.24f);
glVertex2f(-0.6f,0.24f);

glVertex2f(-0.6f,0.11f);
glVertex2f(-0.63f,0.11f);
glVertex2f(-0.63f,0.14f);
glVertex2f(-0.6f,0.14f);

glVertex2f(-0.6f,0.01f);
glVertex2f(-0.63f,0.01f);
glVertex2f(-0.63f,0.04f);
glVertex2f(-0.6f,0.04f);

glVertex2f(-0.6f,-0.05f);
glVertex2f(-0.63f,-0.05f);
glVertex2f(-0.63f,-0.08f);
glVertex2f(-0.6f,-0.08f);

glVertex2f(-0.6f,-0.15f);
glVertex2f(-0.63f,-0.15f);
glVertex2f(-0.63f,-0.18f);
glVertex2f(-0.6f,-0.18f);

glVertex2f(-0.6f,-0.25f);
glVertex2f(-0.63f,-0.25f);
glVertex2f(-0.63f,-0.28f);
glVertex2f(-0.6f,-0.28f);

glVertex2f(-0.6f,-0.35f);
glVertex2f(-0.63f,-0.35f);
glVertex2f(-0.63f,-0.38f);
glVertex2f(-0.6f,-0.38f);

glColor3ub(11, 84, 111); //------ light tower ground floor


glVertex2f(-0.51f,-0.45f);
glVertex2f(-0.6f,-0.45f);
glVertex2f(-0.6f,-0.59f);
glVertex2f(-0.51f,-0.59f);

glEnd();

glPushMatrix();
glTranslatef(-0.95,-0.59,0);
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(30,78,95); //---------bam pasher dim building
float pi=3.1416/2;
float A=(i*2*pi)/200;
float r=0.4;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(141,225,255); //---------bam pasher dim building
float pi=3.1416/4;
float A=(i*2*pi)/200;
float r=0.4;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();
glPopMatrix();

glColor3ub(7,1196,165); //------ dim buidling er bam glass


glBegin(GL_QUADS);

glVertex2f(-1.0f,-0.55f);
glVertex2f(-0.95f,-0.55f);
glVertex2f(-0.95f,-0.5f);
glVertex2f(-1.0f,-0.5f);

glColor3ub(7,1196,165); //-------dim building er pasher glass


glVertex2f(-0.8f,-0.55f);
glVertex2f(-0.65f,-0.55f);
glVertex2f(-0.65f,-0.5f);
glVertex2f(-0.8f,-0.5f);

glEnd();

//-------- dan pasher building start

glPushMatrix();
glTranslatef(0.95,-0.59,0);
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(90,101,102); //---------bam pasher dim building
float pi=3.1416/2;
float A=(i*2*pi)/200;
float r=0.4;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(172,184,186); //---------bam pasher dim building
float pi=3.1416/4;
float A=(i*2*pi)/200;
float r=0.4;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();
glPopMatrix();

glColor3ub(75, 147, 158); //------ dim buidling er part dhaka pore


glBegin(GL_QUADS);
glVertex2f(0.65f,-0.33f);
glVertex2f(1.0f,-0.33f);
glVertex2f(1.0f,-0.38f);
glVertex2f(0.6f,-0.38f);

glColor3ub(98, 183, 196); //------ dim buidling er sada glass


glBegin(GL_QUADS);
glVertex2f(-0.65f,-0.33f);
glVertex2f(-1.0f,-0.33f);
glVertex2f(-1.0f,-0.38f);
glVertex2f(-0.6f,-0.38f);

glColor3ub(98, 183, 196); //------ dim buidling er bam glass


glBegin(GL_QUADS);

glVertex2f(1.0f,-0.55f);
glVertex2f(0.95f,-0.55f);
glVertex2f(0.95f,-0.5f);
glVertex2f(1.0f,-0.5f);
glColor3ub(98, 183, 196);//-------dim building er pasher glass
glVertex2f(0.8f,-0.55f);
glVertex2f(0.65f,-0.55f);
glVertex2f(0.65f,-0.5f);
glVertex2f(0.8f,-0.5f);

glEnd();

glColor3ub(0,111 ,145); //------ ground block


glBegin(GL_QUADS);
glVertex2f(-0.5f,0.4f);
glVertex2f(-0.07f,0.4f);
glVertex2f(-0.07f,-0.6f);
glVertex2f(-0.5f,-0.6f);

glColor3ub(92, 92, 92); //---matha


glVertex2f(-0.5f,0.4f);
glVertex2f(-0.07f,0.4f);
glVertex2f(-0.07f,0.33f);
glVertex2f(-0.5f,0.33f);

glColor3ub(22, 198, 223); //---matha


glVertex2f(-0.5f,0.3f);
glVertex2f(-0.07f,0.3f);
glVertex2f(-0.07f,0.25f);
glVertex2f(-0.5f,0.25f);

glVertex2f(-0.5f,0.2f);
glVertex2f(-0.07f,0.2f);
glVertex2f(-0.07f,0.15f);
glVertex2f(-0.5f,0.15f);

glVertex2f(-0.5f,0.1f);
glVertex2f(-0.07f,0.1f);
glVertex2f(-0.07f,0.05);
glVertex2f(-0.5f,0.05f);

glVertex2f(-0.5f,0.0f);
glVertex2f(-0.07f,0.0f);
glVertex2f(-0.07f,-0.05);
glVertex2f(-0.5f,-0.05f);

glVertex2f(-0.5f,-0.1f);
glVertex2f(-0.07f,-0.1f);
glVertex2f(-0.07f,-0.15);
glVertex2f(-0.5f,-0.15f);

glVertex2f(-0.5f,-0.2f);
glVertex2f(-0.07f,-0.2f);
glVertex2f(-0.07f,-0.25);
glVertex2f(-0.5f,-0.25f);

glVertex2f(-0.5f,-0.3f);
glVertex2f(-0.07f,-0.3f);
glVertex2f(-0.07f,-0.35);
glVertex2f(-0.5f,-0.35f);

glVertex2f(-0.5f,-0.4f);
glVertex2f(-0.07f,-0.4f);
glVertex2f(-0.07f,-0.45);
glVertex2f(-0.5f,-0.45f);

glVertex2f(-0.5f,-0.5f);
glVertex2f(-0.07f,-0.5f);
glVertex2f(-0.07f,-0.55);
glVertex2f(-0.5f,-0.55f);

glEnd();

//--------- building no 2 end


//------------- sun

glPushMatrix();
glTranslatef(0.8,0.8,0);
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(250,242,8); //----------pasher dim er matha
float pi=3.1416;
float A=(i*2*pi)/200;
float r=0.12;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();

glPopMatrix();

//-------- sun end

glPushMatrix();
glTranslatef(0.105,0.51,0);
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(0,128,166); //----------pasher dim er matha
float pi=3.1416;
float A=(i*2*pi)/200;
float r=0.21;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(148,234,255); //----------vitor er colour
float pi=3.1416/2;
float A=(i*2*pi)/200;
float r=0.17;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();
glPopMatrix();
glBegin(GL_QUADS);

glColor3ub(11, 84, 111); //----bottom


glVertex2f(-0.05f,-0.59f);
glVertex2f(0.26f,-0.59f);
glVertex2f(0.26f,-0.38f);
glVertex2f(-0.05f,-0.38f);

glColor3ub(0,128,166); //--------main body


glVertex2f(-0.05f,-0.38f);
glVertex2f(0.26f,-0.38f);
glVertex2f(0.26f,0.38f);
glVertex2f(-0.05f,0.38f);

glColor3ub(148,234,255); //--------main body block


glVertex2f(0.05f,-0.2f);
glVertex2f(0.15f,-0.2f);
glVertex2f(0.15f,0.2f);
glVertex2f(0.05f,0.2f);

glColor3ub(252,252,252); //---matha
glVertex2f(-0.15f,0.4f);
glVertex2f(0.36f,0.4f);
glVertex2f(0.36f,0.33f);
glVertex2f(-0.15f,0.33f);

glEnd();

glBegin(GL_LINES);

glColor3ub(0, 123, 161);


glVertex2f(-0.05f,0.59f);
glVertex2f(0.26f,0.59f);

glVertex2f(0.0f,0.5f);
glVertex2f(0.07f,0.68f);

glVertex2f(0.2f,0.5f);
glVertex2f(0.13f,0.68f);

glEnd();

glBegin(GL_QUADS);

glColor3ub(181,237,255); //--------lights
glVertex2f(-0.15f,0.39f);
glVertex2f(-0.1f,0.39f);
glVertex2f(-0.1f,0.34f);
glVertex2f(-0.15f,0.34f);

glVertex2f(-0.05f,0.39f);
glVertex2f(-0.0f,0.39f);
glVertex2f(-0.0f,0.34f);
glVertex2f(-0.05f,0.34f);

glVertex2f(0.05f,0.39f);
glVertex2f(0.1f,0.39f);
glVertex2f(0.1f,0.34f);
glVertex2f(0.05f,0.34f);

glVertex2f(0.15f,0.39f);
glVertex2f(0.2f,0.39f);
glVertex2f(0.2f,0.34f);
glVertex2f(0.15f,0.34f);

glVertex2f(0.25f,0.39f);
glVertex2f(0.3f,0.39f);
glVertex2f(0.3f,0.34f);
glVertex2f(0.25f,0.34f);

glVertex2f(0.35f,0.39f);
glVertex2f(0.36f,0.39f);
glVertex2f(0.36f,0.34f);
glVertex2f(0.35f,0.34f);

glVertex2f(-0.0f,0.28f);
glVertex2f(-0.05f,0.28f);
glVertex2f(-0.05f,0.2f);
glVertex2f(-0.0f,0.2f);

glVertex2f(0.21f,0.28f);
glVertex2f(0.26f,0.28f);
glVertex2f(0.26f,0.2f);
glVertex2f(0.21f,0.2f);

glVertex2f(-0.0f,0.18f);
glVertex2f(-0.05f,0.18f);
glVertex2f(-0.05f,0.1f);
glVertex2f(-0.0f,0.1f);

glVertex2f(0.21f,0.18f);
glVertex2f(0.26f,0.18f);
glVertex2f(0.26f,0.1f);
glVertex2f(0.21f,0.1f);

glVertex2f(-0.0f,0.08f);
glVertex2f(-0.05f,0.08f);
glVertex2f(-0.05f,0.0f);
glVertex2f(-0.0f,0.0f);

glVertex2f(0.21f,0.08f);
glVertex2f(0.26f,0.08f);
glVertex2f(0.26f,0.0f);
glVertex2f(0.21f,0.0f);

glVertex2f(-0.0f,-0.02f);
glVertex2f(-0.05f,-0.02f);
glVertex2f(-0.05f,-0.1f);
glVertex2f(-0.0f,-0.1f);

glVertex2f(0.21f,-0.02f);
glVertex2f(0.26f,-0.02f);
glVertex2f(0.26f,-0.1f);
glVertex2f(0.21f,-0.1f);
glVertex2f(-0.0f,-0.12f);
glVertex2f(-0.05f,-0.12f);
glVertex2f(-0.05f,-0.2f);
glVertex2f(-0.0f,-0.2f);

glVertex2f(0.21f,-0.12f);
glVertex2f(0.26f,-0.12f);
glVertex2f(0.26f,-0.2f);
glVertex2f(0.21f,-0.2f);

glVertex2f(-0.0f,-0.22f);
glVertex2f(-0.05f,-0.22f);
glVertex2f(-0.05f,-0.3f);
glVertex2f(-0.0f,-0.3f);

glVertex2f(0.21f,-0.22f);
glVertex2f(0.26f,-0.22f);
glVertex2f(0.26f,-0.3f);
glVertex2f(0.21f,-0.3f);

glEnd();

glBegin(GL_QUADS);

glColor3ub(71, 142, 178); //-------pasher building block


glVertex2f(0.3f,-0.59f);
glVertex2f(0.4f,-0.59f);
glVertex2f(0.4f,0.28f);
glVertex2f(0.3f,0.28f);

glColor3ub(50, 102, 128); //-------pasher building tan


glVertex2f(0.32f,-0.59f);
glVertex2f(0.335f,-0.59f);
glVertex2f(0.335f,0.28f);
glVertex2f(0.32f,0.28f);

glColor3ub(50, 102, 128); //-------pasher building tan


glVertex2f(0.34f,-0.59f);
glVertex2f(0.345f,-0.59f);
glVertex2f(0.345f,0.28f);
glVertex2f(0.34f,0.28f);

glColor3ub(50, 102, 128); //-------pasher building tan


glVertex2f(0.35f,-0.59f);
glVertex2f(0.365f,-0.59f);
glVertex2f(0.365f,0.28f);
glVertex2f(0.35f,0.28f);

glColor3ub(50, 102, 128); //-------pasher building tan


glVertex2f(0.38f,-0.59f);
glVertex2f(0.375f,-0.59f);
glVertex2f(0.375f,0.28f);
glVertex2f(0.38f,0.28f);
glColor3ub(80,208,240); //------- bulding colour
glVertex2f(0.4f,-0.59f);
glVertex2f(0.56f,-0.59f);
glVertex2f(0.56f,0.28f);
glVertex2f(0.4f,0.28f);

glColor3ub(161,237,255); //------ colour


glVertex2f(0.43f,0.25f);
glVertex2f(0.47f,0.25f);
glVertex2f(0.47f,0.15f);
glVertex2f(0.43f,0.15f);

glColor3ub(195,236,255); // janla
glVertex2f(0.48f,0.25f);
glVertex2f(0.52f,0.25f);
glVertex2f(0.52f,0.15f);
glVertex2f(0.48f,0.15f);

glColor3ub(161,237,255); //----janla
glVertex2f(0.53f,0.25f);
glVertex2f(0.56f,0.25f);
glVertex2f(0.56f,0.15f);
glVertex2f(0.53f,0.15f);

glVertex2f(0.43f,0.14f);
glVertex2f(0.47f,0.14f);
glVertex2f(0.47f,0.04f);
glVertex2f(0.43f,0.04f);

glVertex2f(0.48f,0.14f);
glVertex2f(0.52f,0.14f);
glVertex2f(0.52f,0.04f);
glVertex2f(0.48f,0.04f);

glColor3ub(161,237,255);
glVertex2f(0.53f,0.14f);
glVertex2f(0.56f,0.14f);
glVertex2f(0.56f,0.04f);
glVertex2f(0.53f,0.04f);

glColor3ub(195,236,255);
glVertex2f(0.43f,0.03f);
glVertex2f(0.47f,0.03f);
glVertex2f(0.47f,-0.07f);
glVertex2f(0.43f,-0.07f);

glColor3ub(161,237,255);
glVertex2f(0.48f,0.03f);
glVertex2f(0.52f,0.03f);
glVertex2f(0.52f,-0.07f);
glVertex2f(0.48f,-0.07f);

glColor3ub(161,237,255);
glVertex2f(0.53f,0.03f);
glVertex2f(0.56f,0.03f);
glVertex2f(0.56f,-0.07f);
glVertex2f(0.53f,-0.07f);
glVertex2f(0.43f,-0.08f);
glVertex2f(0.47f,-0.08f);
glVertex2f(0.47f,-0.18f);
glVertex2f(0.43f,-0.18f);

glVertex2f(0.48f,-0.08f);
glVertex2f(0.52f,-0.08f);
glVertex2f(0.52f,-0.18f);
glVertex2f(0.48f,-0.18f);

glColor3ub(195,236,255);
glVertex2f(0.53f,-0.08f);
glVertex2f(0.56f,-0.08f);
glVertex2f(0.56f,-0.18f);
glVertex2f(0.53f,-0.18f);

glVertex2f(0.43f,-0.19f);
glVertex2f(0.47f,-0.19f);
glVertex2f(0.47f,-0.29f);
glVertex2f(0.43f,-0.29f);

glColor3ub(161,237,255);
glVertex2f(0.48f,-0.19f);
glVertex2f(0.52f,-0.19f);
glVertex2f(0.52f,-0.29f);
glVertex2f(0.48f,-0.29f);

glColor3ub(161,237,255);
glVertex2f(0.53f,-0.19f);
glVertex2f(0.56f,-0.19f);
glVertex2f(0.56f,-0.29f);
glVertex2f(0.53f,-0.29f);

glVertex2f(0.43f,-0.3f);
glVertex2f(0.47f,-0.3f);
glVertex2f(0.47f,-0.4f);
glVertex2f(0.43f,-0.4f);

glColor3ub(195,236,255);
glVertex2f(0.48f,-0.3f);
glVertex2f(0.52f,-0.3f);
glVertex2f(0.52f,-0.4f);
glVertex2f(0.48f,-0.4f);

glVertex2f(0.53f,-0.3f);
glVertex2f(0.56f,-0.3f);
glVertex2f(0.56f,-0.4f);
glVertex2f(0.53f,-0.4f);

glVertex2f(0.43f,-0.41f);
glVertex2f(0.47f,-0.41f);
glVertex2f(0.47f,-0.51f);
glVertex2f(0.43f,-0.51f);

glColor3ub(161,237,255);
glVertex2f(0.48f,-0.41f);
glVertex2f(0.52f,-0.41f);
glVertex2f(0.52f,-0.51f);
glVertex2f(0.48f,-0.51f);
glColor3ub(195,236,255);
glVertex2f(0.53f,-0.41f);
glVertex2f(0.56f,-0.41f);
glVertex2f(0.56f,-0.51f);
glVertex2f(0.53f,-0.51f);

glEnd();

void Cloud() {
glPushMatrix();
glTranslatef(-0.7,1.1,0);
glScalef(0.4,0.4,1);

glColor3ub(0,0,0);//...........................cloud
glPushMatrix();
glTranslatef(0.75,-0.5,0);
glScalef(0.08,0.08,1);

glPopMatrix();

glPushMatrix();
glTranslatef(0.75,-0.5,0);
glBegin(GL_POLYGON);
for(int i=0;i<400;i++)
{
glColor3ub(253,253,243);
float pi=3.1416/2;
float A=(i*2*pi)/200;
float r=0.17;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();

glPopMatrix();

glPushMatrix();
glTranslatef(0.85,-0.65,0);
glBegin(GL_POLYGON);
for(int i=0;i<400;i++)
{
glColor3ub(253,253,243);
float pi=3.1416/2;
float A=(i*2*pi)/200;
float r=0.17;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();
glPopMatrix();
glPushMatrix();
glTranslatef(0.8,-0.71,0);
glBegin(GL_POLYGON);
for(int i=0;i<200;i++)
{
glColor3ub(253,253,243); //------ cloud er vitor colour
float pi=3.1416/2;
float A=(i*2*pi)/200;
float r=0.17;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();

glPopMatrix();

glPushMatrix();
glTranslatef(0.55,-0.55,0);
glBegin(GL_POLYGON);
for(int i=0;i<400;i++)
{
glColor3ub(253,253,243); //------ vitor colour
float pi=3.1416/2;
float A=(i*2*pi)/200;
float r=0.17;
float x = r * cos(A);
float y = r * sin(A);
glVertex2f(x,y);
}

glEnd();

glPopMatrix();

glPointSize(1);
glBegin(GL_POINTS);

glColor3ub(255,255,0);
glVertex2f(0.53f,-0.51f);
glVertex2f(0.63f,-0.515f);
glVertex2f(0.73f,-0.52f);
glVertex2f(0.83f,-0.52f);
glVertex2f(0.93f,-0.515f);
glVertex2f(1.03f,-0.51f);
glEnd();
glPopMatrix();

glPopMatrix();

glPushMatrix();

glPopMatrix();

glPointSize(1);
glBegin(GL_POINTS);

glColor3ub(70,130,180);
glVertex2f(0.53f,-0.51f);
glVertex2f(0.63f,-0.515f);
glVertex2f(0.73f,-0.52f);
glVertex2f(0.83f,-0.52f);
glVertex2f(0.93f,-0.515f);
glVertex2f(1.03f,-0.51f);

glEnd();

void display() {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Set background color to black and
opaque
glClear(GL_COLOR_BUFFER_BIT); // Clear the color buffer
(background)102, 163, 255
glLoadIdentity(); //Reset the drawing perspective
glMatrixMode(GL_MODELVIEW);

glColor3ub(88,193,219);//..........sky
glBegin(GL_QUADS);
glVertex2f(-1.0f,1.0f);
glVertex2f(-1.0f,-1.0f);
glVertex2f(1.0f,-1.0f);
glVertex2f(1.0f,1.0f);
glEnd();

glColor3ub(0,0,0);
glLineWidth(8);
glBegin(GL_LINES);
glVertex2f(-1.0f,-0.6f);
glVertex2f(1.0f,-0.6f);
glEnd();
Cloud();
Building();
River();
Boat();

glFlush(); // Render now


glutSwapBuffers();
}

int main(int argc, char** argv)


{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (900, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Colourfull Neon City");
glutDisplayFunc(display);
init();
glutSpecialFunc(handleSpecialKeys);
glutTimerFunc(100, updateBoat, 0);

glutMainLoop();
}

You might also like