title: GL_INVALID_FRAMEBUFFER_OPERATION Android NDK GL FrameBuffer and glReadPixels returns 0 0 0 0
body: <p>My C++ code was designed for iOS and now I ported it to NDK with minimal modifications.</p>
  
  <p>I bind frame buffer and call</p>
  
  <pre><code>glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
  </code></pre>
  
  <p>then I bind main frame buffer like this</p>
  
  <pre><code>glBindFramebuffer(GL_FRAMEBUFFER, 0);
  </code></pre>
  
  <p><code>glGetError()</code> returns <code>GL_INVALID_FRAMEBUFFER_OPERATION</code></p>
  
  <p>I can draw in my framebuffer and use its texture to draw it in main framebuffer. But I when I call <code>glReadPixels</code> then I get zeros</p>
  
  <p>That code worked in iOS and most works in Android except <code>glReadPixels</code></p>
  
  <p><code>glCheckFramebufferStatus(GL_FRAMEBUFFER)</code> returns GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7</p>
  
  <p>--</p>
  
  <p>I will consider sample code that will give me pixels data from framebuffer or texture that I can save to file as an <code>answer</code></p>
  
  <p>Right now I can draw to buffer with attached texture and I can use that texture to draw on main buffer. But I can't get pixels from framebuffer/texture to save to file or post to facebook.</p>