Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro 5 Android high CPU usage

This thread is locked; no one can reply to it. rss feed Print
Allegro 5 Android high CPU usage
kenmasters1976
Member #8,794
July 2007

This is another of my recent Android-related threads. Once I finally set up the tools for building Allegro for Android applications, I've started making some tests with my own code. First thing I noticed was that, while the sample code that clears the screen to different colors 60 times per second has a very low CPU usage, adding a few primitives makes the CPU usage increase dramatically.

Drawing a few primitives can make the emulator use up to 200% CPU (2 full cores). I thought maybe the emulator is not using hardware acceleration but, even on the real tablet, drawing a few hundreds of primitives or only a few dozens of bitmaps can take up to 40% of the CPU.

Granted, I'm using a really old tablet for my tests but still, it seems like a lot of CPU for such a simple test program.

Is this normal on Android devices? I mean, I didn't expect the CPU usage to increase so dramatically by drawing operations.

Frank Drebin
Member #2,987
December 2002
avatar

I don't have much experience on Android-systems but I can tell that the al_draw_pixel and al_put_pixel functions slow down things a lot (as mentioned in the manual) ...

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Sounds like it's using software rendering.

With all your recent experience with setting up Allegro 5 and Android, what is the best guide to follow to get a working allegro program?

I have Android Studio installed, but the NDK might be out of date.

kenmasters1976
Member #8,794
July 2007

I can tell that the al_draw_pixel and al_put_pixel functions slow down things

I'm not using al_draw_pixel(), al_put_pixel() but other primitives like al_draw_rectangle(), al_draw_circle().

With all your recent experience with setting up Allegro 5 and Android, what is the best guide to follow to get a working allegro program?

Hmm... I had a lot of trouble because of the old tablet I was trying to use and for which it took a while to find a solution. Other than that, the instructions in README_android.txt should be easy to follow. In fact, I literally got Allegro to build successfully on the first attempt following those instructions, it was just due to this issue that I had trouble with it.

While fighting with that issue, I also tried other alternatives and this python script also can help in building Allegro as it does it automatically. Even though it seems the script is not meant for the final user, I guess with some simple modifications the script can be an useful way to build Allegro for final users.

Finally, once you have built Allegro, building Allegro programs is also possible without having to launch Android Studio just by setting the corresponding environment variables and using the Android Studio NDK Hello world sample code as a starting point, just as described in README_android.txt.

In general, it's not that hard to use Allegro on Android be it with or without Android Studio.

Go to: