DerelictSDL
Introduction
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. Although SDL is available on a large number of platforms,
DerelictSDL is currently only available on Windows and Linux.
The current version of DerelictSDL requires SDL 1.2.10 or later.
SDL_VideoInfo is defined differently
in DerelictSDL than it is in SDL. This is because the C version makes use of
bitfields, which D does not support. Currently, DerelictSDL replaces all bitfields
in the structure definition with a single uint field called flags. It is
still possible to access the individual bitfield flags by using bit manipulation
operators, but unless you know what you are doing it is recommended that you not
do so. Instances of SDL_VideoInfo are created on the C side, not in D. There is
nothing in the C standard which specifies the order of the bits in the bitfield
(i.e. the first field encountered might become the low order or high order bit),
so what may work with one SDL shared library on one platform may not work with an
SDL shared library on another platform (or even on the same platform if compiled
with a different compiler!). So please keep in mind that manipulating the flags
field of DerelictSDL's SDL_VideoInfo could result in unexpected consequences. You
have been warned!
Using
- Always make sure the DerelictSDL source modules are available on your import
path.
- In modules that make use of DerelictSDL, you will need to import the
derelict.sdl.sdl module.
- 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 packages, DerelictSDL will throw an exception if an error
occurs while loading the shared library. For more information on Derelict
exceptions, see the documentation for
Loading/Unloading Shared Libraries.
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.
Dependencies
DerelictUtil