gluPerspective vs gluOrtho2D
Bonjour, pouvez vous m'aider à comprendre la différence entre gluPerspective et gluOrtho2D ?
D'un coté (A), j'arrive à display un png sur mon carré avec :
Code:
1 2 3
| ...
gluPerspective (45.0, (GLfloat)w/(GLfloat)h, 0.1, 100.0f);
... |
mais d'une autre façon (B), je peux afficher autant de carrés que je veux (non texturés malheureusement) avec :
Code:
1 2 3 4 5 6 7 8 9
| ...
GLfloat aspect = (GLfloat)w / (GLfloat)h;
gluOrtho2D(-1.0 * aspect, 1.0 * aspect, -1.0, 1.0);
if (w >= h) {
gluOrtho2D(-1.0 * aspect, 1.0 * aspect, -1.0, 1.0);
} else {
gluOrtho2D(-1.0, 1.0, -1.0 / aspect, 1.0 / aspect);
}
... |
Pour info, voici ma fonction reshape :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| void reshape (int w, int h)
{
if (h == 0)
h = 1; /* To prevent divide by 0 */
glViewport (0, 0, (GLsizei)w, (GLsizei)h); /* GLsizei for non-negative integer # Set the viewport to cover the new window */
glMatrixMode (GL_PROJECTION);
glLoadIdentity (); /* Réinitialise la matrice */
A ou B
glMatrixMode (GL_MODELVIEW); /* Je met la matrice MODEL_VIEW en utilisation courante. */
glLoadIdentity (); /* Je reinitialise la matrice */
glutPostRedisplay (); /* Post re-paint request to activate display() */
} |