gpt4 book ai didi

java - 纹理未填充整个四边形

转载 作者:行者123 更新时间:2023-12-01 13:40:16 25 4
gpt4 key购买 nike

我已经按照光滑教程的字母配置了大部分内容,但我得到的是左下角的 png,仅填充四边形的 3/4,四边形的尺寸为 100x100,纹理将填充它完全但是由于某种原因我无法让包装工作(帮助!!如果这是我的错误)

注册表代码:

public Form(String fileName, Frame frame) {
try {
texture = TextureLoader.getTexture(
"PNG",
ResourceLoader.getResourceAsStream("img/" + fileName
+ ".png"));
} catch (IOException e) {
e.printStackTrace();
}
this.frame = frame;
VectorFrame = a.constructVectorFrame(frame);
}

渲染代码:

    GL11.glEnable(GL11.GL_TEXTURE_2D);
Color.white.bind();
texture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2d(point.x, point.y);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2d(point.x, point.y + frame.maxY);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2d(point.x + frame.maxX, point.y + frame.maxY);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2d(point.x + frame.maxX, point.y);
GL11.glEnd();
GL11.glDisable(GL11.GL_TEXTURE_2D);

a.renderVectorFrame(point, VectorFrame);

最佳答案

Slick 强制您使用二次方纹理。您有两种方法来处理这个问题:

  • 使用二次方纹理(例如 128x128)
  • 将 glTexCoord2f() 中的 1.0fs 更改为宽度/(2 的最近幂)和高度/(2 的最近幂)

另外,看看这个问题:Texture doesn't stretch properly. Why is this happening?

关于java - 纹理未填充整个四边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20872419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com