jueves, 8 de marzo de 2012

CUBO 3D (QUADS)

// JULIAN ARMANDO AGUILAR JUAREZ 01/03/12
// CUBO EN 3D HECHO CON CUADROS NO CON LINEAS
#include <GL/glut.h>
#include <stdlib.h>
void myinit(void)
{
glClearColor(0.0, 1.0, 0.0, 1.0);
glColor3f(0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 600.0, 0.0, 600.0);
glMatrixMode(GL_MODELVIEW);
}
void display( void )
{
typedef GLfloat point2[3];
point2 vertices[8]={{100.0,100.0,0},{200.0,100.0,0},{200.0,200.0,0},{100.0,200.0,0},{100.0,100.0,-100.0},{200.0,100.0,-100.0},{200.0,200.0,-100.0},{100.0,200.0,-100.0}};
glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);

glColor3f(0.0, 0.0, 1.0);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[3]);

glColor3f(0.0, 1.0, 1.0);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[3]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[7]);

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[1]);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[5]);

glColor3f(0.0, 1.0, 0.0);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[3]);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[7]);

glColor3f(1.0, 1.0, 1.0);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[5]);

glEnd();
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600,600);
glutInitWindowPosition(0,0);
glutCreateWindow("Cubo en 3 Dimensiones <60");
glutDisplayFunc(display);
myinit();
glutMainLoop(); }



No hay comentarios:

Publicar un comentario