• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# gluLookAt() Performance

## Recommended Posts

I was wondering whether there is a performance benefit of translating and rotating the scene manually over using the above function?

##### Share on other sites
Fruny    1658
Here the code for gluLookAt, from SGI''s Sample Implementation

  void GLAPIgluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz){ int i; float forward[3], side[3], up[3]; GLfloat m[4][4]; forward[0] = centerx - eyex; forward[1] = centery - eyey; forward[2] = centerz - eyez; up[0] = upx; up[1] = upy; up[2] = upz; normalize(forward); /* Side = forward x up */ cross(forward, up, side); normalize(side); /* Recompute up as: up = side x forward */ cross(side, forward, up); __gluMakeIdentityf(&m[0][0]); m[0][0] = side[0]; m[1][0] = side[1]; m[2][0] = side[2]; m[0][1] = up[0]; m[1][1] = up[1]; m[2][1] = up[2]; m[0][2] = -forward[0]; m[1][2] = -forward[1]; m[2][2] = -forward[2]; glMultMatrixf(&m[0][0]); glTranslated(-eyex, -eyey, -eyez);}

So, if you don''t need the normalizations and have combined all you rotations in a single matrix, you MAY be a little faster, otherwise go for simplicity and use gluLookAt().

##### Share on other sites
Thanks I think I''ll stay with gluLookAt().

##### Share on other sites
Maximus    124
I see no problem with just using glTranslatef and glRotatef without matrices

##### Share on other sites
Fruny    1658
quote:
Original post by Maximus
I see no problem with just using glTranslatef and glRotatef without matrices

Gimbal lock ?
Ease of use ?