CÓDIGO CUBO EN 2D (ahora de dos dimensiones realmente :S)
#include <glut.h>
void display(void)
{
typedef GLfloat point2[2];
point2 vertice[8] = {
{100.0,100.0}, //vector 0
{300.0,100.0}, //vector 1
{300.0,300.0}, //vector 2
{100.0,300.0}, //vector 3
{400.0,200.0}, //vector 4
{400.0,400.0}, //vector 5
{200.0,400.0}, //vector 6
{200.0,200.0}}; //vector 7
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 2D");
glutDisplayFunc(display);
glutMainLoop();
}
RESULTADOS
No hay comentarios:
Publicar un comentario