问题
I am using the Android mobile platform, with OpenGL ES 2.0.
When I make a texture like so, the textures in my scene draw correctly
//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);
However, I want to be able to scroll a texture, and I believe setting the wrap mode to GLES20.GL_REPEAT would make the needed calculation more possible. However, when using code such as below.
//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);
Every texture is black. The only difference I have made here is the setting of the GLES20.GL_REPEAT parameter name in the call to GLES20.glTexParameteri. This seems really odd. Does anyone have some ideas to share?
I appreciate any help. Thanks.
回答1:
Are the texture sizes powers of two (POT)? If not, there are some limitations on the wrap modes for NPOT textures; only GL_CLAMP_TO_EDGE
is supported in that case, which is what you're seeing.
来源:https://stackoverflow.com/questions/7520445/texture-wrap-mode-repeat-is-not-working