Android OpenGL image processing - without SurfaceV

2020-07-14 03:52发布

问题:

I want to do some background image processing using OpenGL ES 2 and shaders, but no drawing to a surface (i.e. off-screen rendering to framebuffers only). While I've already done so on iOS, I'm struggling with this on Android.

I think I'm close to creating a working OpenGL context, but haven't figured out how to do so without a SurfaceView.

回答1:

Have a look at this gamedev post (click on expand to view the complete code). The code creates a GL context and uses the GLSurfaceView.Renderer interface to appropriately allow to write a renderer. On calling getBitmap(), the renderer is called to draw a frame, which is then read back and converted to a Bitmap.

Note that there is a featured question, which might interest you, too.