Jump to content

  • Log In with Google      Sign In   
  • Create Account

gluLookAt() Performance


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1   Members   

929
Like
Likes
Like

Posted 29 November 2001 - 10:06 AM

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

#2   Moderators   

1654
Like
Likes
Like

Posted 29 November 2001 - 10:17 AM

Here the code for gluLookAt, from SGI''s Sample Implementation

  
void GLAPI
gluLookAt(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().

#3   Members   

929
Like
Likes
Like

Posted 30 November 2001 - 12:21 AM

Thanks I think I''ll stay with gluLookAt().

#4   Members   

124
Like
Likes
Like

Posted 30 November 2001 - 02:09 AM

I see no problem with just using glTranslatef and glRotatef without matrices

#5   Moderators   

1654
Like
Likes
Like

Posted 30 November 2001 - 02:49 AM

quote:
Original post by Maximus
I see no problem with just using glTranslatef and glRotatef without matrices


Gimbal lock ?
Ease of use ?






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.