Ejemplo n.º 1
0
    private static IntPtr GetNativeLibrary()
    {
        var ret = IntPtr.Zero;

        // Load bundled library
        var assemblyLocation = Path.GetDirectoryName((new Uri(typeof(Sdl).Assembly.CodeBase)).LocalPath);

        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);
    }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
    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"));
                ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][0]);
            }
        }
        else if (FuncLoader.IsOSX)
        {
            ret = FuncLoader.LoadLibrary(_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);
    }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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
        }
Ejemplo n.º 6
0
        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);
        }