title: Android - ICS - Hardware Acceleration steals my OpenGL textures
body: <p>I have an Android app which uses a bit of OpenGL running on a Galaxy Nexus with ICS. After turning on hardware acceleration and using my OpenGL activity some of those textures are stolen by the system and now in my listviews and other UI elements. Its as if my GL pointers obtained via GLES20.glGenTextures are not actually fresh pointers but rather overwriting ones used by the window renderer.</p>
  
  <p>In any case there should be some sort of firewall or sandbox between the OS screen drawing system and my app, no?</p>
  
  <p>Turning off hardwareAcceleration entirely displays fine, but the UI is choppy (and buttery smooth on 2.3 and lower either way). Turning it off/on activity by activity doesn't help either.</p>
  
  <p><strong>Screenshot (before/after)</strong></p>
  
  <p>Normally a repeating bitmap drawable, now an image (from camera in this case) I loaded into OpenGL in a different activity - <a href="http://a.yfrog.com/img532/9245/t81k.png" rel="nofollow">http://a.yfrog.com/img532/9245/t81k.png</a></p>
  
  <p><strong>Gen/Load texture</strong></p>
  
  <pre><code>int[] image = new int[1];
  GLES20.glGenTextures(1, image, 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);
  GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
  </code></pre>
  
  <p><strong>Basic draw</strong></p>
  
  <pre><code>GLES20.glViewport(0, 0, width, height);
  GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
  GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
  GLES20.glUseProgram(shader.program);
  GLES20.glUniform1i(GLES20.glGetUniformLocation(shader.program, "imageTexture"), 0);
  GLES20.glVertexAttribPointer(Attributes.VERTEX, 2, GLES20.GL_FLOAT, true, 0, squareVertices);
  GLES20.glEnableVertexAttribArray(Attributes.VERTEX);
  GLES20.glVertexAttribPointer(Attributes.TEXTUREPOSITON, 2, GLES20.GL_FLOAT, true, 0, textureVertices);
  GLES20.glEnableVertexAttribArray(Attributes.TEXTUREPOSITON);
  GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, image[0]);
  GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
  </code></pre>