Android OpenGLES 2.0 Texture Mapping Does Not Work

耗尽温柔 提交于 2019-12-08 14:32:25
jknight

SOLVED: Android OpenGL2.0 showing black textures

NEEDED TO ADD 2 LINES TO LOAD_TEXTURE: GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

Turns out that is required if your texture sizes are not powers of 2.

For anyone who is coming here for the iOS side of this, the other answer provided here also applies. Only difference is the commands are like this:

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Also, make sure that you enable filtering:

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

which I didn't think was so practical in 2D, but you need them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!