Código del programa del Cubo
void display(void)
{
typedef GLfloat point2[2];
point2 vertice[8] = {
{100.0,100.0}, //v0
{300.0,100.0}, //v1
{300.0,300.0}, //v2
{100.0,300.0}, //v3
{400.0,200.0}, //v4
{400.0,400.0}, //v5
{200.0,400.0}, //v6
{200.0,200.0}}; //v7
glColor3f(0.0,0.0,1.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);
// glutInitWindowPosition(20, 20);
glutCreateWindow("Cubo 2D");
glutDisplayFunc(display);
glutMainLoop();
}
Corrida del Programa del Cubo
No hay comentarios:
Publicar un comentario