static Application() { if (!GLib.Thread.Supported) { GLib.Thread.Init(); } switch (Environment.OSVersion.Platform) { case PlatformID.Win32NT: case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.WinCE: Win32CreateWindow = FuncLoader.LoadFunction <d_Win32CreateWindow>(FuncLoader.GetProcAddress(GLibrary.Load("user32.dll"), "CreateWindowExW")); Win32DestroyWindow = FuncLoader.LoadFunction <d_Win32DestroyWindow>(FuncLoader.GetProcAddress(GLibrary.Load("user32.dll"), "DestroyWindow")); // No idea why we need to create that window, but it enables visual styles on the Windows platform IntPtr window = Win32CreateWindow(WS_EX_TOOLWINDOW, "static", "gtk-sharp visual styles window", WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); Win32DestroyWindow(window); break; default: break; } }
public static IntPtr Load(Library library) { var ret = IntPtr.Zero; if (_libraries.TryGetValue(library, out ret)) { return(ret); } if (FuncLoader.IsWindows) { ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][0]); if (ret == IntPtr.Zero) { SetDllDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Gtk", "3.24.24")); ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][0]); } } else if (FuncLoader.IsOSX) { ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][2]); if (ret == IntPtr.Zero) { ret = FuncLoader.LoadLibrary("/usr/local/lib/" + _libraryDefinitions[library][2]); } } else { ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][1]); } if (ret == IntPtr.Zero) { for (int i = 0; i < _libraryDefinitions[library].Length; i++) { ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][i]); if (ret != IntPtr.Zero) { break; } } } if (ret == IntPtr.Zero) { var err = library + ": " + string.Join(", ", _libraryDefinitions[library]); throw new DllNotFoundException(err); } _libraries[library] = ret; return(ret); }
private static IntPtr GetNativeLibrary() { var ret = IntPtr.Zero; // Load bundled library var assemblyLocation = Path.GetDirectoryName(typeof(Sdl).Assembly.Location); if (CurrentPlatform.OS == OS.Windows && Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x64/SDL2.dll")); } else if (CurrentPlatform.OS == OS.Windows && !Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x86/SDL2.dll")); } else if (CurrentPlatform.OS == OS.Linux && Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x64/libSDL2-2.0.so.0")); } else if (CurrentPlatform.OS == OS.Linux && !Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x86/libSDL2-2.0.so.0")); } else if (CurrentPlatform.OS == OS.MacOSX) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "libSDL2-2.0.0.dylib")); } // Load system library if (ret == IntPtr.Zero) { if (CurrentPlatform.OS == OS.Windows) { ret = FuncLoader.LoadLibrary("SDL2.dll"); } else if (CurrentPlatform.OS == OS.Linux) { ret = FuncLoader.LoadLibrary("libSDL2-2.0.so.0"); } else { ret = FuncLoader.LoadLibrary("libSDL2-2.0.0.dylib"); } } // Welp, all failed, PANIC!!! if (ret == IntPtr.Zero) { throw new Exception("Failed to load SDL library."); } return(ret); }
private static IntPtr GetNativeLibrary() { var ret = IntPtr.Zero; #if DESKTOPGL // Load bundled library var assemblyLocation = Path.GetDirectoryName((new Uri(typeof(AL).Assembly.CodeBase)).LocalPath); if (CurrentPlatform.OS == OS.Windows && Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x64/soft_oal.dll")); } else if (CurrentPlatform.OS == OS.Windows && !Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x86/soft_oal.dll")); } else if (CurrentPlatform.OS == OS.Linux && Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x64/libopenal.so.1")); } else if (CurrentPlatform.OS == OS.Linux && !Environment.Is64BitProcess) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x86/libopenal.so.1")); } else if (CurrentPlatform.OS == OS.MacOSX) { ret = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "libopenal.1.dylib")); } // Load system library if (ret == IntPtr.Zero) { if (CurrentPlatform.OS == OS.Windows) { ret = FuncLoader.LoadLibrary("soft_oal.dll"); } else if (CurrentPlatform.OS == OS.Linux) { ret = FuncLoader.LoadLibrary("libopenal.so.1"); } else { ret = FuncLoader.LoadLibrary("libopenal.1.dylib"); } } #elif ANDROID ret = FuncLoader.LoadLibrary("libopenal32.so"); #else ret = FuncLoader.LoadLibrary("/System/Library/Frameworks/OpenAL.framework/OpenAL"); #endif return(ret); }
private static IntPtr GetNativeLibrary() { var result = IntPtr.Zero; var assemblyLocation = Path.GetDirectoryName(typeof(Sdl).Assembly.Location); if (Environment.OSVersion.IsWindows()) { result = FuncLoader.LoadLibrary(Environment.Is64BitProcess ? Path.Combine(assemblyLocation, "x64/SDL2.dll") : Path.Combine(assemblyLocation, "x86/SDL2.dll")); } else if (Environment.OSVersion.IsMacOSX()) { result = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "libSDL2-2.0.0.dylib")); } else if (Environment.OSVersion.Platform == PlatformID.Unix) { result = FuncLoader.LoadLibrary(Environment.Is64BitProcess ? Path.Combine(assemblyLocation, "x64/libSDL2-2.0.so.0") : Path.Combine(assemblyLocation, "x86/libSDL2-2.0.so.0")); } if (result == IntPtr.Zero) { if (Environment.OSVersion.IsWindows()) { result = FuncLoader.LoadLibrary("SDL2.dll"); } else if (Environment.OSVersion.Platform == PlatformID.Unix) { result = FuncLoader.LoadLibrary("libSDL2-2.0.so.0"); } else if (Environment.OSVersion.IsMacOSX()) { result = FuncLoader.LoadLibrary("libSDL2-2.0.0.dylib"); } } if (result == IntPtr.Zero) { throw new Exception("Failed to load SDL library."); } return(result); }
private static IntPtr GetNativeLibrary() { if (CurrentPlatform.OS == OS.Windows) { return(FuncLoader.LoadLibraryExt("SDL2.dll")); } else if (CurrentPlatform.OS == OS.Linux) { return(FuncLoader.LoadLibraryExt("libSDL2-2.0.so.0")); } else if (CurrentPlatform.OS == OS.MacOSX) { return(FuncLoader.LoadLibraryExt("libSDL2-2.0.0.dylib")); } else { return(FuncLoader.LoadLibraryExt("sdl2")); } }
static partial void LoadPlatformEntryPoints() { Android.Util.Log.Verbose("GL", "Loading Entry Points"); var eglBindLoaded = false; try { BindAPI = FuncLoader.LoadFunction <BindAPIDelegate>(libGL, "eglBindAPI", true); eglBindLoaded = true; } catch { } var supportsFullGL = eglBindLoaded && BindAPI(RenderApi.GL); if (!supportsFullGL) { if (eglBindLoaded) { BindAPI(RenderApi.ES); } BoundApi = RenderApi.ES; } Android.Util.Log.Verbose("GL", "Bound {0}", BoundApi); if (BoundApi == RenderApi.ES && libES3 != IntPtr.Zero) { Library = libES3; } if (BoundApi == RenderApi.ES && libES2 != IntPtr.Zero) { Library = libES2; } else if (BoundApi == RenderApi.GL && libGL != IntPtr.Zero) { Library = libGL; } }
private static IntPtr GetNativeLibrary() { #if DESKTOPGL if (CurrentPlatform.OS == OS.Windows) { return(FuncLoader.LoadLibraryExt("soft_oal.dll")); } else if (CurrentPlatform.OS == OS.Linux) { return(FuncLoader.LoadLibraryExt("libopenal.so.1")); } else if (CurrentPlatform.OS == OS.MacOSX) { return(FuncLoader.LoadLibraryExt("libopenal.1.dylib")); } else { return(FuncLoader.LoadLibraryExt("openal")); } #elif ANDROID var ret = FuncLoader.LoadLibrary("libopenal32.so"); if (ret == IntPtr.Zero) { var appFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var appDir = Path.GetDirectoryName(appFilesDir); var lib = Path.Combine(appDir, "lib", "libopenal32.so"); ret = FuncLoader.LoadLibrary(lib); } return(ret); #else return(FuncLoader.LoadLibrary("/System/Library/Frameworks/OpenAL.framework/OpenAL")); #endif }
private static T LoadFunction <T>(string function, bool throwIfNotFound = false) { return(FuncLoader.LoadFunction <T>(Library, function, throwIfNotFound)); }
private static IntPtr GetNativeLibrary() { var loaded = IntPtr.Zero; #if DESKTOPGL || DIRECTX // Load bundled library string assemblyLocation = Path.GetDirectoryName(typeof(AL).Assembly.Location) ?? string.Empty; if (PlatformInfo.CurrentOS == OS.Windows && Environment.Is64BitProcess) { loaded = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x64/soft_oal.dll")); } else if (PlatformInfo.CurrentOS == OS.Windows && !Environment.Is64BitProcess) { loaded = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x86/soft_oal.dll")); } else if (PlatformInfo.CurrentOS == OS.Linux && Environment.Is64BitProcess) { loaded = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x64/libopenal.so.1")); } else if (PlatformInfo.CurrentOS == OS.Linux && !Environment.Is64BitProcess) { loaded = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "x86/libopenal.so.1")); } else if (PlatformInfo.CurrentOS == OS.MacOSX) { loaded = FuncLoader.LoadLibrary(Path.Combine(assemblyLocation, "libopenal.1.dylib")); } // Load system library if (loaded == IntPtr.Zero) { if (PlatformInfo.CurrentOS == OS.Windows) { loaded = FuncLoader.LoadLibrary("soft_oal.dll"); } else if (PlatformInfo.CurrentOS == OS.Linux) { loaded = FuncLoader.LoadLibrary("libopenal.so.1"); } else { loaded = FuncLoader.LoadLibrary("libopenal.1.dylib"); } } #elif ANDROID loaded = FuncLoader.LoadLibrary("libopenal32.so"); if (loaded == IntPtr.Zero) { string appFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string appDir = Path.GetDirectoryName(appFilesDir); string lib = Path.Combine(appDir, "lib", "libopenal32.so"); loaded = FuncLoader.LoadLibrary(lib); } #else loaded = FuncLoader.LoadLibrary("/System/Library/Frameworks/OpenAL.framework/OpenAL"); #endif return(loaded); }