DerelictSDL

DerelictSDL is a D binding to Sam Lantinga's Simple DirectMedia Layer, a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. DerelictSDL is implemented against the 1.2.x series of the SDL library. It will not work with the 1.3.x series, the version which will eventually become SDL 2.

The current version of DerelictSDL requires at least SDL 1.2.13.

Building

To compile DerelictSDL only, add the DerelictSDL make target to the command line when compiling Derelict. For example, to build DerelictSDL on Windows with DMD, you would execute the following:

make -fwin32.mak DerelictSDL DC=DMD
For more information on compiling Derelict libraries, see Building the Derelict Bindings.

Using

  1. Always make sure the DerelictSDL source modules are available on your import path.
  2. In modules that make use of DerelictSDL, you will need to import the derelict.sdl.sdl module.
  3. You must link your application with the DerelictSDL and DerelictUtil libraries.
  4. Before calling any SDL functions, you need to make a call to DerelictSDL.load(). This will load the shared library.

The following is a complete program that loads DerelictSDL:

import derelict.sdl.sdl;

void main()
{
    DerelictSDL.load();

    // now you can call SDL functions
}

As with other Derelict bindings, DerelictSDL will throw an exception if an error occurs while loading the shared library. For more information on Derelict exceptions, see the documentation for Using the Derelict Bindings.

Finally, the method DerelictSDL.unload() is provided for convenience. In normal practice you do not need to call this function, as Derelict will unload the library automatically when the app exits. You generally should only use this function if you need to unload DerelictSDL while the application is running or if you disable the automatic unloading of shared libraries (as per the documentation for the loader module).

Things You Need To Know