Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2D API or OpenGL ES for an Android 2D game?

I'm planning to develop a 2D game for Android devices without a dedicated GPU, like the HTC Wildfire. I remember from the PC that OpenGL is generally to be chosen over something like SDL for 2D graphics because of speed and features.

On Android, there are two APIs for graphics:

  • A "normal" 2D API (does it have a name?)
  • OpenGL ES 2.0

Which one should I favor for a 2D game that should run on Android devices without a dedicated GPU?

like image 947
JRoberts Avatar asked Nov 08 '10 13:11

JRoberts


People also ask

Can I use OpenGL for 2D games?

OpenGL is quite appropriate for 2D games. Although it is generally used for 3D, the same functionality can be used for 2D games. That is to say, anything you can do with 3D OpenGL will be applicable with "2D" OpenGL. Some further information can be found at this location.

What 2D capability does WebGL offer that 2d canvas does not?

What 2D capability does WebGL offer that 2D canvas does not? The biggest one IMHO is the programmable fragment shaders on the graphics hardware. For example, in WebGL, one can implement Conway's Game of Life in a shader on your 3D hardware: This kind of 2D display would only run on the CPU, not the GPU, with a 2D canvas.

Should I use HTML5 canvas or WebGL for my project?

As WebGL is particularly new technology and HTML5 canvas is more established what you want to use depends on your users. If you think that your users will use mobile devices then I would suggest HTML5 canvas but if you want better 2D rendering I would use WebGL.

Can I run WebGL without a GPU?

WebGL is unusable without a GPU. This hardware dependency is not a big problem because most systems have GPUs, but if GPU or CPU architectures ever evolve, preserving webgl content by emulation may be challenging. Running it on old (virtualized) computers is problematic.


1 Answers

Depends on your experience and the scope of the game really, there are benefits and drawbacks for both. I would watch the Chris Pruett Google IO Lectures, they helped me out a lot when I was first getting started with game dev on Android.

Personally I went with OpenGL over the canvas (or "normal" as you called it) since I was familiar with it already. The game I am working on under this approach works pretty well (with threading and being careful of the GC) even on the old myTouch phones.

like image 61
Handsome Avatar answered Oct 20 '22 08:10

Handsome