Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: 2D. OpenGl or android.graphics?

I'm working with my friend on our first Android game. Basic idea is that every frame of the game the whole surface is redrawn (1 large bitmap) in 2 steps:

  1. Background with some static image (PNG) wipes out previous frame
  2. Then it is sprinkled all over with large number of particles which produces effect of soapy bubbles where there's a pool of about 20 bitmaps which randomly gets picked to produce illusion that all bubbles (between 200 - 300) are all different. Bubbles positions updated on each frame (~50ms) producing effect of moving bubbles.

The math engine is in C (JNI) and currently all drawing is done using android.graphics package very similar (since that was the example I was using) to Lunar Lander. It works but animation is somewhat jerky and I can feel by temperature of my phone that it is very busy. Will we benefit from switching to OpenGL? And as a bonus question: what would be a good way to optimize the drawing mechanism (Lunar Lander like) we have now?

like image 595
Bostone Avatar asked May 02 '10 23:05

Bostone


People also ask

Is Android using OpenGL?

The basics. Android supports OpenGL both through its framework API and the Native Development Kit (NDK).

Can OpenGL be used for 2D graphics?

OpenGL (Open Graphics Library) is a cross-platform, hardware-accelerated, language-independent, industrial standard API for producing 3D (including 2D) graphics. Modern computers have dedicated GPU (Graphics Processing Unit) with its own memory to speed up graphics rendering.

Does Android use OpenGL or DirectX?

Android (and iOS as well) doesn't support DirectX but OpenGL ES. Check out 3D with OpenGL on the Android developer site.

What graphics does Android use?

Today large parts of the Android operating system use OpenGL ES 2.0 through components like HWUI, Renderscript, SurfaceTextures, etc. Tablets devices all have high resolution and software simply cannot keep up with the fill rates required to provide a smooth user experience.


1 Answers

Now I've started to work with OpenGL ES, I would also use it for 2D graphics. This way is the most flexible and it's extremely fast (look at this example code. It's about 2D rendering, and there you can see the power of OpenGL.

It's not the easiest thing to start with, but there are some good tutorials out there - for example, this is a very good one.

like image 158
Simon Avatar answered Oct 24 '22 00:10

Simon