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
| glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// déplace le point de vue (nécessaire en mode perspective)
if (modeProjection == PERSPECTIVE) {
if (loader.fileLoaded)
glTranslatef(0.0,0.0,-loader.maxSize);
else
glTranslatef(0.0,0.0,-25.0);
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glTranslatef(tx, ty, tz); // translation XY de la vue
glColor3f(0.0f,0.0f,0.0f);
// dessine l'origine du repère globale :
dessineRepere();
glPushMatrix(); // sauvegarde la matrice
glLoadIdentity(); // re-init les transformations
// on est maintenant dans le repère local de l'objet
// où l'origine est son centre de gravité
// translation au centre de la tôle
if (loader.fileLoaded){
glTranslatef(loader.center.x, loader.center.y, loader.center.z);
}
glMultMatrixf(rotMatrix); // applique la rotation
// dessine le tracé
if (loader.fileLoaded) {
if (isOnSimulation)
loader.drawSimulation(currentInstruction); // dessine jusque l'instruction courante
else
glCallList(loader.listID); // tracé par liste d'affichage
}
glPopMatrix();
swapBuffer(); |