2016-08-04 36 views
0

我想顯示一個窗口的紋理(三維) 這是我的代碼Lwjgl正在改變我的紋理的顏色?

try { 
     texture = TextureLoader.getTexture("PNG", new FileInputStream(new File("res\\window.png"))); 
    } catch (FileNotFoundException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    GL11.glEnable(GL11.GL_TEXTURE_2D); 
    texture.bind(); 
    GL11.glBegin(GL11.GL_QUADS); 
    GL11.glTexCoord2f(0, 0); 
    GL11.glVertex3f(0, 0, 0); 
    GL11.glTexCoord2f(1, 0); 
    GL11.glVertex3f(10, 0, 0); 
    GL11.glTexCoord2f(1, 1); 
    GL11.glVertex3f(10, 10, 0); 
    GL11.glTexCoord2f(0, 1); 
    GL11.glVertex3f(0, 10, 0); 
    GL11.glEnd(); 
    GL11.glDisable(GL11.GL_TEXTURE_2D); 

這纔是真正的形象:

window.png

而現在這裏的問題:LWJGL或者是在做什麼,都會徹底改變質地的顏色? 這是圖像獲取的顯示方式:

displayed.png

沒有錯誤,什麼都沒有。

+0

這是過時的OpenGL,您應該避免它 – elect

回答

0

您設置的顏色與圖像的顏色相乘。在繪製圖像之前將您的顏色設置爲白色:

GL11.glColor3f(1.0, 1.0, 1.0);