Android OpenGL2.0 showing black textures

一曲冷凌霜 提交于 2019-11-27 21:36:22
Maurizio Benedetti

This is a quite common issue of texturing on OpenGL ES 2.0 which caused a lot of headache to me in the past.

In OpenGL ES 2.0, in caso of no-power of 2 textures, the wrap mode can only be GL_CLAMP_TO_EDGE.

There are restrictions as well on the filter you can use which can be only GL_NEAREST or GL_LINEAR (in other words no MIPMAPPING)

In simple words, checking you loadtexture function, change these 2 code lines from:

GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                    GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                    GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);

to

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

I hope this fix the problem, let me know :)

Maurizio Benedetti

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