1
這裏沒有問題能夠提供幫助。我想旋轉一個精靈,一個帶紋理的四邊形,在LWJGL的中心。我想在LWJGL中圍繞它的中心旋轉一個精靈
這是我的代碼,目前,它圍繞其他中心旋轉。
public void draw(int x, int y, int rot) {
//存儲當前模型矩陣 glPushMatrix();
// bind to the appropriate texture for this sprite
texture.bind();
// translate to the right location and prepare to draw
glTranslatef(x, y, 0);
glRotatef(rot,0f,0f,1f);
// draw a quad textured to match the sprite
glBegin(GL_QUADS);
{
texture.bind(); // or GL11.glBind(texture.getTextureID());
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(100,100);
glTexCoord2f(1,0);
glVertex2f(100+texture.getTextureWidth()*2,100);
glTexCoord2f(1,1);
glVertex2f(100+texture.getTextureWidth()*2,100+texture.getTextureHeight()*2);
glTexCoord2f(0,1);
glVertex2f(100,100+texture.getTextureHeight()*2);
glEnd();
}
glEnd();
// restore the model view matrix to prevent contamination
glPopMatrix();
}
你不應該使用任何這些功能。您在此使用的每個OpenGL函數都被棄用。您需要創建頂點數組並管理着色器中的變換。 – Avi 2013-02-23 00:33:52
請等待什麼教程 – 2013-02-23 02:37:55
我不明白你的問題。 – Avi 2013-02-23 03:23:21