RoflFrankoc RoflFrankoc - 4 months ago 19
Java Question

Lwjgl is changing the color of my texture?

I am trying to display a texture of a window (in 3d)
This is my code

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);


This is the real image:

window.png

And now here's the problem: lwjgl or what ever is doing it, is totally changing the color of the texture?
this is how the image get's displayed:

displayed.png

No errors, no nothing.

Answer

The color you set multiplies with the color of your image. Set your color to white before drawing the image:

GL11.glColor3f(1.0, 1.0, 1.0);