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?
Sorry, that was my fault. I tried to call glTexImage2D function from other thread (not from GL thread). Now everything works perfect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With