Original Post
I tried searching and couldn't find anything so I figured I'd ask here. When I try to rotate a sprite 180 degrees it of course rotates off of the screen due to that whole ray from the origin concept, I however want it to rotate in place (like the anchor point was in the center of the sprite). I also may want to rotate it in other degrees. Here is the code I have now: Also, if anybody knows how to clean that up, could they let me know? Thanks in advance EDIT: Also I tried taking half the width and height and doing this instead But that did not work either
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureID);
glColor3f(1, 1, 1);
glPushMatrix();
glRotatef(rotate, 0.0, 0.0, 1.0);
glTranslatef(top.x,top.y,0.0f);
glAlphaFunc(GL_GREATER, 0.9f);
glEnable(GL_ALPHA_TEST);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f (0, 0);
glTexCoord2f(1.0f, 0.0f); glVertex2f (abs(top.x - bottom.x), 0);
glTexCoord2f(1.0f, 1.0f); glVertex2f (abs(top.x - bottom.x), abs(top.y - bottom.y));
glTexCoord2f(0.0f, 1.0f); glVertex2f (0, abs(top.y - bottom.y));
glEnd();
glDisable(GL_ALPHA_TEST);
glPopMatrix();
glDisable(GL_TEXTURE_2D);
float wH = abs(top.x - bottom.x) / 2;
float hH = abs(top.y - bottom.y) / 2;
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f (-wH, -hH);
glTexCoord2f(1.0f, 0.0f); glVertex2f (wH, -hH);
glTexCoord2f(1.0f, 1.0f); glVertex2f (wH, hH);
glTexCoord2f(0.0f, 1.0f); glVertex2f (-wH, hH);
glEnd();