/* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Avril 2001 */ /* Illustration de l'utilisation */ /* de la fonction reshape avec GLUt */ #include #include #include void reshape(int w,int l) { glViewport(0,0,w,l); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if ( w > l ) glOrtho((float) -w/l,(float) w/l, -1.0,1.0, -1.0,1.0); else glOrtho(-1.0,1.0, (float) -l/w,(float) l/w, -1.0,1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void display(void) { glClearColor(0.0F,0.0F,0.0F,0.0F) ; glClear(GL_COLOR_BUFFER_BIT) ; glColor3f(1.0F,1.0F,1.0F) ; glBegin(GL_POLYGON) ; glVertex2f(-0.5F,-0.5F) ; glVertex2f(-0.5F,0.5F) ; glVertex2f(0.5F,0.5F) ; glVertex2f(0.5F,-0.5F) ; glEnd() ; glFlush() ; } int main(int argc,char **argv) { glutInit(&argc,argv); glutInitWindowSize(200,200); glutInitWindowPosition(100,100); glutInitDisplayMode(GLUT_RGBA|GLUT_SINGLE); glutCreateWindow("Carre blanc homothetique") ; glutReshapeFunc(reshape) ; glutDisplayFunc(display) ; glutMainLoop() ; return(0); }