Android: Deciding between SurfaceView and OpenGL (GLSurfaceView)-ThrowExceptions

Exception or error:

Is there a way to decide up front based on the expected complexity of a game/app in the planning phase whether to use regular Canvas drawing in a SurfaceView or to go with OpenGL?

I’ve been playing around with a Canvas and only need 2D movement, and on a fairly new phone I’m getting pretty decent performance with a bunch of primitive objects and a few bitmaps running around the screen on a solid background.

Is it fair to say that if I’m going to be drawing background images and increasing the number of objects being moved and drawn on top of them that I should go straight to OpenGL?

How to solve:

All I can say is that it depends on how many sprites you’re gonna use. Chris Pruett from Google has also documented this part very well.

Google I/O 2009 and Google I/O 2010.

Below is a picture from one of his slides that are related to your topic:
enter image description here

With that knowledge, you should go with OpenGL using the draw_texture extension. Remember to query out the string and check if draw_texture is supported on the actual device.

For further information that are related to game development in general, see this.

###

SurfaceView

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.

OpenGL

OpenGL would be able to handle the rotations and scaling easily.

Honestly, you would probably need to learn a lot of OpenGL to do this,
specifically related to the topics of:

Geometry Lighting (or just disabling it) Picking (selecting geometry
to draw on it) Pixel Maps Texture Mapping Mipmapping Also, learning
OpenGL for this might be overkill, and you would have to be pretty
good at it to make it efficient.

Instead, I would recommend using the graphic components of a game
library built on top of openGL, such as:

Cocos2d

libgdx

Any of the engines listed here

Source

Difference between SurfaceView and GLSurfaceView in Android

Android: Canvas vs OpenGL

Leave a Reply

Your email address will not be published. Required fields are marked *