opengl-esopengl-es-2.0glsurfaceviewfbo

OpenGL-ES: Rendered-FBO to GLSurfaceView


I have a Renderer processing an input image in RENDERMODE_WHEN_DIRTY mode (i.e. render once, per request). It simply applies an effect to the input image.

As it required for the result-image to be in the exact same dimensions of the source-image, rendering is performed to an FBO (Frame-Buffer Object), to which a texture is attached - sized exactly as the source. FBO pixels are then read into a Bitmap, saved to a file. So far - so good.

Now, as the result image should also be shown to the user, over a GLSurfaceView - which is usually smaller than the original image, I apply another OpenGL program, using the aforementioned FBO's texture as input texture, which is then scaled to match surface dimensions (while keeping image's original aspect-ratio, by using suitable quad-vertices as input for 2n'd program's Vertex-Shader).

Well, this works well as well, but... seems like a substantial redundant overhead - for such a simple & basic (common) task.

Question: Is there a way to avoid the appliance of another OpenGL-program, just for the sake of showing the FBO to the user? (i.e. to avoid a 2nd rendering, just for resizing an existing FBO/texture to match drawing-surface dimensions)

  1. Could the FBO/texture be projected onto the surface by a simpler manner?
  2. Could the (GLES20.glDrawArrays) rendering be performed to 2 targets at once, each having its own dimensions?
  3. Any other neat & simple solution would be welcomed and appreciated.

Thanks much.


Solution

  • If you need the full resolution image, and this is different than the final on-screen resolution, then no - you can't avoid a second render.