gfm



class  SDL2Exception: object.Exception;

The one exception type thrown in this wrapper.

A failing SDL function should always throw a  SDL2Exception.


class  SDL2;

Owns both the loader, logging, keyboard state...

This object is passed around to other SDL wrapper objects

to ensure library loading.


this(Logger logger, SharedLibVersion sdl2Version = SharedLibVersion(2, 0, 2));

Load SDL2 library, redirect logging to our logger.

You can pass a null logger if you don't want logging.

You can specify a minimum version of SDL2 you wish your project to support.

Creating this object doesn't initialize any SDL subsystem!

Parameters
Logger logger The logger to redirect logging to.
SharedLibVersion sdl2Version The version of SDL2 to load. Defaults to SharedLibVersion(2, 0, 2).
Throws
SDL2Exception on error.
See Also
http://wiki.libsdl.org/SDL_Init, subSystemInit

bool  subSystemInitialized(int subSystem);

Returns
true if a subsystem is initialized.
See Also
http://wiki.libsdl.org/SDL_WasInit

void  subSystemInit(int flag);

Initialize a subsystem. By default, all SDL subsystems are uninitialized.

See Also
http://wiki.libsdl.org/SDL_InitSubSystem

SDL2VideoDisplay[]  getDisplays();

Returns
Available displays information.
Throws
SDL2Exception on error.

SDL_Point  firstDisplaySize();

Returns
Resolution of the first display.
Throws
SDL2Exception on error.

SDL2RendererInfo[]  getRenderersInfo();

Returns
Available renderers information.
Throws
SDL2Exception on error.

bool  pollEvent(SDL_Event* event);

Get next SDL event.

Input state gets updated and window callbacks are called too.

Returns
true if returned an event.

void  waitEvent(SDL_Event* event);

Wait for next SDL event.

Input state gets updated and window callbacks are called too.

See Also
http://wiki.libsdl.org/SDL_WaitEvent
Throws
SDL2Exception on error.

bool  waitEventTimeout(SDL_Event* event, int timeoutMs);

Wait for next SDL event, with a timeout.

Input state gets updated and window callbacks are called too.

See Also
http://wiki.libsdl.org/SDL_WaitEventTimeout
Throws
SDL2Exception on error.
Returns
true if returned an event.

void  processEvents();

Process all pending SDL events.

Input state gets updated. You would typically look at event instead of calling

this function.

See Also
pollEvent, waitEvent, waitEventTimeout

SDL2Keyboard  keyboard();

Returns
Keyboard state.

The  keyboard state is updated by processEvents() and pollEvent().

SDL2Mouse  mouse();

Returns
Mouse state.

The  mouse state is updated by processEvents() and pollEvent().

const bool  wasQuitRequested();

Returns
true if an application termination has been requested.

void  startTextInput();

Start text input.


void  stopTextInput();

Stops text input.


string  setClipboard(string s);

Sets clipboard content.

Throws
SDL2Exception on error.

const(char)[]  getClipboard();

Returns
Clipboard content.
Throws
SDL2Exception on error.

alias  getVideoDrivers = .SDL2.getDrivers!(SDL_GetNumVideoDrivers, SDL_GetVideoDriver).getDrivers;

Returns
Available SDL video drivers.

alias  getAudioDrivers = .SDL2.getDrivers!(SDL_GetNumAudioDrivers, SDL_GetAudioDriver).getDrivers;

Returns
Available SDL audio drivers.

const(char)[][]  getAudioDevices(int type = 0);

Returns
Available audio device names.
See Also
https:
//wiki.libsdl.org/SDL_GetAudioDeviceName
Known Bugs
SDL2 currently doesn't support recording, so it's best to call this without any arguments.

const(char)[]  getPlatform();

Returns
Platform name.

int  getL1LineSize();

Returns
L1 cacheline size in bytes.

int  getCPUCount();

Returns
number of CPUs.

const(char)[]  getPrefPath(string orgName, string applicationName);

Returns
A path suitable for writing configuration files, saved games, etc...
See Also
http://wiki.libsdl.org/SDL_GetPrefPath
Throws
SDL2Exception on error.

package nothrow void  ensureNotInGC(string resourceName);

Crash if the GC is running.

Useful in destructors to avoid reliance GC resource release.