Utilisation de toute la surface de la fenêtre d'affichage
Utilisation d'une partie seulement de la fenêtre d'affichage
#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <GL/gl.h> #include <GL/glu.h> #include "GL/glaux.h" static int proj = 0 ; static int vp = 0 ; static int vx = 0 ; static int vy = 0 ; static int vdx = 200 ; static int vdy = 200 ; static int ww ; static int hh ; static float anglex = 0.0F ; static float angley = 0.0F ; static float zoomPersp = 1.0F ; static float zoomParal = 1.0F ; static float ouverture = 1.0F ; void projection(void) { if ( vp ) glViewport(0,0,ww,hh); else glViewport(vx,vy,vdx,vdy); if ( proj ) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0*ouverture,(double) ww/hh,0.5,200.0); glMatrixMode(GL_MODELVIEW); glTranslatef(0.0F,0.0F,-5.0F*zoomPersp); } else { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2.5*zoomParal,2.5*zoomParal,-2.5*zoomParal*(double) hh/ww,2.5*zoomParal*(double) hh/ww,-25,25); glMatrixMode(GL_MODELVIEW); glTranslatef(0.0F,0.0F,-5.0F); } } void CALLBACK display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glPushMatrix(); glColor3f(1.0F,1.0F,1.0F); projection(); glPushMatrix(); glRotatef(anglex,1.0F,0.0F,0.0F); glRotatef(angley,0.0F,1.0F,0.0F); glTranslatef(-1.0F,0.0F,0.0F) ; float jaune[] = { 1.0F,1.0F,0.0F }; glMaterialfv(GL_FRONT,GL_DIFFUSE,jaune); auxSolidCube(2.0); glTranslatef(2.0F,0.0F,0.0F) ; float bleu[] = { 0.0F,0.0F,1.0F }; glMaterialfv(GL_FRONT,GL_DIFFUSE,bleu); auxSolidSphere(1.3); glPopMatrix(); glPopMatrix(); glFlush(); auxSwapBuffers() ; } void CALLBACK myinit(void) { glShadeModel(GL_SMOOTH); glDepthFunc(GL_LESS) ; glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } void CALLBACK myReshape(int w, int h) { ww = w ; hh = h ; } void CALLBACK keyo(void) { ouverture *= 1.01F ; ouverture *= 1.01F ; } void CALLBACK keyO(void) { ouverture /= 1.01F ; ouverture /= 1.01F ; } void CALLBACK keyz(void) { zoomPersp *= 1.01F ; zoomParal *= 1.01F ; } void CALLBACK keyZ(void) { zoomPersp /= 1.01F ; zoomParal /= 1.01F ; } void CALLBACK keyP(void) { proj++; proj %= 2; } void CALLBACK keyp(void) { proj++; proj %= 2; } void CALLBACK keyV(void) { vp++; vp %= 2; } void CALLBACK keyv(void) { vp++; vp %= 2; } void CALLBACK keyX(void) { vx++ ; } void CALLBACK keyx(void) { vx-- ; } void CALLBACK keyY(void) { vy++ ; } void CALLBACK keyy(void) { vy-- ; } void CALLBACK keyA(void) { vdx++ ; } void CALLBACK keya(void) { vdx-- ; } void CALLBACK keyB(void) { vdy++ ; } void CALLBACK keyb(void) { vdy-- ; } void CALLBACK up(void) { anglex++ ; } void CALLBACK down(void) { anglex-- ; } void CALLBACK left(void) { angley++ ; } void CALLBACK right(void) { angley-- ; } void main(void) { auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA|AUX_DEPTH); auxInitPosition(0,0,200,200); auxInitWindow("Visualisations"); myinit(); auxKeyFunc(AUX_X,keyX); auxKeyFunc(AUX_x,keyx); auxKeyFunc(AUX_Y,keyY); auxKeyFunc(AUX_y,keyy); auxKeyFunc(AUX_A,keyA); auxKeyFunc(AUX_a,keya); auxKeyFunc(AUX_B,keyB); auxKeyFunc(AUX_b,keyb); auxKeyFunc(AUX_O,keyO); auxKeyFunc(AUX_o,keyo); auxKeyFunc(AUX_V,keyV); auxKeyFunc(AUX_v,keyv); auxKeyFunc(AUX_P,keyP); auxKeyFunc(AUX_p,keyp); auxKeyFunc(AUX_Z,keyZ); auxKeyFunc(AUX_z,keyz); auxKeyFunc(AUX_UP,up) ; auxKeyFunc(AUX_DOWN,down) ; auxKeyFunc(AUX_LEFT,left) ; auxKeyFunc(AUX_RIGHT,right) ; auxReshapeFunc(myReshape); auxMainLoop(display); }
RETOUR