Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Benchmark: Allegro and SDL

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Benchmark: Allegro and SDL
Rodrigo Monteiro
Member #4,373
February 2004
avatar

I think that it should also be mentioned that Allegro is essentially public domain while SDL is LGPL. I've also considered many times using SDL, simply because I prefer using OpenGL, anyway, and don't need the vast majority of Allegro's functions... I just haven't managed to take that step yet. :)

[EDIT] Besides, Allegro has the Speedhack... that alone should be worth it, right?

_____________________________
a.k.a amz, a.k.a. ArchMage ZeratuL
[Aegisub] - [TINS05: Lord of the Stars] [SH05: Bunkermaster] [SH07: Fury of the Sky God] [TINS08: All Yar Base Arr Belong To Us (with codnik)] [SH09: Xtreme Programming: The Literal Game]

Vanneto
Member #8,643
May 2007

Whats wrong with the LGPL? You dont have to include the license if your program is closed source. You can sell your program. LGPL FTW!

P.S. Still, no license is better than any license :P

In capitalist America bank robs you.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

P.S. Still, no license is better than any license :P

No licence means its 100% proprietary, and no one is technically aloud to use, or distribute it.

A licence is just an "easy" way of giving broad permission to "people" to use and/or distribute your work.

--
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

Richard Phipps
Member #1,632
November 2001
avatar

I'm now using PTK instead of Allegro, and even though it's a bit buggy and I'm not that fond of the API, it gives me all the basics needed and hardware acceleration (via OpenGL or DirectD3D).

Thomas Harte
Member #33
April 2000
avatar

I'm about to run for a train, so no time to post at length. Apologies for that, keep in mind that I'm not being deliberately short.

Quote:

Re: Not use 100% CPU
That was just a test to see how it performed under pressure. Obviously I don't use 100% CPU for games most of the time.

Oh, I didn't mean the example specifically. It's clearly meant to be a stress test, so 100% CPU is appropriate.

Quote:

SDL_image forces me to include a whole JPEG library.

No it doesn't. It can load the LibJPEG (or whatever its called) DLL at runtime, and simply not load JPEGs if the DLL isn't present.

Quote:

Okay, I'm wondering what else needs to be done to prevent a 100% CPU usage outside of using rest(1).

Implementations vary, but the basic idea is that you either (a) use a vsync that sleeps properly (Allegro's may work, it's written in such a way that it may also silently fail); or (b) apply some simple timing logic.

You know how many FPS your game is supposed to work at. So you can work out how long each frame should take. You can also use timing to work out how long each frame has taken. And you can use rest to sleep for the number of milliseconds you specify. So you don't need to use 100% CPU.

We discussed this quite loudly recently, and opinions clearly vary, but for 'pure Allegro' (i.e. no extra libraries), I like this:

1unsigned my_timer_var;
2my_timer_func() {my_timer_var++;}
3 
4...
5int FPS_I_WANT = <whatever>;
6 
7install_timer_bps(my_timer_func, FPS_I_WANT * 4);
8...
9 
10...
11unsigned framestart = my_timer_var = 0;
12 
13while(in_game_loop)
14{
15 process_logic();
16 draw_frame();
17 
18 unsigned time_taken = my_timer_var - framestart;
19 if(framestart < 4)
20 {
21 rest( ((4 - framestart) * 250) / FPS_I_WANT); // converts from units of FPS_I_WANT*4 per second to 1000ths per second, i.e. milliseconds
22 framestart += 4;
23 }
24 else
25 {
26 if(framestart < 8)
27 {
28 skip next frame;
29 framestart += 4;
30 }
31 else
32 {
33 we're too slow, just jump up to date
34 skip next frame;
35 framestart = my_timer_var;
36 }
37 }
38}

Apologies, the above is just typed from the top of my mind, it isn't thoroughly checked.

Neil Walker
Member #210
April 2000
avatar

