title: Record opengl fbo made with c++ with java MediaCodec
body: <p>I'm trying to record the contents of an fbo that i create and fill in c++ 
  with the MediaCodec java object.</p>
  
  <p>I understand that i need to get a Surface from MediaCodec and draw on it
  with a frag shader, so i'm trying to feed the c++ fbo as uniform to the
  shader.</p>
  
  <p>At the moment i can write the video and if i draw all the pixels red with
  the shader i got a red clip, so everything ok on the Shader=>Surface=>MediaCodec side.</p>
  
  <p>To use my fbo i'm passing the GLunit of the texture of the fbo to the 
  java side with a jni function, and everything seems ok, but all i got
  is just noise, like a not initializated texture.</p>
  
  <p>So the question is:
  is in any way possible to use a texture done with c++ as a input uniform
  to a gles2 java shader?</p>
  
  <p>and if yes, what is the correct flow to do so?</p>
  
  <p>To clarify, i'm actually doing this in my GLSurfaceView.Renderer class:</p>
  
  <pre><code>@Override
  public void onSurfaceCreated(GL10 gl, EGLConfig config) {
      Log.i("OF","onSurfaceCreated");
      OFAndroid.onSurfaceCreated();
      try{
          ((OFActivity)OFAndroid.getContext()).onGLSurfaceCreated();
      }catch(Exception e){
          Log.e("OF","couldn call onGLSurfaceCreated",e);
      }
      return;
  }
  
  @Override
  public void onSurfaceChanged(GL10 gl, int w, int h) {
      this.w = w;
      this.h = h;
      if(!setup &amp;&amp; OFAndroid.unpackingDone){
          try {
              setup();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      OFGestureListener.swipe_Min_Distance = (int)(Math.max(w, h)*.04);
      OFGestureListener.swipe_Max_Distance = (int)(Math.max(w, h)*.6);
      OFAndroid.resize(w, h);
  
      mRenderFbo = new RenderFbo(
              800, 800, mSrfTexId);
      mFboTexId = mRenderFbo.getFboTexId();
  
      GlUtil.checkGlError("onSurfaceCreated_E");
  
  }
  
  @Override
  public void onDrawFrame(GL10 gl) {
      if(setup &amp;&amp; OFAndroid.unpackingDone){
          OFAndroid.render();
  
          if (mRenderSrfTex != null) {
              mRenderSrfTex.draw();
          }
          GlUtil.checkGlError("onDrawFrame_E RENDER SRF TEX");
      }else if(!setup &amp;&amp; OFAndroid.unpackingDone){
          try {
              setup();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }else{
          gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
          gl.glClearColor(.5f, .5f, .5f, 1.f);    
      }
  }
  
  public void setRecorder(MyRecorder recorder, int myTexID) {
      texID = myTexID;
      synchronized(this) {
          if (recorder != null) {
              mRenderSrfTex = new RenderSrfTex(
                      800, 804,
                      myTexID, recorder);
          } else {
              mRenderSrfTex = null;
          }
      }
  }
  </code></pre>
  
  <p>where myTexID is the GLUint that i pass from c++ to java with jni, containing the GLUint of the fbo texture.</p>
  
  <p>for reference to the classes myRecorder and RenderSrfTex see the classes at <a href="https://github.com/MorihiroSoft/Android_MediaCodecTest/tree/master/MediaCodecTest18/src/jp/morihirosoft/mediacodectest18" rel="nofollow">https://github.com/MorihiroSoft/Android_MediaCodecTest/tree/master/MediaCodecTest18/src/jp/morihirosoft/mediacodectest18</a></p>
  
  <p>and here the sources of the relevant part of the framework, <a href="https://github.com/openframeworks/openFrameworks/blob/master/addons/ofxAndroid/ofAndroidLib/src/cc/openframeworks/OFAndroidWindow.java" rel="nofollow">https://github.com/openframeworks/openFrameworks/blob/master/addons/ofxAndroid/ofAndroidLib/src/cc/openframeworks/OFAndroidWindow.java</a></p>