jueves, 23 de febrero de 2012

CUBO 2D

CALCULOS PARA REALIZAR EL CUBO
 
CODIGO
#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, 400.0, 0.0, 400.0);
glMatrixMode(GL_MODELVIEW);
}

void display( void )
{
typedef GLfloat point2[2];
point2 vertices[8]={{100.0,100.0},{200.0,100.0},{200.0,200.0},{100.0,200.0},{150.0,186.6025},{250.0,186.6025},{250.0,286.6025},{150.0,286.6025}};
glClearColor(1.0, 1.0, 1.0, 0.0);

glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2fv(vertices[0]);
glVertex2fv(vertices[1]);
glVertex2fv(vertices[0]);
glVertex2fv(vertices[3]);
glVertex2fv(vertices[1]);
glVertex2fv(vertices[2]);
glVertex2fv(vertices[2]);
glVertex2fv(vertices[3]);
glVertex2fv(vertices[4]);
glVertex2fv(vertices[5]);
glVertex2fv(vertices[5]);
glVertex2fv(vertices[6]);
glVertex2fv(vertices[6]);
glVertex2fv(vertices[7]);
glVertex2fv(vertices[4]);
glVertex2fv(vertices[7]);
glVertex2fv(vertices[3]);
glVertex2fv(vertices[7]);
glVertex2fv(vertices[2]);
glVertex2fv(vertices[6]);
glVertex2fv(vertices[0]);
glVertex2fv(vertices[4]);
glVertex2fv(vertices[1]);
glVertex2fv(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 2 Dimensiones <60");
glutDisplayFunc(display);
myinit();
glutMainLoop(); }

RESULTADO

No hay comentarios:

Publicar un comentario