Introduction: About AgateLib

AgateLib is a platform-independent .NET library intended for cross-platform development of games and game development tools. It is CLS-compliant, so it is accessible to any .NET language. AgateLib is built on a driver-based model so that new platforms and rendering pipelines can be implemented easily. The design and interfaces in AgateLib were inspired by the powerful ClanLib C++ library. AgateLib is developed entirely in C#, and builds and runs under .NET 2.0 and Mono.

Driver Model

How does AgateLib work on different platforms? The answer is simple really, thanks to powerful reflection capabilities in the .NET standard library.

AgateLib has several abstract classes located in ERY.AgateLib.ImplBase which must be inherited from by a driver. The three main subsystems (Display, Audio and Input) have abstract classes which behave as a class factory to create their own concrete implementations of these abstract base classes.

When the Agate library is initialized, it searches the directory of the executing file for other DLL's (this directory can be changed, if needed). Each DLL it finds, it checks to see if it has any classes which inherit from DisplayImpl, AudioImpl or InputImpl. If so, then these libraries are marked as containing classes which can be used. The best one of these is chosen and used for running the graphical engine (or audio or input). New drivers can be added to an existing program without recompiling it. Thanks to Mono's ability to load and execute MSIL, one can compile a game into a binary executable with Microsoft Visual Studio, for example, and copy it to a Linux machine, drop in the appropriate Linux driver and run the application. All of this happens behind the scenes.

If multiple drivers are present, Agate will choose the best available one. Agate can also show a dialog to the user asking them which drivers to choose. This is useful for debugging purposes. This also allows a single distribution to be constructed for all platforms just by including the drivers for each platform.