///Martin Orlando Palomares
///Cubo 3D
#include <GL/glut.h>
void myinit(void)
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glColor3f(1.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(100.0, 500.0, 100.0, 500.0,10.00,500.00);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void display( void )
{
typedef GLfloat point3[3];
point3 vertices[8]={{100.0,100.0,0.0},{200.0,100.0,0.0},{200.0,200.0,0.0},{100.0,200.0,0.0},{100.0,100.0,-100.00},{200.0,100,-100.00},{200.0,200.0,-100.00},{100.0,200.0,-100.00}};
glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(200,100,-100);
glRotatef(55,1,1,1);
glBegin(GL_QUADS);
glColor3f(1.0,1.0,1.0);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[5]);
glColor3f(1.0,0.0,1.0);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[5]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[7]);
glColor3f(1.0,0.0,0.0);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[3]);
glVertex3fv(vertices[7]);
glVertex3fv(vertices[4]);
glColor3f(1.0,0.0,1.0);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[5]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[2]);
glColor3f(0.25,0.25,0.25);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[3]);
glColor3f(0.98,0.625,0.12);
glVertex3fv(vertices[3]);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[7]);
glEnd();
glutSwapBuffers();
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("Sierpinski Gasket");
glutDisplayFunc(display);
myinit();
glutMainLoop();
}