title: Draw to framebuffer object, then blit to primary display (GLES 3.0)
body: <p>I am attempting to create a framebuffer object, and then blit it to the primary display. The purpose of this to to cache a screen shot that I can blit to the display whenever I want without re-rendering the object. I am using Open GLES 3.0 with android NDK. </p>
  
  <p>I created a frame buffer in the normal way.</p>
  
  <pre><code>GLuint framebuffer = NULL;
  glGenFramebuffers( 1, &amp;framebuffer );
  glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
  
  GLuint colorRenderBuffer = NULL;        
  glGenRenderbuffers( 1, &amp;colorRenderbuffer );
  glBindRenderbuffer( GL_RENDERBUFFER, colorRenderbuffer );
  glRenderbufferStorage( GL_RENDERBUFFER, GL_RGBA8, engine-&gt;width, engine-&gt;height );
  glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer );
  
  GLuint depthRenderbuffer = NULL;
  glGenRenderbuffers( 1, &amp;depthRenderbuffer );
  glBindRenderbuffer( GL_RENDERBUFFER, depthRenderbuffer );
  glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, engine-&gt;width, engine-&gt;height );
  glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer );
  
  GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
  if (status != GL_FRAMEBUFFER_COMPLETE) {
      LOGI( "failed to make complete framebuffer object %d", status );
  }
  else {
      LOGI( "Frame buffer is complete." );
  }
  </code></pre>
  
  <p>This works without error. I then am able to edit the frame buffer, successfully.</p>
  
  <pre><code>glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );
  glBindFramebuffer( GL_READ_FRAMEBUFFER, framebuffer );
  
  // Just fill the screen with a color.
  glClearColor( red, green, blue, 255 );
  glClear( GL_COLOR_BUFFER_BIT );
  
  read_pixels( ); //wrapper for glReadPixels. Shows that all pixels in the frame buffer object have the desired color.
  </code></pre>
  
  <p>However, attempting to blit this to the main draw buffer fails.</p>
  
  <pre><code>glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
  glBindFramebuffer( GL_READ_FRAMEBUFFER, framebuffer );
  
  glReadBuffer( GL_COLOR_ATTACHMENT0 );
  
  glBlitFramebuffer( 0, 0, engine-&gt;width, engine-&gt;height, 0, 0, engine-&gt;width, engine-&gt;height, GL_COLOR_BUFFER_BIT, GL_LINEAR );
  
  LOGI("GL error after blit: %d", glGetError()); //no error reported
  
  glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
  glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
  
  read_pixels( engine ); //gives zero'd buffer (wrong result)
  
  eglSwapBuffers( engine-&gt;display, engine-&gt;surface ); //shows a black screen, unless I use glClearColor directly on the primary display buffer.
  </code></pre>