0

I'm using NDK on Android with OpenGL ES2.

  1. I create PBuffer surface using eglCreatePbufferSurface with resolution 1024x576. I use GL_RGBA format. 8 bits for each color component.
  2. Load texture from a bitmap and blit it onto the surface. Call glFlush().
  3. Than I create another texture and read the frame buffer into this texture with glCopyTexImage2D. Texture internal format is GL_RGBA.
  4. I blit the new texture onto the same frame buffer again. Call glFlush().
  5. Finally call glReadPixels to read the frame buffer and save it as Bitmap.

The result is pixelated:
sample image

All my textures have these parameters:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Also if I use window surface instead of PBuffer and draw the result on the screen it is correct and not pixelated.
Another thing I tried is to render the original texture to the PBuffer and read pixels from buffer straight away. Without extra pass using glCopyTexImage2D. The result is also correct.

If I change glCopyTexImage2D internal format from GL_RGBA to GL_RGB everything works fine. My PBuffer color space format is RGBA.

Update: My code seems to work fine on the emulator but not on a Nexus 7 device.

So why is it pixelated when I use glCopyTexImage2D with GL_RGBA format?

Lev
  • 730
  • 12
  • 32
  • What is the format of your texture? Result looks alot like texture compression artifacts. – Vasaka Jul 17 '13 at 10:59
  • The image you uploaded is 695x575, not 1024x576. Are you intentionally changing the resolution? At which step (i.e. is it done in GL or by the Bitmap code)? – fadden Jul 17 '13 at 17:30
  • Both texture and PBuffer format is RGBA. I'm not using compression anywhere. Original image resolution is 1024x768. The texture quad I'm drawing is a bit smaller than the buffer to preserve the aspect ratio of the image. I just cut blackness off when saving a screenshot. – Lev Jul 17 '13 at 22:53

0 Answers0