Hiya. I have a problem where after using gluLookAt to orient a texture projection in a scene, on subsequent calls of gluLookAt, the texture is projected according to the new coordinates. I want to leave the projection as it is but be able to look around the scene with gluLookAt.
void renderPrimitive(int width, int height)
{
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5, 0.5, 0);
glScalef(0.5, 0.5, 1);
glOrtho (-15.0f*width/height, 15.0f*width/height, -15.0f, 15.0f, -100.0f, 100.0f);
gluLookAt(0.0, 0.0, 0.0,
0.0, 0.0, -1.0,
0.0, 1.0, 0.0);
GLfloat Splane[] = {1.f, 0.f, 0.f, 0.f};
GLfloat Tplane[] = {0.f, 1.f, 0.f, 0.f};
GLfloat Rplane[] = {0.f, 0.f, 1.f, 0.f};
GLfloat Qplane[] = {0.f, 0.f, 0.f, 1.f};
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, Splane);
glEnable(GL_TEXTURE_GEN_S);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_T, GL_EYE_PLANE, Tplane);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_R, GL_EYE_PLANE, Rplane);
glEnable(GL_TEXTURE_GEN_R);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_Q, GL_EYE_PLANE, Qplane);
glEnable(GL_TEXTURE_GEN_Q);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 0.0,
5.0, 0.0, -60.0,
0.0, 1.0, 0.0);
glBegin(GL_QUADS);
glVertex3f(-15.0f*width/height, -15.0f, -90.0f);
glVertex3f(15.0f*width/height, -15.0f, -90.0f);
glVertex3f(15.0f*width/height, 15.0f, -90.0f);
glVertex3f(-15.0f*width/height, 15.0f, -90.0f);
glEnd();
glColor3f(.0f, 1.0f, 0.0f);
DrawObject(x, y, -60.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glDisable( GL_TEXTURE_2D );
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, width, height);
gluPerspective(20, width/height, 1, 1000);
glMatrixMode(GL_MODELVIEW);