6

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
CSmith
  • 13,318
  • 3
  • 39
  • 42

1 Answers1

4

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.

Community
  • 1
  • 1
Stefan Hanke
  • 3,458
  • 2
  • 30
  • 34
  • This looks of great interest, Thanks! – CSmith Jun 14 '12 at 16:36
  • Actually what I was interested in is directly creating an OpenGL ES 2.0 context and avoiding GLSurfaceView and Renderer altogether ... this didn't quite get me there, though it did allow me to create a context, the GLES20 static class didn't know about it. I support I could use NDK instead to do the off-screen rendering... – CSmith Jun 15 '12 at 13:28
  • The class inside does nothing share with GLSurfaceView except the Renderer interface. You are free to completely abandon GLSurfaceView.Renderer and do you own stuff instead. – Stefan Hanke Jun 15 '12 at 13:40
  • @CSmith Did you ever figure this out? I would like to do the same thing. – Christopher Perry Mar 18 '16 at 04:09
  • This link is no longer functional. Does anyone have a backup or could someone in this thread summarize the content? – Sarthak_ssg5 Jun 20 '23 at 08:53