Rotating the Camera Using glRotate*

How I want to rotating the camera around the cube. Let say, the cube at the center. Rotation axis is y-axis. How it works actually ?

ex:
glRotatef(theta,0.0,1.0,0.0);
gluLookAt (viewer[0], viewer[1], viewer[2], xref, yref, zref, Vx, Vy, Vz);

First, set up your “world projection” matrix. (This is a made up name, and doesn’t have an OpenGL equivilant, but is basically the transformation which everything goes through to be converted from object space to world space.) Since you want to do a relatively complex transformation, gluLookAt would be the easiest way:

gluLookAt(cameraPosX,cameraPosY,cameraPosZ,
          viewVectorX,viewVectorY,viewVectorZ,
          upVectorX,upVectorY,upVectorZ);

Next, rotate and translate your cube. Finally, after all this, tell OpenGL to display the cube. Since you want to rotate around the cube, using polar coordiantes would probably be best:

x=cos(theta)*cos(phi);
y=cos(theta)*sin(phi);
z=sin(theta);

or something like that. Theta and phi are just some angle measurements with 0<=theta<360 (0<=theta<2*pi) and 0<=phi<180 (0<=phi<pi). Those are just guidlines though…have fun with it. ^^

[This message has been edited by Nychold (edited 03-09-2004).]

Thanx for replying.
Where I want to put this variables

x=cos(theta)*cos(phi);
y=cos(theta)*sin(phi);
z=sin(theta);

if I am using this command

gluLookAt(cameraPosX,cameraPosY,cameraPosZ,
viewVectorX,viewVectorY,viewVectorZ,
upVectorX,upVectorY,upVectorZ);

Actually, I have to draw the cube but the problem is, to rotate the camera around the cube. Let say, if I press the key left button the camera will move to the left of the cube.

I try to use this command to rotate the camera at y-axis.
glrotatef(theta,0,1,0);
gluLookAt(cameraPosX,cameraPosY,cameraPosZ,
0,0,0,
0,1,0);
I thought, if I increase the value of theta the camera will rotating around the cube.
Is it this command can use to rotating camera around the cube ??