【问题标题】:Lwjgl is changing the color of my texture?Lwjgl 正在改变我的纹理的颜色?
【发布时间】:2016-08-04 18:09:43
【问题描述】:

我正在尝试显示窗口的纹理(在 3d 中) 这是我的代码

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

这是真实的图像:

现在问题来了:lwjgl 或曾经做过什么,完全改变了纹理的颜色? 这就是图像的显示方式:

没有错误,什么都没有。

【问题讨论】:

  • 这是不推荐使用的OpenGL,你应该避免它

标签: java textures lwjgl game-engine


【解决方案1】:

您设置的颜色与图像的颜色相乘。在绘制图像之前将颜色设置为白色:

GL11.glColor3f(1.0, 1.0, 1.0);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-06
    • 2017-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多