daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Oct 31st, 2012 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void GLAPIENTRY
  2. gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx,
  3.           GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy,
  4.           GLdouble upz)
  5. {
  6.     float forward[3], side[3], up[3];
  7.     GLfloat m[4][4];
  8.  
  9.     forward[0] = centerx - eyex;
  10.     forward[1] = centery - eyey;
  11.     forward[2] = centerz - eyez;
  12.        
  13.     up[0] = upx;
  14.     up[1] = upy;
  15.     up[2] = upz;
  16.  
  17.     normalize(forward);
  18.  
  19.     /* Side = forward x up */
  20.     cross(forward, up, side);
  21.     normalize(side);
  22.  
  23.     /* Recompute up as: up = side x forward */
  24.     cross(side, forward, up);
  25.        
  26.     __gluMakeIdentityf(&m[0][0]);
  27.     m[0][0] = side[0];
  28.     m[1][0] = side[1];
  29.     m[2][0] = side[2];
  30.  
  31.     m[0][1] = up[0];
  32.     m[1][1] = up[1];
  33.     m[2][1] = up[2];
  34.  
  35.     m[0][2] = -forward[0];
  36.     m[1][2] = -forward[1];
  37.     m[2][2] = -forward[2];
  38.  
  39.     glMultMatrixf(&m[0][0]);
  40.     glTranslated(-eyex, -eyey, -eyez);
  41. }
RAW Paste Data
Top