So I draw images using vertexes and the like in OpenGL (LWJGL specifically.)
I currently, in this order:
Translate
Rotate
Scale
Draw
Is this the right order? I'm only using 2D coordinates if that changes anything. My code is as follows:
GL11.glPushMatrix();
tex.bind();
enableTexturing();
GL11.glTranslatef(x + (xflip ? tex.getImageWidth() : 0), y + (yflip ? tex.getImageHeight() : 0), 0);
if(rot != 0){
GL11.glTranslatef((tex.getImageWidth() / 2) * xScale, (tex.getImageHeight() / 2) * yScale, 0);
GL11.glRotatef(rot, 0, 0, 1);
GL11.glTranslatef(-(tex.getImageWidth() / 2) * xScale, -(tex.getImageHeight() / 2) * yScale, 0);
}
if(xflip) GL11.glScalef(-1, 1, 1);
if(yflip) GL11.glScalef(1, -1, 1);
if(xScale != 1 || yScale != 1){
if(xScale != 1) GL11.glTranslatef(-tex.getImageWidth() * xScale / 2, 0, 0);
if(yScale != 1) GL11.glTranslatef(0, -tex.getImageHeight() * yScale / 2, 0);
GL11.glScalef(xScale, yScale, 0);
}
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0f, 0f);
GL11.glVertex2f(0, 0);
GL11.glTexCoord2f(tex.getWidth(), 0f);
GL11.glVertex2f(tex.getImageWidth(), 0);
GL11.glTexCoord2f(tex.getWidth(), tex.getHeight());
GL11.glVertex2f(tex.getImageWidth(), tex.getImageHeight());
GL11.glTexCoord2f(0f, tex.getHeight());
GL11.glVertex2f(0, tex.getImageHeight());
GL11.glEnd();
disableTexturing();
GL11.glPopMatrix();