gluLookAt()
What's the difference between gluLookAt(...) and glRotatef(xpos,1.0f,0.0f,0.0f);glRotatef(ypos,0.0f,1.0f,0.0f);glRotatef(zpos,0.0f,0.0f,1.0f); and glTranslatef(x,y,z)
"Everything is relative." -- Even in the world of computers.
Edited by - Ionut Costica on 7/26/00 4:34:53 PM
everything is relative. -- even in the world of computers... so PUSH BEYOND THE LIMITS OF SANITY!
There''s almost no difference at all.
Remember that the entire GLU library is only a *utility* library, and so anything that it does can also be done just with the normal gl functions (although some of them are worth it).
Another example is gluPerspective and glFrustum - they''re essentially the same, but with different methods of input. In fact, if you''ve seen the Quake source code, they''ve made a replacement function for gluPerspective so they don''t have to include the library!
In your example with gluLookAt and the translation/rotation functions, it''s probably worth doing it yourself. For instance, in my games, I need compatibility with D3D as well, so I convert to a left-handed coordinate system with the glTranslate funcs.
Another benefit of doing it yourself is that you can save the matrix on the stack with more control. Your game loop might look like this:
glTranslatef(-Camera.x, -Camera.y, -Camera.z);
glRotatef(-Camera.RotX, 1, 0, 0);
... etc.
// Save the matrix
glPushMatrix();
Then, whenever you want to apply the camera matrix, just do this:
glPopMatrix();
glPushMatrix(); // Push it back on for the next time...
I think that pushing/popping is actually quicker than loading it from an array of floats as well, but I''m not sure.
That help?
Remember that the entire GLU library is only a *utility* library, and so anything that it does can also be done just with the normal gl functions (although some of them are worth it).
Another example is gluPerspective and glFrustum - they''re essentially the same, but with different methods of input. In fact, if you''ve seen the Quake source code, they''ve made a replacement function for gluPerspective so they don''t have to include the library!
In your example with gluLookAt and the translation/rotation functions, it''s probably worth doing it yourself. For instance, in my games, I need compatibility with D3D as well, so I convert to a left-handed coordinate system with the glTranslate funcs.
Another benefit of doing it yourself is that you can save the matrix on the stack with more control. Your game loop might look like this:
glTranslatef(-Camera.x, -Camera.y, -Camera.z);
glRotatef(-Camera.RotX, 1, 0, 0);
... etc.
// Save the matrix
glPushMatrix();
Then, whenever you want to apply the camera matrix, just do this:
glPopMatrix();
glPushMatrix(); // Push it back on for the next time...
I think that pushing/popping is actually quicker than loading it from an array of floats as well, but I''m not sure.
That help?
--Mr Smidge
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement