Rotating a Quad around it center
Posted
by
Trixmix
on Game Development
See other posts from Game Development
or by Trixmix
Published on 2012-11-16T13:11:56Z
Indexed on
2012/11/16
17:18 UTC
Read the original article
Hit count: 233
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();
© Game Development or respective owner