jeudi 15 novembre 2018

Limit fovy in an OpenGL animation

I just wanted to know how can I limit my zoom in/zoom out animation in such a way that the fovy is never exceeded (180 degrees I think), so that the scene does not turn around or do strange things. The code of the animation is the following:

void funSpecial(int key, int x, int y){
    switch(key){
    case GLUT_KEY_UP: zoom+=0.5f; break;
    case GLUT_KEY_DOWN: zoom-=0.5f; break;
    default: zoom=0.0f; break;
    }

    glutPostRedisplay();
}

It controls the value of the global variable GLfloat zoom = 1.0f, which in turn multiplies the value of fovy, declared in the definition of the scene with a value of 60. So it does the effect of zooming to the scene.

Aucun commentaire:

Enregistrer un commentaire