x = x + xOffset
y = y + yOffset
then do the rotations, and then finally translate back
x = x - xOffset etc
MS Dev MVP
I know that glRotatef rotates around the origin (0,0,0). Now I want to
rotate an object around its own center. Let's say that the object's
center is located at (5,5,0). I should be able to rotate the object
around around the z-axis by first translating the object's center to the
origin, then rotate the object, and then translate the object back to
its original position.
glTranslatef(-5,-5,0); // Put the fixed point at the origin
glRotatef(45,0,0,1); // Rotate 45 degrees around the z-axis
glTranslatef(5,5,0); // Translate back to original position
The problem however, is that due to the first translation, the origin
gets translated too! So the object doesn't get rotated around its own
center but still around the origin! How the heck can I get this working?
Any help is appreciated.