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();
}
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.