View Full Version : Zooming out

05-19-2008, 11:12 AM

I'm having a bit of trouble visualizing the whole camera thing. I get confused between changing the "view" using translatef and gluLookAt...

Right now I'm just trying to draw a cube glWireCube(1.0);, and "zoom out" so that it looks farther away. From my textbook, I understood that if I used translatef(0.0,0.0,-0.5); the effect will be as though I move the cube 0.5 units (pixels?) down the negative z-axis.

I tried the following:

#include <gl/glut.h> // GLUT header file
#include <gl/gl.h> // OpenGL header file

void display() {

void main(int argc, char **argv) {
glutInit(&amp;argc, argv);

But it's cutting out the back of the cube. I don't understand why...

Sorry for this ultra-newbie question. Hopefully, I'll get a feel for this soon enough.

- Canadian0469

Note: I know that I can just increase my viewing volume using
glOrtho(-2, 2, -2, 2, -2, 2);
for example, but I want to know why what I tried above doesn't work. Does it have to do with the initial viewing volume being too small?

05-19-2008, 11:58 AM
Part of your cube is most likely being clipped. If you don't specify the projection matrix it will use the default one which is an orthographic projection in the [-1,1]x[-1,1]x[-1,1] range.
This means that your visible depth ranges from -1 to 1. Translating the cube towards the back causes part of the cube to fall outside of the depth range. These parts will get clipped
and will therefore not be rasterized. Hope this helps.

05-19-2008, 12:01 PM
Thank you so much -NiCo-! That's exactly what I wanted to know!

- Canadian0469