How to use gluLookAt() to rotate around object created

I’m new to openGl, I am starting on 3d stuff, but can’t get gluLookAt() to work, right now it works by just pressing a button, the “camera” moves , which is fine, I want it to rotate around the object…How would I go about doing this?
Here’s what I have so far. I have attached a text file as they won’t let me paste the code as a new member…

If you refer to the arguments (gluLookAt), you see that you specify three things:

  1. where the eye is
  2. what point it is looking towards
  3. and direction is generally toward “up” in your view

In your case, you already know #2

I’m not sure I get you. I know how to move the camera around a little bit, and that the 0,0,0 is where it will look at, the final 3 values are just the up and down on each axis. But I am confused as to how to get the camera to actual orbit my object.

If you want it to orbit, the first thing you need to do is come up with some formula which gives you the world-space position of the camera at any given time (x,y,z) as a function of time (t). For instance, Parametric Equation of a Circle. Then it’s just a matter of computing the time (e.g. based on system time) and computing the camera position each frame, plug it in, and you’re done.

1 Like