Search code examples
androidopengl-essurfaceview

Difference between SurfaceView and GLSurfaceView in Android


Can anyone tell me what the basic difference is between SurfaceView and GLSurfaceView? When should I use SurfaceView, and when should I use GLSurfaceView?

I read some already answered questions on Stack Overflow, but they did not satisfy my queries.

Any help would be appreciated.


Solution

  • A GLSurfaceView is a SurfaceView that you can render into with OpenGL. Choosing between them is simple:

    • If you're familiar with OpenGL and need what it provides, use a GLSurfaceView.
    • Otherwise, use a SurfaceView.

    OpenGL is low-level. If you're not already familiar with it, it's an undertaking to learn. If you only need 2D drawing, SurfaceView uses the high-level, reasonably high-performance Canvas. It's very easy to work with.

    Unless you have a strong reason to use a GLSurfaceView, you should use a regular SurfaceView. I would suggest that if you don't already know that you need GL, then you probably don't.