CODIGO
//// Julian Armando Aguilar Juarez
/// Cubo 3D
#include <GL/glut.h>
void myinit(void)
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 500.0, 0.0, 500.0,0.1,400.00);
glMatrixMode(GL_MODELVIEW);
glRotatef(30,0,1,0);
}
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(10,1,1,1);
glBegin(GL_QUADS);
glColor3f(1.0,1.0,0.0);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[3]);
glColor3f(1.0,0.0,0.0);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[3]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[7]);
glColor3f(0.0,1.0,0.0);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[5]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[7]);
glColor3f(1.0,0.0,1.0);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[5]);
glColor3f(0.0,.0.0,0.4);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[3]);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[7]);
glColor3f(1.0,0.0,0.0);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[5]);
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();
}
RESULTADO
No hay comentarios:
Publicar un comentario