4

I have a shape and I want to view it from different locations decided in the run time. I thought that if I call gluLookAt(...) with the parameters decided, it could change the view location. But, it seems it does not. I guess I should do some refreshing stuff after changing, I tried glFlush().

Any help would be appreciated. Thank you very much in advance.

void Keyboard(unsigned char key, int x, int y)
{
  switch (key)
  {
  case 'w':       
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        gluLookAt(3,2, 0,   0, 0, 0,   0, 10, 0); 
        glFlush();
        break;

  case 's':
      cout<<"s"<<endl;
      break;
  }
}
Sammy
  • 885
  • 3
  • 13
  • 32

1 Answers1

6

OpenGL is not a scene graph, it's just sophisticated "pencil and paper". If you change your scene setup, you've to redraw the full scene.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Thank you for the quick response. Actually when I redraw the full scene, it shows something. But, no matter which position I change to, gluLookat() views the scene from the bottom in a very close way. And when I try those positions in the first place, they look ok, but not at the run time. – Sammy Apr 23 '11 at 13:01
  • The typical OpenGL render pass loos something like this: "glViewport(...); glClear(...); glMatrixMode(GL_PROJECTION); glLoadIdentity(); multiply_projection_matrix(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); multiply_view_matrix(); glPushMatrix(); foreach(o in objects){glPushMatrix(); glMultMatrix(o.transformation); o.draw(); glPopMatrix();} glPopMatrix(); SwapBuffers();" gluLookAt is some variant of mult_view_matrix(); – datenwolf Apr 23 '11 at 13:17