Original Post
I'm having problems with rotating a sprite in OpenGL. The graphics is set to 2D and I have my own coordinate system management (for several good reasons), which is why I am not translating. The problem is that while rotating, the very z-axis it rotates around itself seems to be located at (0,0). What I want is that it should rotate around the middle of the sprite, meaning it should only rotate and not move from the upper-right corner down to the lower-left corner and then continue rotating outside of the screen the rest of the 270 degrees. Here's the OpenGL code:
glBindTexture(GL_TEXTURE_2D, *texture->getGLTexture());
glPushMatrix();
glRotatef(angle, 0, 0, 1);
glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex3f(x1, y1, 0.0f);
glTexCoord2i(1, 0);
glVertex3f(x2, y1, 0);
glTexCoord2i(1, 1);
glVertex3f(x2, y2, 0);
glTexCoord2i(0, 1);
glVertex3f(x1, y2, 0);
glEnd();
glPopMatrix();
if(angle < 360)
{
angle++;
}
else
{
angle = 0;
}
Help would be appreciated.