Okay Smarties. Need Your Thinking Caps!

Hey Y’all,
I’m in my graphics class this quarter. All is going well until I ran a sample program from the book (i’m running openGL and GLUT on a windows machine). Anyway I run this program and it’s just suppose to give me a static room with a table. It does until you get another window (any window for that matter) anywhere near it and KABAM rotation starts happening. It’s really making me upset and no fun at parties.

Please Help
Kellody

Okay. I’ve narrowed the problem down. It is all caused by gluLookAt. . .

GLfloat ambientLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambientLight);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
glClearColor(0.0f, 0.0f, 00.f,1.0f);

//THIS IS THE LINE OF MY ANGST!!!
gluLookAt(23, 13, 20, 0, .25, 0, 0, 1,0);

Okay. I take gluLookAt out and everything works splendid. I can put any window I want in front of the window and live hapily ever after. With gluLookAt in place the thing rotates into a hellacious abbyss.

Please Help,
Kelly

The problem is that you don’t set your matrix to the identity with glLoadIdentity() before you call your gluLookAt(). Thus, the gluLookAt calls are actually multiplying the current matrix, giving the cumulative rotation effect. The reason that it doesn’t happen until you move another window over your window is because glut is smart and doesn’t redraw your window until it has to.

j

J,
You are my new best friend. That was all it took to make my code work. Thank you!

Kellody