Author Topic: OpenGL changes in Android 4.2  (Read 2947 times)

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
OpenGL changes in Android 4.2
« on: December 04, 2012, 12:57:50 am »
This is a general OpenGL question not directly related to jPCT but I would like to ask if anyone here is aware of any OpenGL ES1.x changes in Android 4.2 (JellyBean MR1)?

@Egon, did you need to make any modifications for Jellybean compatibility?

I have an app that uses pure OpenGL ES1.1 and the textures are all messed up on multiple 4.2 devices plus the emulator. If I load 5 textures, the last texture loaded is used for all 5 textures, but if I load only 2 textures, those 2 textures render fine. The texture clipping is also not working properly. The whole texture is rendered instead of the clipping region.

I create the textures by:

int[] textures = new int[5];
gl.glGenTextures(5, textures, 0);

Then load an image resource into a byteBuffer and upload it to the GPU:

gl.glBindTexture(GL11.GL_TEXTURE_2D, textures[n])
gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR)     
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_LINEAR)
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, 512, 512,0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, byteBuffer) 

Drawing:

textureCrop0[0] = 0// Left
textureCrop0[1] = 0 // Bottom
textureCrop0[2] = 512// Width
textureCrop0[3] = 512 // Height
gl.glTexParameteriv(GL11.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, textureCrop0, 0)


Were any of these functions changed in 4.2?
            
« Last Edit: December 04, 2012, 01:00:01 am by K24A3 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: OpenGL changes in Android 4.2
« Reply #1 on: December 04, 2012, 07:13:20 am »
None that i'm aware of. jPCT-AE works just fine on 4.2 and 4.2.1 on my Nexus 7.

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: OpenGL changes in Android 4.2
« Reply #2 on: December 04, 2012, 12:17:10 pm »
Finally found the problem, I was loading the image pixels manually pixel by pixel and using a temporary buffer to hold the pixels. Even though I made sure I was freeing and nulling the buffer after each image load, I'm guessing Android was garbage collecting the buffer at some stage causing blank or disordered textures despite using allocateDirect to avoid the GC...

Anyway I use the GLUtil texImage2D now and all is fine. Seems like Google fiddled around with the GC again in 4.2 :p