Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Advice on using Allegro 4 or 5?

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Advice on using Allegro 4 or 5?
sec_goat
Member #12,838
May 2011

Hello all,

being a complete novice to allegro, I am wondering if I should be using version 4 or 5? I am having some difficulty with 5, getting it to work on linux, finding examples of how to make certain functions work. However with version 4 I know there are multiple tutorials and examples available.

I feel that I have a pretty good understanding of programming basics, and would like to explore allegro as a tool I use to further my knowledge of programming.

What arguments are there against using the older version versus the newer? I feel like I want to use 5, but I do not want to come in here every day to ask the most basic of questions. Are there some places I can find examples on the allegro functions above and beyond what is in the wiki?

Thanks everyone!

AMCerasoli
Member #11,955
May 2010
avatar

Well, you don't need to see only the Wiki, you can check the Allegro. cc forum, using the search engine (I use to get better result with the google engine), the forum is plenty of new topics about Allegro 5,

What you need to think about it, is that Allegro 5 is the future and Allegro 4 is the past... It's going to happen the same as if you were using and old version of any other software, as you surely already read on the wiki "Allegro 4 is no longer actively developed, but we still apply patches sent to us by contributors, mainly to fix minor bugs."

Allegro 5 has a port to the iPhone and a work-in-progress for Android.

Even when there is a lot of tutorials about Allegro 4 these days, in the future is not going to be the same, practically you're going to have to learn Allegro 5 some day.

Allegro 5 isn't difficult at all, believe me, when I start learning A5 I was a completely newbie, I used Allegro 4 just a little bit, and I have found no problem when I begun to use A5.

So my recommendation is, start learning Allegro 5.

Evert
Member #794
November 2000
avatar

sec_goat said:

I am wondering if I should be using version 4 or 5?

5.

Quote:

I am having some difficulty with 5, getting it to work on linux,

What sort of difficulty?
Getting it to work on Linux, if anything, should be easier than any of the other platforms since most of the developers use Linux. Please post any installation problems or difficulties you run into and they can be looked at and we can give you a pointer in the right direction.
There are some Allegro 5 RPMs as well, they may work on your system.

Quote:

finding examples of how to make certain functions work.

If you download the Allegro source, it comes with an examples/ directory. Many of them are simple tests, but they should still give you a good idea for how to use particular functions. The examples are also linked from the manual pages on allegro.cc (not from the official manual though).

Neil Walker
Member #210
April 2000
avatar

I'd say move to windows and choose XNA instead ;)

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

sec_goat
Member #12,838
May 2011

AMCerasoli: My first thought was to go with 5 as well since 4 is no longer developed or supported. I had used 4 briefly in the past, and I am already liking the function names better in 5, easier for me to keep track of what they do.

Evert said:

Getting it to work on Linux, if anything, should be easier than any of the other platforms since most of the developers use Linux

