Reputation: 143
I'm trying to rotate a object I've made with openGL and LWJGL. My problem is that it does not rotate at all. Here is the code I'm using to draw the object with:
public static void draw() {
if (active) {
tex.bind();
glBegin(GL_QUADS);
glPushMatrix();
glRotatef(rotation, 0, 0, 1);
glTexCoord2f(0, 1);
glVertex2f(x - (WIDTH / 2), y);
glTexCoord2f(1, 1);
glVertex2f(x - (WIDTH / 2) + WIDTH, y);
glTexCoord2f(1, 0);
glVertex2f(x - (WIDTH / 2) + WIDTH, y + HEIGHT);
glTexCoord2f(0, 0);
glVertex2f(x - (WIDTH / 2), y + HEIGHT);
glPopMatrix();
glEnd();
}
}
Upvotes: 3
Views: 1286
Reputation: 473427
glBegin(GL_QUADS);
glPushMatrix();
glRotatef(rotation, 0, 0, 1);
You cannot call any matrix functions between glBegin
and glEnd
. Move them to in front of the glBegin
call.
Upvotes: 2