FAQ

From Allegro Wiki
Jump to: navigation, search

Every question on this page has really, truly been asked frequently.

General

Is Allegro C or C++?

With the exception of a few DirectX files that are required to be C++, Allegro is programmed according to the C90 standard.[1][2]

Is Allegro compatible with C++? Is it compatible with C?

Yes and yes. Also, thank you for finding the answer to your question here, in the FAQ. You are off to a good start.[3]

Is Allegro compatible with non-C language X?

Maybe.

Is Allegro thread-safe?

Yes.[4]

Which branch/version of Allegro should I use?

If you have just started learning C/C++, use whichever branch is easiest to install on your system. If you have C/C++ experience and want to see what the Allegro API has to offer, use the work-in-progress branch. If you formerly programmed in Allegro 4, spend an afternoon bringing yourself up to speed with the Allegro 5 API and use the work-in-progress branch.[5]

For the long answer, see here.

Installation

See here.

Program Compilation

Why do I get undefined symbol errors?

Because you aren't linking correctly to Allegro. Try adding the "-lallegro" switch to your compile command. Add an additional "-lallegro_main" for Mac.[6]

How do I statically link?

Sacrifice a virgin maiden to the gods of Mt Allegrohorn.

How do I build an executable that runs on any Linux distro?

Link to and distribute monolithic Allegro builds for both 64- and 32-bit platforms.[7]

Programming

Why does Allegro register too many key/mouse presses?

Because you're not using events.[8] See here.

How do I switch between full-screen and windowed modes?

For full-screen, use ALLEGRO_FULLSCREEN_WINDOWED and scale the buffer with a transformation.[9][10] For windowed, use ALLEGRO_WINDOWED.

How do I open GIF animations?

Use algif.

Should I use memory or video bitmaps?

The answer is not entirely straightforward, but here are some facts:

  • Video bitmaps are generally faster than memory bitmaps.
  • Converting bitmaps between memory and video is generally slow.[11]
  • Testing helps.[12]

How do I prevent the task bar from appearing on top of a full-screen display?

See here.

How do I create a multi-threaded application?

See here.

How do I use Allegro with a UI engine like Awesomium?

Attach a shader as necessary to convert the UI engine's pixel format to one compatible with Allegro. Copy the pixel data to a locked video bitmap. Unlock and draw the bitmap.[13]

References

  1. Allegro.cc forum post by pkrcel in Is Allegro C or C++?
  2. Allegro Github language statistics.
  3. How to Ask Questions the Smart Way, by Eric Steven Raymond
  4. Allegro.cc forum post by Thomas Fjellstrom in How thread safe is Allegro?
  5. Which branch of Allegro should I use?
  6. Allegro.cc forum post by Trent Gamblin in How to compile a program using allegro
  7. Allegro.cc forum posts by Elias in Linking allegro statically and by Arthur Kalliokoski and bamccaig in How to compile for a release from linux for all linux platforms?
  8. Allegro.cc forum post by Gideon Weems in Stored mouse and keyboard after dialog
  9. Allegro.cc forum post by Thomas Fjellstrom in Fullscreen in Linux Mint
  10. Achieving Resolution Independence
  11. Allegro.cc forum post by Thomas Fjellstrom in A threaded loading screen
  12. Allegro.cc forum post by André Silva in A threaded loading screen
  13. Allegro.cc forum posts by jmasterx in How To Render Awesomium Into Allegro 5 Buffer and SiegeLord in Allegro5 and Awesomium