#include <windows.h>
#include<iostream>
#include<math.h>
#include<GL/glut.h>
using namespace std;
static float input[5][3] =
{
{
30,30,0},{80,30,0},{90,40,-50},{40,40,-50},{60,80,-25}
};
void Axes(void)
{
/*glColor3f(1.0, 1.0, 1.0); */ // Set the color to BLACK
glBegin(GL_LINES); // Plotting X-Axis
glVertex2s(-1000, 0);
glVertex2s(1000, 0);
glEnd();
glBegin(GL_LINES); // Plotting Y-Axis
glVertex2s(0, -1000);
glVertex2s(0, 1000);
glEnd();
}
void draw(float a[8][3])
{
glBegin(GL_QUADS);
glColor3f(0.7, 0.4, 0.5); //bottom
glVertex3fv(a[0]);
glVertex3fv(a[1]);
glVertex3fv(a[2]);
glVertex3fv(a[3]);
glBegin(GL_QUADS);
glColor3f(0.8, 0.2, 0.4); //behind
glVertex3fv(a[3]);
glVertex3fv(a[4]);
glVertex3fv(a[2]);
glBegin(GL_QUADS);
glColor3f(0.3, 0.6, 0.7); //left
glVertex3fv(a[2]);
glVertex3fv(a[4]);
glVertex3fv(a[1]);
glBegin(GL_QUADS);
glColor3f(0, 0, 0.2); //right
glVertex3fv(a[2]);
glVertex3fv(a[4]);
glVertex3fv(a[0]);
glBegin(GL_QUADS);
glColor3f(0.6, 0.6, 0.2); //front
glVertex3fv(a[0]);
glVertex3fv(a[1]);
glVertex3fv(a[4]);
glEnd();
}
void init()
{
glClearColor(0.1, 0.1, 0.1, 1.0); //set backgrond color to white
glOrtho(-454.0, 454.0, -250.0, 250.0, -250.0, 250.0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Axes();
/*glColor3f(1.0, 0.0, 0.0);*/
draw(input);
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(1362, 750);
glutInitWindowPosition(0, 0);
glutCreateWindow("3D Object");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}