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 3.5 and Mono on Windows, Linux and Mac OS X.

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 AgateLib.ImplementationBase which must be inherited from by a driver. The three main subsystems (Display, Audio and JoystickInput) 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. Each DLL it finds, it checks for a class extending AgateDriverReporter. When it finds one, AgateLib instantiates it and asks it what classes in the library provide implementations for the AgateLib subsystems. 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 Mac OS X machine, drop in appropriate Mac OS X drivers 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.

Features

Driver Based Architecture

AgateLib operates through a driver or plug-in model where drivers are loaded at startup automatically based on what is available. Your application only needs a reference to AgateLib.dll. Upon initializing AgateLib, it will instantiate drivers to operate through OpenGL or Direct3D, depending on which drivers are present.

Cross Platform Support

Considerable work and testing has gone into ensuring that AgateLib runs as consistently as possible across multiple platforms. Currently supported platforms are Windows, Mac OS X, and Linux. AgateLib is regularly tested on several versions of these platforms in order to ensure that the behavior is consistent.

Ease of Deployment

An application built with AgateLib is easy to deploy. The AgateLib.dll itself has no external dependencies. The recommended drivers AgateOTK (for graphics) and AgateSDL (for audio and joysticks) operate on all platforms, provided native libraries are present. OpenGL is generally already installed on every computer, so this usually amounts to making sure that SDL and SDL_mixer are present. If SDL is not a desirable dependency, then AgateSDL can be swapped out for AgateFMOD or AgateMDX to use FMOD or DirectSound for audio.

Ease of Use

Eighty percent of users will use twenty percent of the code. AgateLib is designed to make that twenty percent of code that you will use as accessible as possibly, giving you code ends up being very readable and easy to maintain.

Windows.Forms Integration

From day one, being able to use AgateLib to render to a control on a Form has been a goal, and that will never go away. This makes AgateLib ideal for writing game authoring tools or applications which require a complex set controls for user experience as well as smooth animations in the rendering region.

Flexible Coding Structure

With AgateLib, you have complete control over your rendering. You don't have to give up control of your render loop, where it is called, with what frequency, or even how many render loops you have. Of course, you can give up control over the render loop if you prefer, as this eases the coding effort on you and enforces some structure. With AgateLib, you have the choice.

Code - Performance Lineup

Many OOP libraries abstract away the details to the point where two lines of code which look identical can have very different performance characteristics. With AgateLib, expensive operations like copying pixel data from application memory to video memory require explicit method calls which make the intent clear. You never have to hunt for weird performance bugs where, say, you have some surfaces stored in video memory and others not.

High Performance

AgateLib has been thoroughly tested and optimized. Surfaces are packed into video memory to minimize graphics accelerator state changes, and drawing calls are queued up in order to batch them. These optimizations occur behind the scenes, so all you notice is that your AgateLib game is blazing fast, even on old hardware.