Home » Android » graphics – Differences and advantages of SurfaceView vs GLSurfaceView on Android?

graphics – Differences and advantages of SurfaceView vs GLSurfaceView on Android?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m currently playing around with 2D graphics in android and have been using a plain old SurfaceView to draw Drawables and Bitmaps to the screen. This has been working alright, but there’s a little stutter in the sprite movement, and I’m wondering the feasibility to do a real time (but not terrible fast) game with this.

I know GLSurfaceView exists which uses OpenGL, but I’m curious as to the extent to which this makes a difference. Is a plain SurfaceView hardware accelerated, or do I need to use OpenGL? What type of speed difference could I expect from switching to OpenGL, and how much altering of code would it require to switch (the game logic is all in a separate object that provides an ordered array of drawables to the SurfaceView)?

How to&Answers:

As far as I can tell, you have to use openGL to get HW acceleration. But don’t take is for granted and wait for other answers ^^

If it really is the case, the speedup should be quite important. Any 2D application should work at at very least 20 fps (generally less polygons than 3D applications)

it would take a substantial amount of code, but 1) as a first attempt, you could try with only 1 square VBO and change the matrix each time and 2) your rendering seems already quite encapsulated so it should simplify things a lot.

Answer:

SurfaceView is not hardware accelerated in default.
if you want to get HW acceleration
use GLSurfaceView, which use opengl and is hardware accelerated.

Answer:

Hardware acceleration is possible for a regular SurfaceView since 3.0.

http://developer.android.com/guide/topics/graphics/hardware-accel.html