mediacodec

Hello, I'm using android's MediaCodec to render a movie to a texture created in Unity. I do this by attaching the texture from Unity to a framebuffer object and then rendering to it using the texture drawn to by android SurfaceTexture. The movie was rendering fine until I switched to Development build and then switched back to Production. Now, the image from SurfaceTexture only shows up when I use Development build.
What changes in terms of OpenGL when I switch to development build? Or am I messing up the gl context somehow?
Below is the native code I call every frame where I think has the highest probability of having errors.
  1. public void DrawFrame() {
  2.  
  3. synchronized(this) {
  4. if (updateSurface) {
  5. //GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
  6. mSurfaceTexture.updateTexImage();
  7.  
  8. mSurfaceTexture.getTransformMatrix(mSTMatrix);
  9. updateSurface = false;
  10.  
  11. Log.d(TAG, "Update texture");
  12.  
  13. } else {
  14. return; //no need to render texture
  15. }
  16. }
  17. //mDecoderAct.onDrawFrame();
  18.  
  19. //bind fbo
  20. GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFBO);
  21.  
  22. //GLES20.glEnable(GLES20.GL_BLEND);
  23. //GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
  24. GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
  25. GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
  26.  
  27. GLES20.glUseProgram(mProgram);
  28. checkGlError("glUseProgram");
  29.  
  30. //texture
  31. GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
  32. GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTexExtOES); //no need to bind, updateTexImage does that. do it anyway
  33. GLES20.glUniform1i(mExtSamplerHandle, 0); //make sure the sampler is bound to the right texture unit
  34. //GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
  35.  
  36. //position
  37. mVertices.position(VERTICES_DATA_POS_OFFSET);
  38. GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
  39. VERTICES_DATA_STRIDE_BYTES, mVertices);
  40. checkGlError("glVertexAttribPointer maPosition");
  41. GLES20.glEnableVertexAttribArray(maPositionHandle);
  42. checkGlError("glEnableVertexAttribArray maPositionHandle");
  43.  
  44. //uv
  45. mVertices.position(VERTICES_DATA_UV_OFFSET); //point to first uv
  46. GLES20.glVertexAttribPointer(maTextureHandle, 3, GLES20.GL_FLOAT, false,
  47. VERTICES_DATA_STRIDE_BYTES, mVertices);
  48. checkGlError("glVertexAttribPointer maTextureHandle");
  49. GLES20.glEnableVertexAttribArray(maTextureHandle);
  50. checkGlError("glEnableVertexAttribArray maTextureHandle");
  51.  
  52. //Combine the projection and camera view matrices
  53. Matrix.multiplyMM(mMVPMatrix, 0, mVMatrix, 0, mMMatrix, 0);
  54. Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0);
  55.  
  56. //Apply the combined projection and camera view transformations
  57. GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
  58. GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
  59.  
  60. GLES20.glViewport(0, 0, mWidth, mHeight);
  61.  
  62. GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
  63. checkGlError("glDrawArrays");
  64.  
  65. //default
  66. GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
  67. GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
  68.  
  69. }
Some notes: mFBO is the framebuffer I render the external texture from SurfaceTexture (mTexExtOES). I've attached the texture from Unity to it and changing the clear color reflects in unity so I know the texture is being rendered to.

이 블로그의 인기 게시물

둘 중 누군가 그녀를 죽였다, 범인 해설

[MAC OS X] mds_stores 100% CPU usage

tips more on unity ...