dynamically resizing viewport according to 3d drawing

hi guys!

suppose i have a cube, look it at the front, so i see a rectangle. Then i glRotate it in order to have an isometric view. What happened? some of the drawing went out of my viewport.
Question :
How can i automate resizing of the viewport to make all of the scene in the viewport?

(was it silly?)
Thanks.

See if all objects are within the viewing frustum.

You can either project vertices with gluProject (or bounding box)and see if they all lie inside the viewport. The problem here is what to do next if object is outside. You can move back or rotate to look at the object. Depends on you!

The second way is to test if all vertices (or bounding box) are inside the frustum volume.

Originally posted by holyburak:
suppose i have a cube, look it at the front, so i see a rectangle. Then i glRotate it in order to have an isometric view. What happened?

What projection are you using? Remember, perspective projections don’t preserve line lenghts. Maybe you want an isometric projection? Where all lines that are equal in world space are equal in 2d(I think this was isometric).