#include <gl\glut.h>
void myinit(void){
glClearColor(1.0, 1.0, 1.0, 1.0); /* white background */
glColor3f(1.0, 0.0, 0.0); /* draw in red */
/* set up viewing *//* 500 x 500 window with origin lower left */
glMatrixMode(GL_PROJECTION);glLoadIdentity();
gluOrtho2D(0.0, 500.0, 0.0, 500.0);
glMatrixMode(GL_MODELVIEW);
}
void display(void)
{
typedef GLfloat point2[2];
point2 vertice[8] = {{100.0,100.0},{300.0,100.0},{300.0,300.0},{100.0,300.0},{400.0,200.0},{400.0,400.0},{200.0,400.0},{200.0,200.0}};
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(512, 512);
glutCreateWindow("Cubo en 2D");
glutDisplayFunc(display);
glutMainLoop();
}

No hay comentarios:
Publicar un comentario