Sdl constructor
Sdl({
- String? libName,
Create an object.
Implementation
Sdl({String? libName})
: xPointer = calloc<Int>(),
yPointer = calloc<Int>(),
x2Pointer = calloc<Int>(),
y2Pointer = calloc<Int>(),
floatPointer = calloc<Float>(),
displayModePointer = calloc<SDL_DisplayMode>(),
_audioSpecDesiredPointer = calloc<SDL_AudioSpec>(),
_audioSpecObtainedPointer = calloc<SDL_AudioSpec>(),
_messageBoxDataPointer = calloc<SDL_MessageBoxData>(),
_versionPointer = calloc<SDL_version>(),
hapticDirectionPointer = calloc<SDL_HapticDirection>(),
rectPointer = calloc<SDL_Rect>(),
_eventHandle = calloc<SDL_Event>() {
if (libName == null) {
if (Platform.isWindows) {
libName = 'SDL2.dll';
} else if (Platform.isLinux) {
libName = 'libSDL2.so';
} else if (Platform.isMacOS) {
if (File('libSDL2.dylib').existsSync()) {
libName = 'libSDL2.dylib';
} else {
libName = 'SDL2.framework/SDL2';
}
} else {
throw Exception(
'Unimplemented operating system: ${Platform.operatingSystem}. '
'You must specify your own `libName`.',
);
}
final libPath = path.join(
path.dirname(Platform.script.toFilePath()),
libName,
);
if (File(libPath).existsSync() == true) {
libName = libPath;
} else {
libName = path.join(Directory.current.path, libName);
}
}
sdl = DartSdl(DynamicLibrary.open(libName));
}