You'd need to do something like:
- translate by (-
playerx
-playerwidth
/2, -playery
-playerheight
/2) - rotate by
rotateangle
- translate by (
playerx
+playerwidth
/2,playery
+playerheight
/2)
The idea is to center your sprite on the origin then rotate around the origin (glRotate
) and after you get the rotated sprite you translate it back in its place.
NB: If your sprite is initially "centered" around the origin, but with a corner not the actual center of the sprite, you first translate the object to center the sprite's center with the origin. So like if your sprite had the top-left corner in the origin, you'd translate by (-playerwidth/2, -playerheight/2), then rotate then translate by (playerx,playery).