title: Reading data using glReadPixel() with multisampling
body: <p>Presently I am trying to read the pixel data from the frame Buffer in order to capture the screen in IOS. GlreadPixels command works fine when using the following code to setup frame buffer :-</p>
  
  <pre><code>//buffers
  // Create a depth buffer that has the same size as the color buffer.
  glGenRenderbuffersOES(1, &amp;m_depthRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_depthRenderbuffer);
  glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, width, height);
  
  // Create the framebuffer object.
  
  glGenFramebuffersOES(1, &amp;framebuffer);
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES,
                               GL_RENDERBUFFER_OES, m_colorRenderbuffer);
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES,
                               GL_RENDERBUFFER_OES, m_depthRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);
  </code></pre>
  
  <p>but when I use depth buffer and colorbuffer for Multi-Sampling glreadpixels() don't capture any pixel data as with earlier code ....for multi-sampling I use following code :-</p>
  
  <pre><code>glGenFramebuffersOES(1, &amp;sampleFramebuffer);
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, sampleFramebuffer);
  
  //GLuint sampleColorRenderbuffer;
  glGenRenderbuffersOES(1, &amp;sampleColorRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
  glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_RGBA8_OES, width, height);
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
  
  //glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_RGBA8_OES, width, height);
  //glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
  
  GLuint sampleDepthRenderbuffer;
  glGenRenderbuffersOES(1, &amp;sampleDepthRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, sampleDepthRenderbuffer);
  glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_DEPTH_COMPONENT24_OES, width, height);
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, sampleDepthRenderbuffer);
  //glBindRenderbufferOES(GL_RENDERBUFFER_OES,sampleColorRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, sampleFramebuffer);
  </code></pre>
  
  <p>I use the follwing code to read pixel data :-</p>
  
  <pre><code>CGRect screenBounds = [[UIScreen mainScreen] bounds];
  
  int backingWidth = screenBounds.size.width;
  int backingHeight =screenBounds.size.height;
  
  glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;backingWidth);
  glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;backingHeight);
  NSInteger myDataLength = backingWidth * backingHeight * 4;
  
  buffer= (GLuint *) malloc(myDataLength);
  glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
  </code></pre>
  
  <p>Any idea how to capture correct pixel data with multi-Sampling technique....or Am I doing something wrong? Please guide me in right direction.
  Thanks</p>