SubC.AllegroDotNet 0.6.42

There is a newer version of this package available.
See the version list below for details.
dotnet add package SubC.AllegroDotNet --version 0.6.42                
NuGet\Install-Package SubC.AllegroDotNet -Version 0.6.42                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SubC.AllegroDotNet" Version="0.6.42" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SubC.AllegroDotNet --version 0.6.42                
#r "nuget: SubC.AllegroDotNet, 0.6.42"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SubC.AllegroDotNet as a Cake Addin
#addin nuget:?package=SubC.AllegroDotNet&version=0.6.42

// Install SubC.AllegroDotNet as a Cake Tool
#tool nuget:?package=SubC.AllegroDotNet&version=0.6.42                

AllegroDotNet

The AllegroDotNet project aims to make the Allegro 5 game programming library to be useable from C# and feel .NET-like. Native C functions, pointers, and structs are wrapped by C# methods and classes and avoid exposing pointers whenever possible.

Using AllegroDotNet will allow you to create game and multimedia applications in C#.

Requirements

  • Target x64 architecture (AnyCPU or x86 will not work)
  • Native Allegro 5 (v5.2.8) library available (see Quick Start)

Quick Start (Windows)

  1. Add a NuGet package reference to SubC.AllegroDotNet.
  2. Add a NuGet package reference to SubC.AllegroDotNet.Win64 (or add your own Allegro v5.2.8 monolith .DLL (allegro_monolith-5.2.dll) to your project output).
  3. Add the following test code to your source code:
using SubC.AllegroDotNet;
// ...
Al.InstallSystem(Al.ALLEGRO_VERSION_INT, null);
var display = Al.CreateDisplay(1280, 720) ?? throw new Exception();
Al.Rest(3);
Al.DestroyDisplay(display);
Al.UninstallSystem();
  1. Compile and run.

For more example code, see the AllegroDotNet.Sandbox project in this repository.

Using AllegroDotNet

AllegroDotNet tries to be as familiar for users of Allegro 5 as possible. The Allegro 5 documentation applies to AllegroDotNet, because AllegroDotNet is only wrapping Allegro 5 functionality. Following existing Allegro 5 tutorials will apply to AllegroDotNet, at least as far as what Allegro function to call with what parameters.

Differences between Allegro 5 and AllegroDotNet

  • AllegroDotNet uses .NET-style naming conventions, so all functions use pascal-casing and removing underscores.
  • AllegroDotNet removes the al_ prefix from all functions.
  • AllegroDotNet places all Allegro functions in the static class named Al.

Where Allegro 5 used functions named similar to al_create_bitmap(100, 50), AllegroDotNet would call this function via Al.CreateBitmap(100, 50). All functions are in the static SubC.AllegroDotNet.Al class.

Where Allegro 5 used pointers (ie, ALLEGRO_BITMAP*), AllegroDotNet uses classes (ie, AllegroBitmap). These classes are in the SubC.AllegroDotNet.Models namespace.

Where Allegro 5 used #DEFINE constants (ie, ALLEGRO_NO_PRESERVE_TEXTURE), AllegroDotNet uses enumerations (ie, BitmapFlags.NoPreserveTexture). Enumerations are in the SubC.AllegroDotNet.Enums namespace.

Where Allegro 5 used macros (ie, ALLEGRO_BPS_TO_SECS(x)), AllegroDotNet uses methods (ie, Al.BpmToSecs(x)). All macros are in the static SubC.AllegroDotNet.Al class.

Some final notes about using AllegroDotNet:

  • Currently AllegroDotNet uses Allegro v5.2.8.

  • If the Allegro function takes or returns a string, that involves extra marshalling from managed/unmanaged code. While this isn't "slow", it isn't as fast as passing pointers and numbers around.

  • Not all of Allegro 5 API is implemented yet; for example, haptic routines are currently not implemented.

  • No testing has been done on OSX, and minimal testing was done on Linux. Would you want to test it on those platforms?

Troubleshooting

  • If you get "unbalanced stack" errors, ensure your application is targeting x64 architecture. AnyCPU will not work.

  • If calling Al.Init() is failing, ensure you have the correct version of the Allegro 5 library. Currently, AllegroDotNet requires v5.2.8. See NuGet packages SubC.AllegroDotNet.Win64 or SubC.AllegroDotNet.Linux64 for known working native Allegro libraries to use.

  • AllegroDotNet requires a monolith version of Allegro (ie, allegro_monolith-5.2.dll) to be available.

  • If you'd rather use the offical Allegro 5 binaries instead of SubC.AllegroDotNet.Win64, that is also an option. However, you will need to do the work to make sure the monolith .DLL file is available to your executable (the NuGet package automatically adds the .DLL to your project's output).

  • You will get "missing function" errors if the native Allegro 5 library you are using is missing functions for addons it expects to be available (ex: you compiled your own .DLL and did not include native dialog functions, acodec functions, etc).

  • You may get additional errors if your .DLL did not have dependencies statically linked. You can solve this by using a static-linked Allegro 5 .DLL (such as from SubC.AllegroDotNet.Win64), or place the needed .DLLs with your program output (flac.dll, zlib.dll, etc).

AllegroDotNet.Extensions

This extension project adds object-oriented extension methods to (some of) the AllegroDotNet classes. Example:

Al.RegisterEventSource(myEventSource, Al.GetDisplayEventSource(myDisplay))

becomes

myEventQueue.RegisterEventSource(myDisplay.GetDisplayEventSource());

Closing

Thanks to the Allegro team, it's an awesome library that I've been using since the DOS / DJGPP days.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.10.0 103 9/2/2024
0.9.4 101 8/27/2024
0.9.3 126 8/24/2024
0.9.2 115 8/11/2024
0.9.1 144 5/4/2024
0.9.0 297 2/17/2024
0.8.2 579 10/3/2023
0.8.1-pre 654 7/22/2023 0.8.1-pre is deprecated because it has critical bugs.
0.7.10 577 10/2/2023
0.7.9 808 4/8/2023
0.7.2 947 1/15/2023
0.7.1 961 12/10/2022
0.6.42 1,114 9/10/2022
0.6.39 1,163 8/21/2022
0.6.38 1,141 8/14/2022
0.6.33 901 8/13/2022
0.6.28 926 6/25/2022
0.6.22 924 6/18/2022
0.6.6 874 6/13/2022
0.6.6-debug 595 6/13/2022
0.6.5 906 6/12/2022
0.6.5-debug 657 6/12/2022
0.6.1 912 6/10/2022
0.6.1-debug 630 6/10/2022
0.5.42 861 5/30/2022
0.5.42-debug 662 5/30/2022
0.5.41 926 5/14/2022
0.5.41-debug 660 5/14/2022
0.5.39 911 5/13/2022
0.5.39-debug 621 5/13/2022
0.5.38 905 5/12/2022
0.5.38-debug 642 5/12/2022
0.5.37 931 5/10/2022
0.5.37-debug 639 5/10/2022
0.5.36 888 5/8/2022
0.5.36-debug 623 5/8/2022
0.5.28 899 4/30/2022
0.5.28-debug 662 4/30/2022

This release adds the Allegro File I/O routines.