LWJGL 旋转:不会旋转
我正在尝试旋转用 openGL 和 LWJGL 制作的对象。我的问题是它根本不旋转。这是我用来绘制对象的代码:
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();
}
}
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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能调用
glBegin
和glEnd
之间的任何矩阵函数。将它们移至glBegin
调用之前。You cannot call any matrix functions between
glBegin
andglEnd
. Move them to in front of theglBegin
call.