6

Initialization code creates one RGB one-color texture with 128x128 pixels:

GLES20.glGenTextures ( 1, textureId, 0 );
GLES20.glBindTexture ( GLES20.GL_TEXTURE_2D, textureId[0] );
GLES20.glTexImage2D ( GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, bitmap.getWidth(), bitmap.getHeight(), 0,GLES20.GL_RGB, GLES20.GL_UNSIGNED_BYTE, byteBuffer );|
GLES20.glBindTexture ( GLES20.GL_TEXTURE_2D, 0 );

after initialization I have the proper texture and everything works ok. At some poin I have to make some changes in my texture or even replace it completelly with other image:

GLES20.glBindTexture ( GLES20.GL_TEXTURE_2D, textureId[0] );
GLES20.glTexImage2D ( GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, bitmap.getWidth(), bitmap.getHeight(), 0,GLES20.GL_RGB, GLES20.GL_UNSIGNED_BYTE, byteBuffer );|
GLES20.glBindTexture ( GLES20.GL_TEXTURE_2D, 0 );

But glTexImage2D dosen't make any changes to the texture and returns no error. But this code works correctly in my iOS project, but in case of android it doesn't. It looks like I can't use glTexImage2D(..) twice with same texture, in other words, the only way to modify my texture is to create new one and delete old one, but why it's works correctly in iOS? What's wrong with my code?

4

2 回答 2

6

对不起,那是我的错。我试图从其他线程(不是从 GL 线程)调用 glTexImage2D 函数。现在一切都很完美。

于 2012-07-23T10:13:08.400 回答
3

我认为glTexImage2D()用于定义纹理,而glTexSubImage2D()用于重新定义/更新纹理。

您可能只需要切换到 glTexSubImage2D() 即可进行纹理更新。

于 2012-07-23T06:29:33.790 回答