Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mtora · Jun 13, 2014 at 02:53 AM · androidopengldevelopment build

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HarshadK · Jul 23, 2014 at 09:52 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to recover Auto Graphics API for Android back to default? 0 Answers

Extremely Frustrated! How to stop Jaggered Edges ( OpenGL )Android Build? 1 Answer

Troubles with network in development build with Android 0 Answers

after running the app on my android phone, all that appeared was a pink screen. Where did I go wrong????? 1 Answer

OpenGL in UnityPlayerActivity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges