Hello there,
I’m drawing a 3d-scene in a window with very high aspect ratio ( 16 : 3) and I’m trying to figure out how to gain control over the perspective / field of view. I noticed that, when resizing the window, the perspective will change exactly the way I intend to, however, I didn’t succeed in reproducing the effect with opengl calls:
// mouseY for testing
float fov = ofRadToDeg( PI/3.0) - mouseY ;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// mouseX for testing
gluPerspective( fov , float(ofGetWidth())/float(ofGetHeight()+mouseX), 1.0, 5000.0);
glMatrixMode (GL_MODELVIEW);
ofPushMatrix();
ofTranslate(ofGetWidth()*0.5, ofGetHeight()*0.5, 300);
// DRAW 3D SCENE
ofPopMatrix();
The values controlled by mouse only “stretch” the scene like it was a 2d-picture; what I intend to do is really changing the perspective of the scene, which is exactly what happens on resizing the window height.
Could anybody hint me in the right direction or explain to me, how openframeworks handles the perspective from window width and height (or where this calculation takes place in the source)?
Thanks in advance!