I feel like I understand the usage of the modelview matrix and gluLookAt
. That is, by declaring gluLookAt(ex,ey,ez,lx,ly,lz,ux,uy,uz)
, one can easily set up a way to look at a certain point directly.
My question is - since gluLookAt
postmultiplies the current matrix, assuming you load the identity prior to calling gluLookAt
, and the current matrixmode is modelview, what happens if you draw a cube?
So something like this :
glMatrixMode(GL_PERSPECTIVE);
glLoadIdentity();
glFrustum(-5, 5, -5, 5, 15, 150);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 16, 0, 0, 0, 0, 1, 0);
glutSolidCube(1.0);
Where is the cube rendered in world coordinates? For some reason, in this case, it's rendered at the world origin, and you can see it in the viewport - but why? Shouldn't gluLookAt
have modified the modelview matrix with the view rotation and translation? Should't the cube be rendered essentially with the camera inside?