gluLookAt() vs glRotated() and glTranslated()

Why would the following render a cube at the orgin differently?
Note, the results look very similar, the cube has the same size and orientation, but it appears closer to the top of the viewport using the glRotated() and glTranslated() approach.

gluLookAt(1, 1, 1,
          0, 0, 0,
          0, 1, 0);

and

// rotate around the y axis
glRotated(-45, 0, 1, 0);

// rotate around the "rotated" x axis
glRotated(45, cos(radians(45)), 0.0, -sin(radians(45)));

glTranslated(1, 1, 1);

Why would the following render a cube at the orgin differently?

I want to say, becausee it is not the same transformations. :slight_smile:

You have to move the world the the camera origin first. So it should be:

glTranslated(-1, -1, -1);

Sorry, that was a typo.
I am actually using glTranslated(-1, -1, -1)

Just to clarify, I was calling glTranslated() correctly, and I am still having this issue.

I did not looked at the camera orientation computation at first sight but I think you should invert the two glRotated calls:


// rotate around the "rotated" x axis
glRotated(45, cos(radians(45)), 0.0, -sin(radians(45)));

// rotate around the y axis
glRotated(-45, 0, 1, 0);

glTranslated(1, 1, 1);

Assuming signs are correct. But why do you bother with this particular case?