#include <GL/glut.h>
void display(void)
{
typedef GLfloat point2[3];
point2 vertice[8] = {
{200.0,100.0,0},
{200.0,200.0,0},
{100.0,200.0,0},
{100.0,100.0,0},
{200.0,100.0,-100},
{200.0,200.0,-100},
{100.0,200.0,-100},
{100.0,100.0,-100}};
glColor3f(1.0,0.0,0.0);
gluOrtho2D(0.0, 500.0, 0.0, 500.0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2fv(vertice[0]);
glVertex2fv(vertice[1]);
glVertex2fv(vertice[1]);
glVertex2fv(vertice[2]);
glVertex2fv(vertice[2]);
glVertex2fv(vertice[3]);
glVertex2fv(vertice[3]);
glVertex2fv(vertice[0]);
glVertex2fv(vertice[1]);
glVertex2fv(vertice[4]);
glVertex2fv(vertice[2]);
glVertex2fv(vertice[5]);
glVertex2fv(vertice[5]);
glVertex2fv(vertice[4]);
glVertex2fv(vertice[5]);
glVertex2fv(vertice[6]);
glVertex2fv(vertice[6]);
glVertex2fv(vertice[3]);
glVertex2fv(vertice[0]);
glVertex2fv(vertice[7]);
glVertex2fv(vertice[4]);
glVertex2fv(vertice[7]);
glVertex2fv(vertice[6]);
glVertex2fv(vertice[7]);
glEnd();
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(500, 500);
glutCreateWindow("Cubo en 2D");
glutDisplayFunc(display);
glutMainLoop();
}