I haven't read every message and don't know SDL, but surely SDL is using video and the allegro code is using memory buffers, which means the tests aren't equal in any way. Change the create_bitmap to create_video_bitmap and try it again.

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

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

Thomas Harte
Member #33
April 2000
avatar

Quote:

but surely SDL is using video and the allegro code is using memory buffers

I don't think so — "SDL_CreateRGBSurface(SDL_SWSURFACE...)" means create a surface for the fastest possible software blitting, which on a PC means the same as creating a memory bitmap in Allegro. The DisplayFormat thing just makes sure that all the bytes/depths/etc are the same as the display buffer. So it creates a new surface, does a colour conversion blit to it from your original, and returns it.

EDIT: I spotted a logical error in the not-100% CPU code I posted above. You should probably change this bit:

      else
      {
         we're too slow, just jump up to date
         skip next frame;
         framestart = my_timer_var;
      }

To something like:

      else
      {
         we're too slow, just jump up to date
         skipped_count++;
         if(skipped_count&7) skip next frame;
         framestart = my_timer_var;
      }

So that if the computer in question just is too slow to play your game, you still display something, allowing the user to realise what is going on. In this case you'll display every 8th frame, still going too slowly.

sigmar
Member #2,343
May 2002

Allegro is good for: one-hour hacking, simple testing, games, learning(?); you can scrape something together fairly fast from scratch or mod a previous project without too much thinking about hardware-level.

SDL is good for: providing an engine layer for a semi-serious (gamedev?) project. What you basically do when using SDL is to re-code Allegro as far as you need it. Of course it's faster etc., and combined with OpenGL also more powerful; nothing stops you from actually achiving commercial outlook with some labour (scenegraphs etc are available, OI e.g.). Now once you have a basecode set up, engine ready, SDL is as easy as you make it; possibly easier than Allegro.

Allegro is a general-purpose gamedev lib for simple apps and has primarily hacking interest to me (although there are impressive Allegro projects as well, of course).

Michael Faerber
Member #4,800
July 2004
avatar

Oh no! EVERYBODY'S LEAVING! COME BACK! COME BACK TO UNCLE ALLEGRO!

;D

--
"The basic of informatics is Microsoft Office." - An informatics teacher in our school
"Do you know Linux?" "Linux? Isn't that something for visually impaired people?"

Matthew Leverton
Supreme Loser
January 1999
avatar

When I switched to SDL the graphics got way better, I finished all of my games, and millions of people started playing them.

Thomas Harte
Member #33
April 2000
avatar

Quote:

When I switched to SDL the graphics got way better, I finished all of my games, and millions of people started playing them.

If you like SDL, you should try programming in HTML.

Richard Phipps
Member #1,632
November 2001
avatar

Naw, Matthew doesn't like to use variables..

Neil Walker
Member #210
April 2000
avatar

Quote:

means create a surface for the fastest possible software blitting

In that case, he should use create_system_bitmap :)

Quote:

When I switched to SDL the graphics got way better

Is this why www.sdl.cc redirects to allegro.cc, is there something you haven't told us Matthew ;)

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

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

GullRaDriel
Member #3,861
September 2003
avatar

Quote:

Is this why www.sdl.cc redirects to allegro.cc, is there something you haven't told us Matthew ;)

Incredibly it is the case ! I'm dumb! ! ! !

For all those SDL's addict: don't they have a forum for SDL related things ? Didn't you noticed that there is the word 'allegro' in each page of allegro.cc website ?

PS: The last comment is just pure jerk.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Simon Parzer
Member #3,330
March 2003
avatar

There is no such thing as an SDL community. There is only a mailing list for technical problems related to SDL.

GullRaDriel
Member #3,861
September 2003
avatar

So, just for that, SDL sucks.

A project without a community is / not fun / boring / pure shit .

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Neil Walker
Member #210
April 2000
avatar

Quote:

A project without a community is / not fun / boring /

productive ;)

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

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

 1   2 


Go to: