Thursday, 3 December 2015

road side

#include<GL/glut.h>

void road()
{

//SKY

glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glPointSize(5);
glColor3f(0,0,1);

glVertex2f(-1,1);
glVertex2f(1,1);

glColor3f(1,1,1);
glVertex2f(1,0);
glVertex2f(-1,0);
glEnd();

//Buildings

glBegin(GL_QUADS);
glPointSize(5);
glColor3f(1,1,0);

glVertex2f(-1,0.5);
glVertex2f(-0.167,0.5);
glVertex2f(-0.167,0);
glVertex2f(-1,0);
glEnd();



//Road

glBegin(GL_QUADS);
glColor3f(1,0,0);

glVertex2f(-1,0);
glVertex2f(1,0);
    //glColor3f(1,1,1);
glVertex2f(1,-0.5);
glVertex2f(-1,-0.5);


glEnd();

//CAR

glBegin(GL_QUADS);
glColor3f(0,0,0);

glVertex2f(-1,0);
glVertex2f(1,0);
glColor3f(1,1,1);
glVertex2f(1,-0.5);
glVertex2f(-1,-0.5);


glEnd();


//strips
glBegin(GL_LINES);
glColor3f(1,1,1);

glVertex2f(-1,-0.25);
glVertex2f(-0.88,-0.25);

glVertex2f(-0.66,-0.25);
glVertex2f(-0.44,-0.25);


glVertex2f(-0.22,-0.25);
glVertex2f(0,-0.25);

glVertex2f(0,-0.25);
glVertex2f(0.22,-0.25);

glVertex2f(0.44,-0.25);
glVertex2f(0.66,-0.25);


glVertex2f(0.88,-0.25);
glVertex2f(1,-0.25);



glEnd();



//red light

//pole
glBegin(GL_QUADS);
glColor3f(0,0,0);

glVertex2f(0.75,0);
glVertex2f(0.75,0.300);
glVertex2f(0.80,0.300);
glVertex2f(0.80,0);

glEnd();

//display

glBegin(GL_QUADS);
glColor3f(0,0,0);

glVertex2f(0.60,0.300);
glVertex2f(0.95,0.300);
glVertex2f(0.95,0.700);
glVertex2f(0.60,0.700);

glEnd();

//lights

glBegin(GL_POINTS);
glPointSize(100);

    glColor3f(1,0,0);
glVertex2f(0.70,0.280);

glColor3f(1,1,0);
glVertex2f(0.70,0.250);

glColor3f(0,1,0);
glVertex2f(0.70,0.0125);
glEnd();


//greenry

glBegin(GL_QUADS);
glColor3f(0,1,0);
glVertex2f(-1,-0.5);
glVertex2f(1,-0.5);
glVertex2f(1,-1);
glVertex2f(-1,-1);


glEnd();
glFlush();
}

void main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowSize(500,500);
glutInitWindowPosition(10,10);
glutCreateWindow("Road_Side_View");
glutDisplayFunc(road);
glutMainLoop();
}

No comments:

Post a Comment