Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » What's the easiest way to distribute my Allegro 5 game to buddies?

This thread is locked; no one can reply to it. rss feed Print
 1   2 
What's the easiest way to distribute my Allegro 5 game to buddies?
bamccaig
Member #7,536
July 2006
avatar

Neil Roy said:

Which works, but it isn't immediately obvious what it does, which is part of why I don't like it. But it is an interesting solution if you like this sort of thing.

It's obvious what it does, but it's not obvious how the user is supposed to know what went wrong. It reports a different error code for each function, but it doesn't show how it would be used to inform the user what's wrong. Of course, error code is enough if they're documented. And obviously they could be easily mapped to a second array of error messages, but it would be easier to store the error messages next to the functions. None of this was explained by Edgar so unless he expects us all to assume what he meant I still have no idea what he meant. I don't know what obvious solution it is that I'm missing because there's nothing obvious about an array index telling the user what function failed.

All I have to do is :

If you check how Eagle initializes everything here it looks pretty much exactly like the OP did, except perhaps "worse" because it's broken up into separate functions whose sole purpose is to initialize a single addon and report an error message to the log. I'm not even saying that what Eagle is doing here is wrong or bad. But it's basically the same thing the OP did. Why give him balls for it? Having a bad day or something? I'd hope that the "log" goes to the console by default because otherwise the user probably will have no idea why the program insta-quit without figuring out that there's a log somewhere.

Basically you've wrapped up the necessary ugly Allegro initialization into an interface that allows you to hide it from your main program/game. That's fine, but it doesn't get rid of the ugly initialization. It just hides it.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Neil Roy said:

He's talking about this code he posted earlier...
...
Which works, but it isn't immediately obvious what it does, which is part of why I don't like it. But it is an interesting solution if you like this sort of thing.

If that code isn't perfectly clear, you need glasses. Or to brush up on your coding skills.

You fail to grasp the idea. That concise, condensed, organized code is far easier to read and interpret quickly.

#SelectExpand
1typdef bool (*BOOLFUNC)(); 2struct CB { 3 BOOLFUNC cb; 4 const char* msg; 5}; 6CB callbacks[] = { 7 {al_init, "Failed to initialize allegro"}, 8 {al_init_image_addon, "Failed to initialize images"}, 9 {al_init_primitives_addon, "Failed to initialize prims"}, 10 {al_init_font_addon, "Failed to initialize fonts"}, 11 {al_init_ttf_addon, "Failed to initialize ttf fonts"}, 12 {al_init_acodec_addon, "Failed to initialize acodec"}, 13 {al_install_audio, "Failed to install audio"}, 14 {al_install_keyboard, "Failed to install keyboard"}, 15 {al_install_mouse, "Failed to install mouse"} 16}; 17 18const int sz = sizeof(callbacks)/sizeof(CB); 19 20for (int i = 0 ; i < sz ; ++i) { 21 if (!callbacks[i].cb()) { 22 fprintf(stdout , "%s\n" , callbacks[i].msg); 23 } 24}

The code is set up that way because it needs a virtual driver. The real code for system initialization is here : https://github.com/EdgarReynaldo/EagleGUI/blob/55c10821ee85bca747b2d5b837aecf7340bf8fbd/src/System.cpp#L242-L267

blehmeh98
Member #16,870
June 2018
avatar

Edgar, thank you for your pointers.
Everyone else, thank you for the entertaining debate on initialization functions for starting a program. :D

I'll find a way to improve it later, probably by storing the init functions and shutdown functions in a different file and calling those functions from main. For now, I want to distribute my program.
Anyways, back to distributing a working program.
Here's where I am at with this process:

  • I'm having more success with a monolithic build. I just have to include all the libraries with my program, too. I'll see how it goes, and if it works, I'll roll with it and describe how I did it for people from the future.

  • Someone mentioned making DEB or RPM or Snap packages for my game. Originally I did not want to make people "install" anything because I figured my program was small enough anyways, but clearly this is a little more complicated to do than I thought. Maybe I'll make those packages to see how it's done and distribute the packages alongside the monolithic build just in case the monolithic one doesn't work for some people. When I make bigger projects (or even slightly more complex small ones), I'll probably only distribute the packages and the source, with no monolithic build.

  • Static compilations seem a little too complex and redundant compared to these two things I am considering. That said, I will try to make it happen, and if I can figure it out, I will consider using it in the future.

bamccaig
Member #7,536
July 2006
avatar

The "monolithic" build as you describe it is probably the most successful way to package software. That's why Windows software is bundled with everything. It's just easier. At least in Linux systems you can rely on system packages to satisfy dependencies, but due to binary incompatibilities with different versions you either need to target the packages for the system specifically or bundle everything. Creating the packages for every supported distribution will be a headache unless there is a service online that can do this for you (but even that will likely be harder than you'd like). If you can get a simple tarball with bundled binaries working on many different distributions that will be the easiest method. But if the source isn't private you should still ship a source distribution in case people don't trust executing code from strangers.

SiegeLord
Member #7,827
October 2006
avatar

Ok, I made a tutorial about how to make OSX bundles with Allegro: here it is!

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

 1   2 


Go to: