Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » SFML 2 Vs SDL 1.3/2.0 Vs Allegro 5

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
SFML 2 Vs SDL 1.3/2.0 Vs Allegro 5
Rukiri
Member #14,328
May 2012

I'm pretty proficient with C++ and wanted to get out of the "game engine" trend and decided to just write my own, my choice are sfml 2, sdl 1.3/2.0(practically NO documentation..), and allegro 5.

I do plan on writing a level editor as who likes writing out there maps by hand?

The game I'm creating would work on either 3 libraries as it's C++ at the end of the day, but I'm more focused on the game than low level stuff if I do have to use low level I would integrate DirectX 11 or OpenGL 4.3.

Speaking of DirectX or OpenGL does allegro or the others allow linking to other graphics api's?

I'm pretty against sdl 2.0 mainly because there is no documentation, sfml 2 doesn't have documentation but it's forums are like a beehive and there's plenty of unofficial docs for sfml 2, sdl forums aren't really active and for some reason you can't post either.. how convenient for them.

van_houtte
Member #11,605
January 2010
avatar

Since documentation is pretty important go for the one that is the most well documented option (Allegro 4 had really good documentation, I haven't tried Allegro 5 so I can't say which one to chose for you).

I once tried to learn frameworks, I had about 3 to chose from in a language that I was already very familiar with however the documentation was sporadic and lacking and it required me to read source code, and 1 other framework that was really well documented but in a language that I was not familiar with.

After fighting for 3-4 weeks with the language that I was already very familiar with & undocumented frameworks I switched to the language I did not know but had a really well documented framework and I never looked back. I believe that strong documentation is what makes the programming tools functional to humans.

-----
For assistance, please register and click on this link to PM a moderator

Sometimes you may have to send 3-4 messages

gnolam
Member #2,030
March 2002
avatar

Rukiri said:

I'm more focused on the game than low level stuff if I do have to use low level I would integrate DirectX 11 or OpenGL 4.3.

If you don't want to focus on low-level stuff, then for Eris's sake target an earlier OpenGL version than 4.3 (which when removing the cruft from the OpenGL API went too far and removed pretty much everything convenient).

Quote:

Speaking of DirectX or OpenGL does allegro or the others allow linking to other graphics api's?

All of them provide easy access to OpenGL.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

_Kronk_
Member #12,347
November 2010

I'm using SFML 1.6 (last of the 1.x branch) in my game engine. The API is fairly similar to 2.x from what I've seen. 1.6 has great documentation, so I assume that 2.x is going to have good docs when it's finished. In the meantime, you could use 1.6 if you wanted. It's stupid simple and complies to modern programming paradigms like RAII, OOP, etc.

--------------------------------------------------
"If only our dreams were fires to ignite, then we could let the whole world burn" -Emery

My blog: http://joshuadover.tumblr.com

Evert
Member #794
November 2000
avatar

I don't know about any of the others, but Allegro lets you use D3D or OpenGL directly if you want. On Windows the default backend is D3D, but you can specify that you want OpenGL. You can then very easily port your game over to OS X, Linux, Android or iOS.

Allegro 5's documentation is a bit rough (compared to A4's) but it generally ok (http://alleg.sourceforge.net/api.html). There's also the Wiki, that people are busy adding more documentation and tutorials to (http://wiki.allegro.cc/, it's not quite as organised as it could be, though people are working on that too). There are the examples, that are mostly clear and well-commented. Last but not least, there's these forums where you can always ask questions if you get stuck on something.

If you want the latest stuff (including shaders, multi-touch and more extensive primitives) you should check out the latest 5.1 WIP version (beware: you may contribute to Allegro development by finding bugs), otherwise stick with 5.0.

In the end it's mostly about personal preference which library you use.

AMCerasoli
Member #11,955
May 2010
avatar

You can use Allegro with Ogre3D, in case you want to expand your frontiers.

kazzmir
Member #1,786
December 2001
avatar

SDL 1.3/2.0 is still undergoing API changes which is somewhat annoying to deal with. Allegro5 is a bit more stable.

If you want to post on the SDL forums you have to send an email to the admins and have them add you. Still its a waste of time because no one replies to anything.

jmasterx
Member #11,410
October 2009

Yeah, AL5 has unmatched help and support IMO. Teh Community FTW!

Gnatinator
Member #2,330
May 2002
avatar

First, do you want to write a GAME or an ENGINE? Big difference. Writing a level editor is a huge timesink. Try using one of these: http://www.ludumdare.com/compo/tools/

Nowadays all of these API's are good options and are feature-similar. Your results are primarily going to come down to your own experience more than anything... which you will build by coding lots of projects.

If you're using straight C or C++ as an "Extended C", then Be sure to check out SFML 2's C port. It's far smaller syntactically.

For SDL tutorials check out http://www.lazyfoo.net/SDL_tutorials/

I know this may seem obvious, but for documentation, the respective API references for each library will be invaluable.

Allegro, SDL and SFML can all use OpenGL; I wouldn't recommend doing graphics any other way, even if you're doing 2D. Also you can do top-notch 2D with OpenGL going back to the earliest versions (1.1?).

Trezker
Member #1,739
December 2001
avatar

http://www.codinghorror.com/blog/2007/01/if-it-isnt-documented-it-doesnt-exist.html

If it's true that those other libraries have crappy documentation, then they don't even exist. You have no choice but to use Allegro.

Rukiri
Member #14,328
May 2012

Okay thanks for the tips, and for documentation SFML and Allegro are king.

Specter Phoenix
Member #1,425
July 2001
avatar

SDL has a ton of tutorials showing how to use it. I think Lazyfoo's tutorials are the more popular SDL series out there. Also, while Allegro has documentation, I think most Allegro users look at the included examples and games to see how to use it rather than sifting through the docs. This is where other libraries fail or come up short, they don't have very good examples to look at and pick apart.

"Can't a man even talk to himself without being interrupted?" -Krull(1983)
"Through vengence I was born. Through war I was trained. Through love I was found. Through death I was released. Through release I was given a purpose." -- Specter Phoenix
"Programming == AWESOME the rest is just tools to accomplish it."
END OF LINE

Neil Walker
Member #210
April 2000
avatar

What the A5 documentation needs is to stop treating commands in isolation and specifying the obvious and instead add some context, a user friendly description and an example.

for example:

al_create_event_queue
Create a new, empty event queue, returning a pointer to object if successful. Returns NULL on error.

Yes, hello, means nothing to anybody new.

Instead, why not at the start of every section, e.g. http://alleg.sourceforge.net/a5docs/refman/events.html

Have a description of events and how they work.

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

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

Elias
Member #358
May 2000

True, that sounds like a documentation stub. On al_create_event_queue the example links give you plenty of code to look at though. And to be fair events.html is a quite long read already so even with some functions only documented in brief it already shouldn't be much trouble figuring out how to use them.

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

Thomas Fjellstrom
Member #476
June 2000
avatar

What the A5 documentation needs is to stop treating commands in isolation and specifying the obvious and instead add some context, a user friendly description and an example.

PROMOTED!

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Specter Phoenix
Member #1,425
July 2001
avatar

It may just be my nostalgia, but I liked how the A3 and A4 layout looked compared to A5. That is just my personal preference though.

Don't know why I like this old layout:
{"name":"606090","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/7\/47b4ee85fa3c666e1770e0b6a78c2040.png","w":1366,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/7\/47b4ee85fa3c666e1770e0b6a78c2040"}606090

"Can't a man even talk to himself without being interrupted?" -Krull(1983)
"Through vengence I was born. Through war I was trained. Through love I was found. Through death I was released. Through release I was given a purpose." -- Specter Phoenix
"Programming == AWESOME the rest is just tools to accomplish it."
END OF LINE

Evert
Member #794
November 2000
avatar

Don't know why I like this old layout:

Any particular reason you're using archive.org to access the A4 manual despite it still being available directly on Allegro's homepage?

Too many pastels for my taste anyway, although the A5 manual could probably do with a bit more colour. And more examples, obviously. As always, we accept patches. ;)

Specter Phoenix
Member #1,425
July 2001
avatar

Evert said:

Any particular reason you're using archive.org to access the A4 manual despite it still being available directly on Allegro's homepage?

Didn't know it was still available on the Allegro homepage. When I went there I saw "API--5.1" and assumed it only linked to the new A5 API, so I used archive.org to get it.

Quote:

And more examples, obviously.

Not just examples, but simple examples as most programmers coming to Allegro may see the included examples on the documents and not have a clue what is going on there. I know I've looked at some examples and thought "WTF?!".

"Can't a man even talk to himself without being interrupted?" -Krull(1983)
"Through vengence I was born. Through war I was trained. Through love I was found. Through death I was released. Through release I was given a purpose." -- Specter Phoenix
"Programming == AWESOME the rest is just tools to accomplish it."
END OF LINE

Ashteth
Member #3,310
March 2003
avatar

Just use Allegro 5. The examples are good, the library is good and so is the community.

I haven't tried it yet, but this development course looks rather nice:
2D Game Development Course Using Allegro 5

Specter Phoenix
Member #1,425
July 2001
avatar

Ashteth said:

Just use Allegro 5. The examples are good, the library is good and so is the community.

It's A5 examples that make me say "WTF" to. Of course I'm referring to the Manual examples that were attached to some things. For example, under al_create_bitmap there is an example (ex_bitmap_target.c) and it makes me think "WTF?!" when looking at the code(sorry for the bad format, apparently copy/paste doesn't copy the format from the manual to the forums at all, so I had to manually tweak it or have one long line of code):

#SelectExpand
1/* An example comparing FPS when drawing to a bitmap with the 2 * ALLEGRO_FORCE_LOCKING flag and without. Mainly meant as a test how much 3 * speedup direct drawing can give over the slow locking. */ 4#include <allegro5/allegro.h> 5#include <allegro5/allegro_font.h> 6#include <allegro5/allegro_image.h> 7#include <allegro5/allegro_primitives.h> 8#include <stdio.h> #include <stdarg.h> 9#include <math.h> 10#include "common.c" 11const int W = 300, H = 300; /* Size of target bitmap. */ 12const int RW = 50, RH = 50; /* Size of rectangle we draw to it. */ 13ALLEGRO_DISPLAY *display; 14ALLEGRO_BITMAP *target; /* The target bitmap. */ 15float x, y, dx, dy; /* Position and velocity of moving rectangle. */ 16double last_time; /* For controling speed. */ 17bool quit; /* Flag to record Esc key or X button. */ 18ALLEGRO_FONT *myfont; /* Our font. */ 19ALLEGRO_EVENT_QUEUE *queue; /* Our events queue. */ 20/* Print some text with a shadow. */ 21static void print(int x, int y, char const *format, ...) 22{ 23 va_list list; 24 char message[1024]; 25 va_start(list, format); 26 vsnprintf(message, sizeof message, format, list); 27 va_end(list); 28 al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); 29 al_draw_text(myfont, al_map_rgb(0, 0, 0), x + 2, y + 2, 0, message); 30 al_draw_text(myfont, al_map_rgb(255, 255, 255), x, y, 0, message); 31} 32/* Draw our example scene. */ 33static void draw(void) 34{ 35 float xs, ys, a; 36 double dt = 0; 37 double t = al_get_time(); 38 if (last_time > 0) { 39 dt = t - last_time; 40 } 41 last_time = t; 42 43 al_set_target_bitmap(target); 44 al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); 45 al_draw_filled_rectangle(x, y, x + RW, y + RH, al_map_rgba_f(1, 0, 0, 1)); 46 al_draw_filled_rectangle(0, 0, W, H, al_map_rgba_f(1, 1, 0, 0.1)); 47 x += dx * dt; 48 if (x < 0) { 49 x = 0; 50 dx = -dx; 51 } 52 if (x + RW > W) { 53 x = W - RW; 54 dx = -dx; 55 } 56 y += dy * dt; 57 if (y < 0) { 58 y = 0; 59 dy = -dy; 60 } 61 if (y + RH > H) { 62 y = H - RH; 63 dy = -dy; 64 } 65 66 al_set_target_backbuffer(display); 67 al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); 68 al_clear_to_color(al_map_rgba_f(0, 0, 1, 1)); 69 xs = 1 + 0.2 * sin(t * ALLEGRO_PI * 2); 70 ys = 1 + 0.2 * sin(t * ALLEGRO_PI * 2); 71 a = t * ALLEGRO_PI * 2 / 3; 72 al_draw_scaled_rotated_bitmap(target, W / 2, H / 2, 320, 240, xs, ys, a, 0); 73} 74 /* Run the FPS test. */ 75 static void run(void) { 76 ALLEGRO_EVENT event; 77 int frames = 0; 78 double start; 79 target = al_create_bitmap(W, H); 80 al_set_target_bitmap(target); 81 al_clear_to_color(al_map_rgba_f(1, 1, 0, 1)); 82 al_set_target_backbuffer(display); 83 dx = 81; 84 dy = 63; 85 start = al_get_time(); 86 while (true) { 87 /* Check for ESC key or close button event and quit in either case. */ 88 if (!al_is_event_queue_empty(queue)) { 89 while (al_get_next_event(queue, &event)) { 90 switch (event.type) { 91 case ALLEGRO_EVENT_DISPLAY_CLOSE: 92 quit = true; 93 goto done; 94 case ALLEGRO_EVENT_KEY_DOWN: 95 if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) 96 quit = true; 97 goto done; 98 if (event.keyboard.keycode == ALLEGRO_KEY_SPACE) 99 goto done; 100 break; 101 } 102 } 103 } 104 draw(); 105 print(0, 0, "FPS: %.1f", frames / (al_get_time() - start)); 106 if (al_get_new_bitmap_flags() & ALLEGRO_FORCE_LOCKING) { 107 print(0, al_get_font_line_height(myfont), "using forced bitmap locking"); 108 } else { 109 print(0, al_get_font_line_height(myfont), "drawing directly to bitmap"); 110 } 111 print(0, al_get_font_line_height(myfont) * 2, "Press SPACE to toggle drawing method."); 112 al_flip_display(); 113 frames++; 114 } 115 done: 116 al_destroy_bitmap(target); 117 } 118 int main(void) 119 { 120 if (!al_init()) { 121 abort_example("Could not init Allegro.\n"); 122 return 1; 123 } 124 al_init_primitives_addon(); 125 al_install_keyboard(); 126 al_init_image_addon(); 127 al_init_font_addon(); 128 display = al_create_display(640, 480); 129 if (!display) { 130 abort_example("Error creating display\n"); 131 return 1; 132 } 133 queue = al_create_event_queue(); 134 al_register_event_source(queue, al_get_keyboard_event_source()); 135 al_register_event_source(queue, al_get_display_event_source(display)); 136 myfont = al_load_font("data/font.tga", 0, 0); 137 if (!myfont) { 138 abort_example("font.tga not found\n"); 139 return 1; 140 } 141 while (!quit) { 142 if (al_get_new_bitmap_flags() & ALLEGRO_FORCE_LOCKING) 143 al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); 144 else 145 al_set_new_bitmap_flags(ALLEGRO_FORCE_LOCKING); 146 run(); 147 } 148 al_destroy_event_queue(queue); 149 return 0; 150 }

"Can't a man even talk to himself without being interrupted?" -Krull(1983)
"Through vengence I was born. Through war I was trained. Through love I was found. Through death I was released. Through release I was given a purpose." -- Specter Phoenix
"Programming == AWESOME the rest is just tools to accomplish it."
END OF LINE

Ashteth
Member #3,310
March 2003
avatar

The above example is meant to demonstrate the difference between memory and video bitmaps. It is especially relevant to longtime Allegro 4 users. In Allegro 4, you can pretty much write to bitmaps with reckless abandon. In Allegro 5 if you write to a bitmap you take a hefty performance hit if you don't know what you are doing.

Perhaps a simpler explanation of what the example is trying to demonstrate could be placed at the top of the header.

Specter Phoenix
Member #1,425
July 2001
avatar

I'm not that experienced in C++ and looking at that code I can't tell what the hell it is being done because the variable naming is terrible and I have to try to figure out what variable names mean and what is going on in the example. On top of trying to understand what is going on with the Allegro code. For an experienced programmer I'm sure it all makes sense, but most of our new users are new to programming too and trying A5 for the first time to get met with confusing examples like that.

"Can't a man even talk to himself without being interrupted?" -Krull(1983)
"Through vengence I was born. Through war I was trained. Through love I was found. Through death I was released. Through release I was given a purpose." -- Specter Phoenix
"Programming == AWESOME the rest is just tools to accomplish it."
END OF LINE

Ashteth
Member #3,310
March 2003
avatar

I think its alright if the beginning user can't understand all the examples at first glance. Plenty of the included examples are far more simplistic. To a certain extent, complexity is why I like Allegro. The power is there if you want it. If I want to do raw bitmap manipulation I can. I am, however not required to and I can successfully develop a game without knowing anything about bitmap manipulation.

You are correct however in that this example could use better documentation. Perhaps the examples should come with some sort of rating system. I.E. beginner, intermediate, advanced etc. I am grateful that someone took the time to write all the examples. I myself am too busy developing with Allegro 5 to write examples.

Matthew Leverton
Supreme Loser
January 1999
avatar

I think the API documentation is fine. The n00bs needs a well written, high level book to walk them through everything from A-Z. The wiki articles are fine if you are looking for a single topic, but they always are going to lack the context and continuity that a single-authored book provides.

weapon_S
Member #7,859
October 2006
avatar

Evert said:

As always, we accept patches.

For some reason I thought the documentation source was written in some horrible custom syntax. Instead I see it's written in a very understandable custom(?) syntax. Maybe I'll start making patches ^^ Should I use SVN for that or what?
There definitely are English mistakes, and some entries could refer to a bigger number of appropriate entries.

It's A5 examples that make me say "WTF" to.

In my experience each example contains some extra code that is 'hard' to understand (and irrelevant to the theory of the example), and could use some comments to distinguish.

 1   2   3   4 


Go to: