static SDL2EX() { IntPtr sdl; if (Environment.OSVersion.Platform == PlatformID.MacOSX) { sdl = Native.LoadLibrary("libSDL2-2.0.0.dylib"); } else if (Environment.OSVersion.Platform == PlatformID.Unix) { sdl = Native.LoadLibrary("libSDL2-2.0.so.0"); } else { sdl = Native.LoadLibrary("SDL2.dll"); } IntPtr loadLib = Native.GetProcessAddress(sdl, "SDL_LoadObject"); _loadObject = Marshal.GetDelegateForFunctionPointer <OnSDLLoadObject>(loadLib); IntPtr loadFunc = Native.GetProcessAddress(sdl, "SDL_LoadFunction"); _loadFunction = Marshal.GetDelegateForFunctionPointer <OnLoadFunction>(loadFunc); }
static SDL2EX() { IntPtr sdl; switch (SDL.SDL_GetPlatform()) { //as defined in https://wiki.libsdl.org/SDL_GetPlatform case "Linux": sdl = Native.LoadLibrary("libSDL2-2.0.so.0"); break; case "Windows": sdl = Native.LoadLibrary("SDL2.dll"); break; case "Mac OS X": sdl = Native.LoadLibrary("libSDL2-2.0.0.dylib"); break; default: throw new Exception("Your Platform is currently NOT supported"); } IntPtr loadLib = Native.GetProcessAddress(sdl, "SDL_LoadObject"); _loadObject = Marshal.GetDelegateForFunctionPointer <OnSDLLoadObject>(loadLib); IntPtr loadFunc = Native.GetProcessAddress(sdl, "SDL_LoadFunction"); _loadFunction = Marshal.GetDelegateForFunctionPointer <OnLoadFunction>(loadFunc); _glColor4F = Marshal.GetDelegateForFunctionPointer <OnGlColor4f>(SDL.SDL_GL_GetProcAddress("glColor4f")); _glColor4Fub = Marshal.GetDelegateForFunctionPointer <OnGlColor4fub>(SDL.SDL_GL_GetProcAddress("glColor4ub")); }