rotation at the specified pivot point

Say if a have a 3d cube drawn up, how do I make it rotate at any point within the cube?
What I mean is is it possible to rotate a cube not about the center, but say, on any specified vertex, or anywhere within the edge of the cube?
If it is possible, which OpenGL commands are needed?
I know glTranslatef & glRotatef’s are needed but everytime I try that, the cube rotation is restricted about the center only. Can’t I move the pivot point elsewhere?

You can move the center of rotation by translating before you rotate. If the world space coordinates of the point you want to rotate around are for example 1,1,1, you want the cube to be rotated around that point around the x axis by 10 degrees and the y axis by 20 degrees, and then have the rotated cube sit at 1.5,1.5,1.5:

glTranslatef(-1.0 ,-1.0 ,-1.0);
glRotatef(10.0, 1.0, 0.0, 0.0);
glRotatef(20.0, 0.0, 1.0, 0.0);
glTranslatef(1.5, 1.5, 1.5);

the first translate command moves the ‘world’, meaning the vertices you specify after the transformations, relative to the viewport by -1,-1,-1 - that means, that the point that was before at 1, 1, 1 is now at 0,0,0 which is the world coordinate origin. Then the rotate commands rotate everything around the coordinate origin, and the last translate command positions everything at your destination position.
It’s pretty straightforward if you look at the fact that all of these commands influence the modelview matrix, with which all subsequently specified vertices will be multiplied with.

Hope that helped

it kinda helped. But my problem is I set up an object with the pivot point which is not at the center and no matter how I use gltranslatef’s & glrotatef’s, the rotation still occurs on the same vertex.
that is, i tried what you suggested:
gTtranslatef(-1, -1, -1);
glRotatef(90,1.0, 1.0, 1.0);
glTranslatef(1, 1, 1);

Just to show whether I’m doing this correctly, I am moving the pivot point from (1,1,1) to (0,0,0), rotating it 90 degrees in the x-direction and then putting the object back at position (1,1,1).

But this code is useless, since it still rotates the object around the edge and not the center of the object.

I hope I described it clearly…

I see the problem.

The line,

glRotatef(90,1.0, 1.0, 1.0);

is not a rotation about the x-axis. What you asked for was a rotation about the (1.0, 1.0, 1.0) axis. What you want is:

glRotatef(90, 1.0, 0.0, 0.0);