1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
// init OpenGlDisplay
void myInit() {
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); // mode d'affichage des polygones
glShadeModel(GL_SMOOTH); // modèle d'illumination GL_FLAT
glEnable(GL_DEPTH_TEST); // activation du Z-Buffer
glDepthFunc(GL_LEQUAL); // gestion du Z-Buffer : GL_LESS GL_LEQUAL GL_ALWAYS
glEnable(GL_COLOR_MATERIAL); // active la coloration des objets
glClearColor(0.0f,0.0f,0.0f,1.0f); // couleur du fond de la scène
// --------------------------------
// init de la matrice de projection
// --------------------------------
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // init à la matrice identité
double test = myArea->getMinZ();
glOrtho(myArea->getMinX(),
myArea->getMaxX(),
myArea->getMinY(),
myArea->getMaxY(),
-100, // -myArea->getMaxZ()
100); // -myArea->getMinZ()
// -------------------------
// init de la matrice de vue
// -------------------------
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); // init à la matrice identité
float Xcam = (myArea->getMaxX()-myArea->getMinX())/2.0+myArea->getMinX();
float Ycam = (myArea->getMaxY()-myArea->getMinY())/2.0+myArea->getMinY();
float XlookAt = (myArea->getMaxX()-myArea->getMinX())/2.0+myArea->getMinX();
float YlookAt = (myArea->getMaxY()-myArea->getMinY())/2.0+myArea->getMinY();
gluLookAt(Xcam, // position of the camera X
Ycam, // position of the camera Y
100, // position of the camera Z
XlookAt, // where the camera is going to look at X
YlookAt, // where the camera is going to look at Y
0, // where the camera is going to look at Z
0,
1,
0);
} |
Partager