PDA

View Full Version : glLoadIdentity(), glTranslatef()?



02-29-2004, 11:08 PM
I would like to ask what actually glLoadIdentity() and glTranslatef() do?

glLoadIdentity():
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

glTranslatef(Tx, Ty, Tz):
1 0 0 Tx
0 1 0 Ty
0 0 1 Tz
0 0 0 1

If I call glLoadIdentity() and then a glTranslatef(Tx, Ty, Tz), is it actually do:
1 0 0 0 1 0 0 Tx
0 1 0 0 X 0 1 0 Ty
0 0 1 0 0 0 1 Tz
0 0 0 1 0 0 0 1

Thanks!

alantsang
02-29-2004, 11:24 PM
if i am not mistaken
a call to glLoadIdentity will set the current matrix, depending on the modelview top identity and if you follow the glLoadIdentity with glTranslate() it should do a matrix multiplicaion which resulted something like this
1 0 0 Tx
0 1 0 Ty
0 0 1 Tz
0 0 0 1

hopes that i am right. =P

alantsang
02-29-2004, 11:25 PM
how can i edit my old post?? it was 'to' and
'multiplication' not 'top' and 'multiplicaion'.....

Found it, thx

[This message has been edited by alantsang (edited 03-01-2004).]

Nychold
03-01-2004, 07:04 AM
Matrix multiplication: here (http://mathworld.wolfram.com/MatrixMultiplication.html)

Or, you could just do the obvious thing; test it:

float mat[16];
//...
// Transform the Matrix how you see fit
//...
glGetFloatv(GL_MODELVIEW_MATRIX, mat);

Then look at the actual values, and compare them to how they are multiplied. Best way to learn how OpenGL multiplies its matricies is to double check them. ^_~

Edit: And editing your posts is a simple matter of pressing the "modify" button (looks like a sheet of paper with a pencil hovering over it on my system). XD

[This message has been edited by Nychold (edited 03-01-2004).]