【问题标题】:Ideal order of GL_TEXTURE_MIN_FILTER and glTexImage2DGL_TEXTURE_MIN_FILTER 和 glTexImage2D 的理想顺序
【发布时间】:2012-05-10 02:59:12
【问题描述】:

在所有示例中,GL_TEXTURE_MIN_FILTER 和 GL_TEXTURE_MAG_FILTER 总是在调用 glTexImage2D 之前设置。这有什么原因吗?

我知道必须在纹理可用之前设置它们(或者你必须制作 mipmap),但是在 glTexImage2D 之后设置它们有什么问题吗?

例子:

GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GL11.glTexImage2D(target, 0, GL_RGBA8, t_width, t_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureBuffer);

对

GL11.glTexImage2D(target, 0, GL_RGBA8, t_width, t_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureBuffer);
GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, GL_NEAREST);

【问题讨论】:

    标签: opengl


    【解决方案1】:

    不,不应该有任何区别。只有在对纹理进行采样时,这些才应该有任何影响,这要晚得多。

    【讨论】:

    • OpenGL 规范是如何定义它的,曾经有错误的实现,只有在调用 glTexImage 之前设置它们才会尊重纹理参数(尤其是过滤)。这可能是您仍然可以在教程中看到这种模式的主要原因。在现代 OpenGL 中,我们得到了采样器对象,这让我们摆脱了这些问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-14
    • 2020-03-14
    • 2013-12-05
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    相关资源
    最近更新 更多