/* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Septembre 2004 */ /* Un programme OpenGL tout simple */ #include #include #include void scene(void) { glPushMatrix() ; glBegin(GL_POLYGON) ; glVertex2f(-0.5F,-0.5F) ; glVertex2f(-0.5F,0.5F) ; glVertex2f(0.5F,0.5F) ; glVertex2f(0.5F,-0.5F) ; glEnd() ; glPopMatrix() ; } void reshape(int x,int y) { glViewport(0,0,x,y); glMatrixMode(GL_PROJECTION) ; glLoadIdentity() ; glOrtho(-1.0,1.0,(double) -y/x,(double) y/x,-1.0,1.0) ; glMatrixMode(GL_MODELVIEW) ; glLoadIdentity() ; } void display(void) { glClear(GL_COLOR_BUFFER_BIT) ; glPushMatrix() ; scene(); glPopMatrix() ; glFlush(); } int main(int argc,char **argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGBA|GLUT_SINGLE); glutInitWindowSize(200,200); glutInitWindowPosition(50,50); glutCreateWindow("Simple"); glutReshapeFunc(reshape); glutDisplayFunc(display); glutMainLoop(); return(0); }