我已经创建了这样的一种纹理。
现在根据用户输入,我想用新的
在
public int createTexture(Bitmap bitmap){
final int[] textureHandle = new int[1];
GLES20.glGenTextures(1, textureHandle, 0);
glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
// Load the bitmap into the bound texture.
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
return textureHandle[0];
}
现在根据用户输入,我想用新的
位图
更新我的纹理
。我尝试使用不同的位图
重新调用相同的函数,但它没有被更新。我在这里做错了什么吗?
编辑
我按照Tommy在他的答案中所说的方法尝试过了,但没有用。让我详细说明一下我如何使用纹理。public void changeFilter(){
//create required bitmap here
if(mTextureDataHandle1==0)
mTextureDataHandle1 =loadTexture(bitmap);
else
updateTexture(mTextureDataHandle1);
}
在
onDrawFrame
中 glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, mTextureDataHandle1);
glUniform1i(mTextureUniformHandle1, 1);
updateTexture
会脱离GL线程吗? - Praveena