I am using Lubuntu and I run through the download, and Cmake of source as found on the wiki (http://wiki.allegro.cc/index.php?title=Install_Allegro5_From_SVN/Linux/Debian)
It appears to install just fine, but then I do not know where to go from there. There was a wiki article on linking code::blocks and allegro5 on windows and that worked great. I am not sure how to do the same in linux, and just opening my windows project does not work.

I'd say move to windows and choose XNA instead


I appreciate the advice, but I think I will stick with allegro, it is more cross platform as I understand it. My main machine is windows, I just have a server and laptop running linux and will not be changing that any time soon. What are the merits to XNA over allegro?

Evert
Member #794
November 2000
avatar

sec_goat said:

There was a wiki article on linking code::blocks and allegro5 on windows and that worked great. I am not sure how to do the same in linux, and just opening my windows project does not work.

Ah, well, I don't know how to set it up with an IDE. I can tell you that in order to work out the linker options you run pkg-config --libs allegro-5.0 in a terminal (and similar for each addon). How to get that information in the IDE, however, is up to you to work out.

AMCerasoli
Member #11,955
May 2010
avatar

sec_goat said:

What are the merits to XNA over allegro?

Well... nothing special... just that XNA is supported by a multinational company with multiple devices and the guy who create Allegro (until 1998 IIRC) is working for them... nothing special... ;D , And Allegro is well... a multinational library supported by people all around the world... Which make you life easier, in a lot of platforms...

XNA = Windows, Xbox, Windows Phone 7

Allegro = Windows, Linux, iPhone... And I hope someday Android.

The new Xperia Play Sonic Ericson uses Android. I don't know if Allegro could run in that device. The controls are something special.

If you manage to install Allegro on Linux you can try to run the ex_ogre3d.cpp example... I would like to try it but I'm using Windows, and the file says:

ex_ogre3d, by Peter Wang said:

It currently only works on Linux/GLX. To run, you will need to have OGRE plugins.cfg and resources.cfg files in the current directory.

Ogre3D, is an excellent library, many people say it's so complicated that it's the same of using DirectX directly, though.

PS: The wiki is editable, so if you have lot of trouble installing Allegro 5 on Linux and you feel like no one should pass thru' the same, you could create an article since there is no good article about it... Good Luck!

sec_goat
Member #12,838
May 2011

XNA = Windows, Xbox, Windows Phone 7

I think I will be sticking with allegro as it supports the linux environment, as an avid linux hobbyist I would not want to leave that platform out.

If I can manage to get the darn thing working in linux I will definitely put up a tutorial / walk through on how to do so. and I will also try out the ex_ogre3d.cpp example. I will not give up until I have allegro working on my linux system!

Surt
Member #273
April 2000
avatar

In Code::Blocks put this (plus any addon libs at the end): `pkg-config --libs allegro-5.0`
In Project menu -> Build options... -> Linker settings tab -> Other linker options

---
--
-

weapon_S
Member #7,859
October 2006
avatar

sec_goat said:

My first thought was to go with 5 as well since 4 is no longer developed or supported.

This forum is about the only 'support' available. And as for the development, it gets developed for as much some geek honourable developer still feels like changing something.
For example...
That being said: Allegro 5 is the future.

Disadvantages of 5 over 4:

  • Less examples available. (Ideally this will change. The included manual and example programs should provide examples of very basic function usage. There are already games written in A5 with sources available.)

  • Pixel perfect drawing can be a hassle (So I've heard. There seems to be ways around this.)

  • No MIDI functions (Could be there in the future. A4's routines were allegedly bad.)

  • No support for older Windows, DOS, BEOS[1]. Also support for some compilers was dropped (?) (OMG what a problem ::) )

Advantages of 5 over 4:

  • Everything else ???

Allegro 5 still works on OSX, doesn't it?

References

  1. And some other obscure operating system...?
Edgar Reynaldo
Member #8,592
May 2007
avatar

Allegro 4 has support for fairly fast drawing of memory bitmaps, Allegro 5 does not. So if you want a bitmap larger than the graphics card will give you, then you're kind of screwed and you have to mess around with segmenting it into smaller video bitmaps.

Allegro 4 has much shorter function names where Allegro 5 is getting a little verbose.

Allegro 4 has some support for hardware accelerated drawing, but not nearly as much as Allegro 5.

Allegro 4 has state based input, and Allegro 5 has event based input.

Allegro 4 has support for OpenGL through AllegroGL, and Allegro 5 has support for OpenGL built in.

Elias
Member #358
May 2000

weapon_S said:

Allegro 5 still works on OSX, doesn't it?

Of course. Windows/OSX/Linux are the three main platforms. There's also an iPhone port and the Android port is being worked on (mainly by Thomas right now).

Allegro 4 has support for fairly fast drawing of memory bitmaps, Allegro 5 does not.

Even if you disable blending in A5 / enable blending in A4? The Allegro5 al_draw_bitmap is basically a memcpy() for each line without blending, so it shouldn't be much slower. As for blending, there is no color keying support in A5 so it's of course hard to directly compare. But you can use the RGBA_5551 mode for a very similar effect and with the right blend mode comparable speed (at least the GPX port is using a highly optimized version of the 5551 blitter as far as I know, not sure if that code is used normally, but easy to make it use it if it isn't).

Quote:

Allegro 4 has some support for hardware accelerated drawing, but not nearly as much as Allegro 5.

I'd say except for Windows, it has none at all. Also for OSX it uses some outdated windowing API which usually behaves badly. I remember X-G ported a game to A5 because of that.

Quote:

Allegro 4 has state based input, and Allegro 5 has event based input.

A5 has state based input as well (al_get_mouse_state, al_get_keyboard_state, al_get_joystick_state). Of course relying on them is not a good idea as you lose all state changes between two calls of the function - just like in A4.

--
"Either help out or stop whining" - Evert

sec_goat
Member #12,838
May 2011

I see a lot of good feed back here. Thank you everyone for your input. I am definitely feeling a little more confident about using the new version of allegro for my projects.

weapon_s said:

No MIDI functions (Could be there in the future. A4's routines were allegedly bad.)

More novice questions, if you are not using MIDI for sound what else can you use for sound in your games? I know some of the more "state of the art" games have music / sounds which are definitely not midi, but for the typical dabbler, what other choices are there?

Surt said:

In Code::Blocks put this (plus any addon libs at the end): `pkg-config --libs allegro-5.0`
In Project menu -> Build options... -> Linker settings tab -> Other linker options

This is one of the steps I had tried which seemingly did not work. I now realize there is a different issue, the libraries are there, installed and code blocks has that option, but for whatever reason it is not finding the path. If i type the full path to the allegro.h etc it works (/home/me/allegro/include/allegro5) But I can forsee that not working as soon as it leaves my system. any ideas on how to make code::blocks see the right path? SUDO LDCONFIG does not work as some on the wiki have suggested.

Neil Walker
Member #210
April 2000
avatar

Maybe someone (i.e. I'm lazy so count me out) should create a few tests and compare A4 and A5 using similar code, e.g. bitmap/polygon drawing, etc. then maybe the wiki can say, 'A5 is statistically 32.5% faster than A4' ;)

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Arthur Kalliokoski
Second in Command
February 2005
avatar

A4 already times several things in the test/test.c program, so just write a comparable program in A5. I'm pretty sure A5 would win hands down as long as it wasn't an Intel on-board graphic chip.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

AMCerasoli
Member #11,955
May 2010
avatar

sec_goat said:

if you are not using MIDI for sound what else can you use for sound in your games? I know some of the more "state of the art" games have music / sounds which are definitely not midi, but for the typical dabbler, what other choices are there?

No other than .OGG. Ogg Vorbis is a completely open, patent-free, professional audio encoding and streaming technology with all the benefits of Open Source.

Personally I think it's better than .MP3.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Personally I think it's better than .MP3.

Are you going to lend him your orchestra to record the music?

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

AMCerasoli
Member #11,955
May 2010
avatar

;D My orchestra is another software... I just realize that 80% of things that I'm learning doesn't exist...

Hey I'm a musician,
oh yhea? what instrument do you play?
The PC...
;D

Hear this... I was playing too much Cave Story, and end up producing this... It's all improvisation... It took me 10 min, so it sucks, but I don't know why reminds me the in-game music of Cave Story, maybe beacuse I was trying to get something similar :P.

It isn't quantized...
media player

sec_goat
Member #12,838
May 2011

Are you going to lend him your orchestra to record the music?

I must be missing something, can you only record live instruments to OGG? or is this just a refere3nce to how hard the format is to work with?

Hear this... I was playing too much Cave Story, and end up producing this... It's all improvisation... It took me 10 min, so it sucks, but I don't know why reminds me the in-game music of Cave Story, maybe because I was trying to get something similar

I like the way this sounds, what did you use to make it? Also think you can make something more ambient and space themed? I am going to need a sound track for a future project I am planning for. :P

Elias
Member #358
May 2000

sec_goat said:

I must be missing something, can you only record live instruments to OGG? or is this just a refere3nce to how hard the format is to work with?

.ogg is just like .mp3, only better quality/compression. You can use timidity (or other programs) to convert your .mid files to .ogg.

Allegro 5 also supports MOD (.it/.xm/.s3c/.mod) if you prefer them for some reason.

--
"Either help out or stop whining" - Evert

Vanneto
Member #8,643
May 2007

sec_goat said:

I must be missing something, can you only record live instruments to OGG? or is this just a refere3nce to how hard the format is to work with?

You don't work with the format. You use software to create music / sound and export it to an .ogg file. Then you use that file in your game using Allegro 5. You don't see the internal workings of OGG... So no worries there.

In capitalist America bank robs you.

Surt
Member #273
April 2000
avatar

sec_goat said:

If i type the full path to the allegro.h etc it works (/home/me/allegro/include/allegro5) But I can forsee that not working as soon as it leaves my system.

The simplest solution (presuming you have permissions to do so) is to do a proper system install with a sudo make install which should put the headers in the proper place to be found by the compiler.

---
--
-

Edgar Reynaldo
Member #8,592
May 2007
avatar

sec_goat said:

If i type the full path to the allegro.h etc it works (/home/me/allegro/include/allegro5) But I can forsee that not working as soon as it leaves my system.

You need to add a compiler search directory to your project. Use Menu->Project->BuildOptions, select your main project (not the specific build type) and go to Search Directories->Compiler and add in the directory where you have your allegro headers.

Elias said:

Edgar said:

Allegro 4 has support for fairly fast drawing of memory bitmaps, Allegro 5 does not.

Even if you disable blending in A5 / enable blending in A4? The Allegro5 al_draw_bitmap is basically a memcpy() for each line without blending, so it shouldn't be much slower. As for blending, there is no color keying support in A5 so it's of course hard to directly compare. But you can use the RGBA_5551 mode for a very similar effect and with the right blend mode comparable speed (at least the GPX port is using a highly optimized version of the 5551 blitter as far as I know, not sure if that code is used normally, but easy to make it use it if it isn't).

I did some basic comparisons, running each test for approximately 10 to 15 seconds :

A5, blending enabled, memory source to backbuffer - average 2.24 fps :

#SelectExpand
1 2#include <cstdio> 3 4#include "allegro5/allegro.h" 5 6 7int main(int argc , char** argv) { 8 9 if (!al_init()) { 10 return 1; 11 } 12 if (!al_install_keyboard()) { 13 return 1; 14 } 15 16 al_set_new_display_flags(ALLEGRO_WINDOWED); 17 ALLEGRO_DISPLAY* disp = al_create_display(800,600); 18 if (!disp) {return 1;} 19 20 ALLEGRO_TIMER* timer = al_create_timer(1.0); 21 if (!timer) {return 1;} 22 23 ALLEGRO_EVENT_QUEUE* eq = al_create_event_queue(); 24 if (!eq) {return 1;} 25 26 al_register_event_source(eq , al_get_display_event_source(disp)); 27 al_register_event_source(eq , al_get_timer_event_source(timer)); 28 al_register_event_source(eq , al_get_keyboard_event_source()); 29 30 al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); 31 ALLEGRO_BITMAP* bmp = al_create_bitmap(800,600); 32 if (!bmp) {return 1;} 33 34 al_set_target_bitmap(bmp); 35 al_clear_to_color(al_map_rgb(0,0,0)); 36 37 al_set_target_bitmap(al_get_backbuffer(disp)); 38 39/// al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); 40 41 al_start_timer(timer); 42 43 int fps = 0; 44 int totalfps = 0; 45 int fpscount = 0; 46 bool quit = false; 47 48 while (!quit) { 49 while (!al_is_event_queue_empty(eq)) { 50 ALLEGRO_EVENT ev; 51 al_get_next_event(eq , &ev); 52 if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { 53 quit = true; 54 break; 55 } 56 else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) { 57 if (ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { 58 quit = true; 59 break; 60 } 61 } 62 else if (ev.type == ALLEGRO_EVENT_TIMER) { 63 printf("FPS : %i\n" , fps); 64 totalfps += fps; 65 ++fpscount; 66 fps = 0; 67 } 68 } 69 al_draw_bitmap(bmp , 0 , 0 , 0); 70 ++fps; 71 al_flip_display(); 72 } 73 74 float average = (float)totalfps/(float)fpscount; 75 printf("Average fps : %f\n" , average); 76 77 al_destroy_event_queue(eq); 78 79 return 0; 80}

Uncomment the al_set_blender line above and you get :
A5, blending disabled, memory source to backbuffer - 144.68 fps.

Now draw to a memory bitmap instead of to the backbuffer :
A5, blending enabled, memory source to memory destination - 16.79 fps.

Disable blending and you get :
A5, blending disabled, memory source to memory destination - 353.68 fps.

Now for A4 :

A4, blending enabled using set_alpha_blender and draw_trans_sprite, memory source to screen - 2.58 fps

#SelectExpand
1 2 3#include <cstdio> 4 5#include <allegro.h> 6 7volatile int ticks = 0; 8void Ticker() { 9 ++ticks; 10} 11END_OF_FUNCTION(Ticker); 12 13 14int main(int argc , char** argv) { 15 16 if (allegro_init() != 0) {return 1;} 17 18 if (install_keyboard() != 0) {return 1;} 19 20 if (install_timer() != 0) {return 1;} 21 22 set_color_depth(32); 23 if (set_gfx_mode(GFX_AUTODETECT_WINDOWED , 800 , 600 , 0 , 0) != 0) {return 1;} 24 25 BITMAP* bmp = create_bitmap(800,600); 26 BITMAP* buffer = create_bitmap(800,600); 27 28 clear_to_color(bmp , makeacol(127,127,127,127)); 29 30 if (!bmp || !buffer) {return 1;} 31 32 set_alpha_blender(); 33 34 install_int_ex(Ticker , BPS_TO_TIMER(1)); 35 36 int fps = 0; 37 int totalfps = 0; 38 int fpscount = 0; 39 40 while (!key[KEY_ESC]) { 41 if (ticks) { 42 ticks = 0; 43 printf("FPS : %i\n" , fps); 44 totalfps += fps; 45 ++fpscount; 46 fps = 0; 47 } 48 draw_trans_sprite(screen , bmp , 0 , 0); 49 ++fps; 50 } 51 52 float average = (float)totalfps / (float)fpscount; 53 printf("Average FPS : %f\n" , average); 54 55 return 0; 56} 57END_OF_MAIN()

Change the draw_trans_sprite call to blit and you get :
A4, blending disabled (using blit), memory source to screen - 113.74 fps.

A4, blending enabled , memory source to memory destination - 124.25 fps.

A4, blending disabled , memory source to memory destination - 595.79 fps.

So to sum it all up :

Frames per second                       A5      |         A4
_____________________________________________________________________________
blending enabled, mem->screen  :       2.24     |        2.58
blending disabled, mem->screen :     144.68     |      113.74
blending enabled, mem->mem     :      16.79     |      124.25
blending disabled, mem->mem    :     353.68     |      595.79

So Allegro 5 wins when blitting from memory to screen, but Allegro 4 wins when blitting or blending from memory to memory. It's pretty much a tie when blending from memory to screen, as they're both so slow as to be unusable.

However, Allegro 5 wins when it comes to hardware acceleration, so if all you need to use is video bitmaps then this probably doesn't matter to you.

Neil Walker
Member #210
April 2000
avatar

blending enabled, mem->mem : 16.79 | 124.25

This seems odd. Any reason why?

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Edgar Reynaldo
Member #8,592
May 2007
avatar

Not sure. Here's the exact code to demonstrate it (blending enabled, mem to mem, A5) :

#SelectExpand
1 2#include <cstdio> 3 4#include "allegro5/allegro.h" 5 6 7int main(int argc , char** argv) { 8 9 if (!al_init()) { 10 return 1; 11 } 12 if (!al_install_keyboard()) { 13 return 1; 14 } 15 16 al_set_new_display_flags(ALLEGRO_WINDOWED); 17 ALLEGRO_DISPLAY* disp = al_create_display(800,600); 18 if (!disp) {return 1;} 19 20 ALLEGRO_TIMER* timer = al_create_timer(1.0); 21 if (!timer) {return 1;} 22 23 ALLEGRO_EVENT_QUEUE* eq = al_create_event_queue(); 24 if (!eq) {return 1;} 25 26 al_register_event_source(eq , al_get_display_event_source(disp)); 27 al_register_event_source(eq , al_get_timer_event_source(timer)); 28 al_register_event_source(eq , al_get_keyboard_event_source()); 29 30 al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); 31 ALLEGRO_BITMAP* bmp = al_create_bitmap(800,600); 32 ALLEGRO_BITMAP* buffer = al_create_bitmap(800,600); 33 if (!bmp) {return 1;} 34 35 al_set_target_bitmap(bmp); 36 al_clear_to_color(al_map_rgb(0,0,0)); 37 38 al_set_target_bitmap(buffer); 39 40/// al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); 41 42 al_start_timer(timer); 43 44 int fps = 0; 45 int totalfps = 0; 46 int fpscount = 0; 47 bool quit = false; 48 49 while (!quit) { 50 while (!al_is_event_queue_empty(eq)) { 51 ALLEGRO_EVENT ev; 52 al_get_next_event(eq , &ev); 53 if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { 54 quit = true; 55 break; 56 } 57 else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) { 58 if (ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { 59 quit = true; 60 break; 61 } 62 } 63 else if (ev.type == ALLEGRO_EVENT_TIMER) { 64 printf("FPS : %i\n" , fps); 65 totalfps += fps; 66 ++fpscount; 67 fps = 0; 68 } 69 } 70 al_draw_bitmap(bmp , 0 , 0 , 0); 71 ++fps; 72// al_flip_display(); 73 } 74 75 float average = (float)totalfps/(float)fpscount; 76 printf("Average fps : %f\n" , average); 77 78 al_destroy_event_queue(eq); 79 80 return 0; 81}

I can't debug it properly myself, because I'm using the precompiled binaries and they refer to source code in a different directory than it really is.

 1   2 


Go to: