Codigo Cubo Dos Dimensiones
#include <GL/glut.h>
void reshape (int width,int height)
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,10,0,10,0,10); //valor minimo X y valor maximo y
glMatrixMode(GL_MODELVIEW);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,1,0);
glLoadIdentity();
glBegin(GL_LINE_STRIP);
glVertex2f(0,0);
glVertex2f(5,0);
glVertex2f(5,5);
glVertex2f(0,5);
glVertex2f(0,0);
glVertex2f(2.5,2.5);
glVertex2f(2.5,7.5);
glVertex2f(0,5);
glVertex2f(5,5);
glVertex2f(7.5,7.5);
glVertex2f(2.5,7.5);
glVertex2f(7.5,7.5);
glVertex2f(7.5,2.5);
glVertex2f(5,0);
glVertex2f(7.5,2.5);
glVertex2f(2.5,2.5);
glEnd();
glFlush();
}
void init()
{
glClearColor(0,0,0,0);
}
int main (int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50,50);
glutInitWindowSize(500,500);
glutCreateWindow("Hello");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
No hay comentarios.:
Publicar un comentario