I want to utilize Lionel Brits and nehe''s code in lesson 10 to render a sector of a 3D world. Everything works great, except that instead of using the rotation, translation, and variable management in the original code I want to use gluLookAt which I think is a lot cleaner.
However using gluLookAt seems to mess up the way the vertices are pieced together... Can anyone tell me how I can make this code work. Virtually everything is the same from the original lesson 10 code except I replaced
GLfloat xtrans = -xpos;
GLfloat ztrans = -zpos;
GLfloat ytrans = -walkbias-0.25f;
GLfloat sceneroty = 360.0f - yrot;
glRotatef(lookupdown,1.0f,0,0);
glRotatef(sceneroty,0,1.0f,0);
glTranslatef(xtrans, ytrans, ztrans);
with
float cosYaw = cos_t[(int)xRot];
float sinYaw = sin_t[(int)xRot];
float sinPitch = sin_t[(int)yRot];
float lookx = float(pos.x + cosYaw);
float looky = float(pos.y + sinPitch);
float lookz = float(pos.z + sinYaw);
gluLookAt(pos.x, pos.y, pos.z,
lookx, looky, lookz,
0.0, 1.0, 0.0);
The gluLookAt code works fine with other 3d things I''ve written, like drawing an environment from cubes. What can I do to make it work with this?