Imagination PowerVR SDK Blog

FBO and glReadPixels()


#1

Correct pixel values were not acquired by glReadPixels() from framebuffer object.

At first I cleared a color buffer with (1.0, 1.0, 1.0, 1.0) as follows.

  glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
  glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT );
  glBindFramebuffer( GL_FRAMEBUFFER, 0 );

I took out pixel values by glReadPixels() as follows next.

  glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
  glPixelStorei( GL_PACK_ALIGNMENT, 1 );
  const int WIDTH  = 64;
  const int HEIGHT = 1;
  GLubyte pixels[4 * WIDTH * HEIGHT];
  glReadPixels( 0, 0, WIDTH, HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, pixels );
  glBindFramebuffer( GL_FRAMEBUFFER, 0 );

All the elements of pixels should have been 0xFF then, but actually got the following values.

  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

I tested it in Galaxy S (SC-02B Android 2.3.3 GINGERBREAD.OMKE3).

source code: (md5sum=d1b861da715b9890745f6d004c679a4e)
 http://dl.dropbox.com/u/23346852/ticket-701_4/Test701_4-source.zip

APK file: (md5sum=83432dab7d9556e55ab83cb6d401abea)
 http://dl.dropbox.com/u/23346852/ticket-701_4/Test701_4.apk

Screenshot (Galaxy S)
Galaxy%20S

Screenshot (GALAPAGOS 003SH)




#2

Hi,





did you find a solution for this?





Best Regards,


Nicolas


#3

Hi,

Unfortunately I do not yet find this solution. Pinch