02-09-2003, 02:43 AM
there is no way to really 'zoom' in OpenGL. The camera stays at 0, 0, 0 looking along the z axis. Everything else moves around it. The best way to zoom out object a is to translate it further away, eg.
glTranslatef(APosX, APosY, APosZ);
glTranslatef(0.0f, 0.0f, -Zoom);
then as zoom increases, the object gets further away
watch out though, anything drawn after that will be 'zoomed' as well.
02-09-2003, 04:00 AM
Actually u can zoom with OpenGL by altering ur viewing matrix using the gluPerspective(..) function.
The actuall function parameter is as follows:
float angle, // the viewable anlge infront of the camera/eye
float aspect, // typically width/height of window or screen
float near, // min distance from camera that is renderable
float far, // max distance from camera that is renderable
To do zooming the first parameter is the one u wnat to alter. The smaller the angle u specify the greater the zoom. Try experimenting and u'll see this in action.
The advantage of using this technique over the one above is that u won't get into a situation where u zoom past an object because u aren't actually repositioning any objects.
The disadvantage is that everytime u want to zoom or animate zooming and zooming out u have to recreate ur perspective viewing transformation. Well this isn't too bad.
I found this on an other forum