Fitting scene to camera

Hi,

I need to tightly fit a scene to the camera while maintaining the camera direction. How can this be achieved?

Thanx in advance

I’m not sure, but maybe you could send the corners of a bounding box of your scene through glRasterPos3f (?) … this should give the screen coordinates of the corners.

Then you find the rectangle bounding the 3D box on the screen.

Then you scale the scene or zoom (?) by the factor that the rectangle needs to be enlarged to fill the entire screen space.

I’m not sure that this works, just an idea. . .