- Home /
Android development build opengl
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.
     public void DrawFrame() {
        
         synchronized(this) {
             if (updateSurface) {
                 //GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
                 mSurfaceTexture.updateTexImage();
  
                 mSurfaceTexture.getTransformMatrix(mSTMatrix);
                 updateSurface = false;
              
                 Log.d(TAG, "Update texture");
              
             } else {
                 return; //no need to render texture
             }
         }
         //mDecoderAct.onDrawFrame();
      
         //bind fbo
         GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFBO);
      
         //GLES20.glEnable(GLES20.GL_BLEND);
         //GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
         GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
         GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
      
         GLES20.glUseProgram(mProgram);
         checkGlError("glUseProgram");
      
         //texture
         GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
         GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTexExtOES); //no need to bind, updateTexImage does that. do it anyway 
         GLES20.glUniform1i(mExtSamplerHandle, 0); //make sure the sampler is bound to the right texture unit
         //GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
      
         //position
         mVertices.position(VERTICES_DATA_POS_OFFSET);
         GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
                 VERTICES_DATA_STRIDE_BYTES, mVertices);
         checkGlError("glVertexAttribPointer maPosition");
         GLES20.glEnableVertexAttribArray(maPositionHandle);
         checkGlError("glEnableVertexAttribArray maPositionHandle");
  
         //uv
         mVertices.position(VERTICES_DATA_UV_OFFSET); //point to first uv
         GLES20.glVertexAttribPointer(maTextureHandle, 3, GLES20.GL_FLOAT, false,
                 VERTICES_DATA_STRIDE_BYTES, mVertices);
         checkGlError("glVertexAttribPointer maTextureHandle");
         GLES20.glEnableVertexAttribArray(maTextureHandle);
         checkGlError("glEnableVertexAttribArray maTextureHandle");
      
         //Combine the projection and camera view matrices
         Matrix.multiplyMM(mMVPMatrix, 0, mVMatrix, 0, mMMatrix, 0);
         Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0);
      
         //Apply the combined projection and camera view transformations
         GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
         GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
      
         GLES20.glViewport(0, 0, mWidth, mHeight);
      
         GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
         checkGlError("glDrawArrays");
      
         //default
         GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
         GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
  
     }
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.
Using Unity Pro 3.5.7f6
Answer by knighthedspi · Jul 23, 2014 at 09:51 AM
Maybe this below link will help you
https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials-video-capturing-for-unity3d-applications?page=2#comment-1794141 Btw, i'm using RenderTexture to get textureID to render a movie.But performance is not good, FPS decreases 20→24 .Can you suggest another solution?
Btw, i'm using RenderTexture to get textureID to render a movie.But performance is not good, FPS decreases 20→24 .Can you suggest another solution?
Rather than adding this in answer, why not make it a separate question? :-)
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                