SubC.AllegroDotNet
0.6.42
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
<PackageReference Include="SubC.AllegroDotNet" Version="0.6.42" />
paket add SubC.AllegroDotNet --version 0.6.42
#r "nuget: SubC.AllegroDotNet, 0.6.42"
// 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)
- Add a NuGet package reference to
SubC.AllegroDotNet
. - 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). - 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();
- 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 | Versions 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. |
-
.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.11.0 | 36 | 11/29/2024 | |
0.10.0 | 111 | 9/2/2024 | |
0.9.4 | 107 | 8/27/2024 | |
0.9.3 | 132 | 8/24/2024 | |
0.9.2 | 121 | 8/11/2024 | |
0.9.1 | 150 | 5/4/2024 | |
0.9.0 | 303 | 2/17/2024 | |
0.8.2 | 601 | 10/3/2023 | |
0.8.1-pre | 656 | 7/22/2023 | |
0.7.10 | 583 | 10/2/2023 | |
0.7.9 | 812 | 4/8/2023 | |
0.7.2 | 953 | 1/15/2023 | |
0.7.1 | 965 | 12/10/2022 | |
0.6.42 | 1,118 | 9/10/2022 | |
0.6.39 | 1,167 | 8/21/2022 | |
0.6.38 | 1,147 | 8/14/2022 | |
0.6.33 | 905 | 8/13/2022 | |
0.6.28 | 932 | 6/25/2022 | |
0.6.22 | 930 | 6/18/2022 | |
0.6.6 | 897 | 6/13/2022 | |
0.6.6-debug | 614 | 6/13/2022 | |
0.6.5 | 912 | 6/12/2022 | |
0.6.5-debug | 677 | 6/12/2022 | |
0.6.1 | 918 | 6/10/2022 | |
0.6.1-debug | 634 | 6/10/2022 | |
0.5.42 | 867 | 5/30/2022 | |
0.5.42-debug | 675 | 5/30/2022 | |
0.5.41 | 932 | 5/14/2022 | |
0.5.41-debug | 664 | 5/14/2022 | |
0.5.39 | 917 | 5/13/2022 | |
0.5.39-debug | 625 | 5/13/2022 | |
0.5.38 | 911 | 5/12/2022 | |
0.5.38-debug | 648 | 5/12/2022 | |
0.5.37 | 939 | 5/10/2022 | |
0.5.37-debug | 643 | 5/10/2022 | |
0.5.36 | 894 | 5/8/2022 | |
0.5.36-debug | 627 | 5/8/2022 | |
0.5.28 | 905 | 4/30/2022 | |
0.5.28-debug | 666 | 4/30/2022 |
This release adds the Allegro File I/O routines.