Rotating a Quad around it center
- by Trixmix
How can you rotate a quad around its center?
This is what im trying to do but it aint working:
GL11.glTranslatef(x-getWidth()/2, y-getHeight()/2, 0);
GL11.glRotatef(30, 0.0f, 0.0f, 1.0f);
GL11.glTranslatef(x+getWidth()/2, y+getHeight()/2, 0);
DRAW
my main problem is that it renders it off the screen..
draw code:
GL11.glBegin(GL11.GL_QUADS);
{
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(0, 0);
GL11.glTexCoord2f(0, getTexture().getHeight());
GL11.glVertex2f(0, height);
GL11.glTexCoord2f(getTexture().getWidth(), getTexture().getHeight());
GL11.glVertex2f(width,height);
GL11.glTexCoord2f(getTexture().getWidth(), 0);
GL11.glVertex2f(width,0);
}
GL11.glEnd();