【问题标题】:Texture wrap mode repeat is not working纹理环绕模式重复不起作用
【发布时间】:2017-02-20 19:47:11
【问题描述】:

我使用的是 Android 移动平台,带有 OpenGL ES 2.0。

当我像这样制作纹理时,场景中的纹理会正确绘制

 //Generate there texture pointer
 GLES20.glGenTextures(1, textureHandle, 0);

    // parameters - we have to make sure we clamp the textures to the edges!!!
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_LINEAR);

但是,我希望能够滚动纹理,并且我相信将环绕模式设置为 GLES20.GL_REPEAT 会使所需的计算更加可能。但是,当使用如下代码时。

            //Generate there texture pointer
            GLES20.glGenTextures(1, textureHandle, 0);

    // parameters - we have to make sure we clamp the textures to the edges!!!
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_REPEAT);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_REPEAT);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_LINEAR);

每个纹理都是黑色的。我在这里所做的唯一区别是在对 GLES20.glTexParameteri 的调用中设置了 GLES20.GL_REPEAT 参数名称。这看起来真的很奇怪。有人有什么想法可以分享吗?

感谢您的帮助。 谢谢。

【问题讨论】:

    标签: java android opengl-es opengl-es-2.0


    【解决方案1】:

    纹理大小是 2 的幂(POT)吗?如果不是,则 NPOT 纹理的环绕模式有一些限制;在这种情况下仅支持 GL_CLAMP_TO_EDGE,这就是您所看到的。

    【讨论】:

    • 是的,就是这样。我曾认为这可能是问题所在,但奇怪的是,我的第一次测试似乎违背了原因。但无论如何,你是对的!衷心感谢您!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-08
    • 1970-01-01
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多