Exemple #1
0
        /// <summary>
        /// Try to get an extension.
        /// </summary>
        /// <param name="ext">The extension obtained. If the return value is false, then this is null.</param>
        /// <typeparam name="T">The extension type to check for.</typeparam>
        /// <returns>Whether or not the extension was found. If false, the extension was not found.</returns>
        public bool TryGetExtension <T>(out T ext)
            where T : NativeExtension <EGL>
        {
            ext = LibraryLoader <EGL> .Load <T>(this);

            return(ext != null);
        }
Exemple #2
0
        public static void InitEngine()
        {
            LibraryLoader.Load(new LibraryConfig()
            {
                Linux64 = new LibraryContent[]
                {
                    new LibraryContent("cimgui.so", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("linux") && name.Contains("64"))),
                },

                Win32 = new LibraryContent[]
                {
                    new LibraryContent("cimgui.dll", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("win") && name.Contains("86"))),
                },

                Win64 = new LibraryContent[]
                {
                    new LibraryContent("cimgui.dll", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("win") && name.Contains("64"))),
                },

                Mac64 = new LibraryContent[]
                {
                    new LibraryContent("cimgui.dylib", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("osx") && name.Contains("64"))),
                },
            });
        }
    static SoundIO()
    {
        _handle = LibraryLoader.Load(typeof(SoundIO));

        if (BitConverter.IsLittleEndian)
        {
            SoundIoFormatS16NE     = (uint)SoundIoFormat.SoundIoFormatS16LE;
            SoundIoFormatU16NE     = (uint)SoundIoFormat.SoundIoFormatU16LE;
            SoundIoFormatS24NE     = (uint)SoundIoFormat.SoundIoFormatS24LE;
            SoundIoFormatU24NE     = (uint)SoundIoFormat.SoundIoFormatU24LE;
            SoundIoFormatS32NE     = (uint)SoundIoFormat.SoundIoFormatS32LE;
            SoundIoFormatU32NE     = (uint)SoundIoFormat.SoundIoFormatU32LE;
            SoundIoFormatFloat32NE = (uint)SoundIoFormat.SoundIoFormatFloat32LE;
            SoundIoFormatFloat64NE = (uint)SoundIoFormat.SoundIoFormatFloat64LE;

            SoundIoFormatS16FE     = (uint)SoundIoFormat.SoundIoFormatS16BE;
            SoundIoFormatU16FE     = (uint)SoundIoFormat.SoundIoFormatU16BE;
            SoundIoFormatS24FE     = (uint)SoundIoFormat.SoundIoFormatS24BE;
            SoundIoFormatU24FE     = (uint)SoundIoFormat.SoundIoFormatU24BE;
            SoundIoFormatS32FE     = (uint)SoundIoFormat.SoundIoFormatS32BE;
            SoundIoFormatU32FE     = (uint)SoundIoFormat.SoundIoFormatU32BE;
            SoundIoFormatFloat32FE = (uint)SoundIoFormat.SoundIoFormatFloat32BE;
            SoundIoFormatFloat64FE = (uint)SoundIoFormat.SoundIoFormatFloat64BE;
        }
    }
Exemple #4
0
        public bool TryGetExtension <T>(out T ext)
            where T : NativeExtension <Vk>
        {
            ext = LibraryLoader <Vk> .Load <T>
                      (this, SearchPaths, _extLoader ??= new VkLoader(this, PlatformLoaderBase.PlatformLoader));

            return(ext != null);
        }
Exemple #5
0
        public static Vk GetApi()
        {
            var sym = new VkLoader(PlatformLoaderBase.PlatformLoader);
            var ret = LibraryLoader <Vk> .Load(new VulkanLibraryNameContainer(), sym);

            sym.Vulkan = ret;
            return(ret);
        }
Exemple #6
0
        static NativeMethods()
        {
            IntPtr image;

            if (PlatformDetails.IsMac)
            {
                image = LibraryLoader.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Audio", "Codecs", "Opus", "Libs", "32bit", "libopus.dylib"));
            }
            else if (PlatformDetails.IsWindows)
            {
                if (!Environment.Is64BitProcess)
                {
                    image = LibraryLoader.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Audio", "Codecs", "Opus", "Libs", "32bit", "opus.dll"));
                }
                else
                {
                    image = LibraryLoader.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Audio", "Codecs", "Opus", "Libs", "64bit", "opus.dll"));
                }
            }
            else
            {
                image = LibraryLoader.Load("libopus.so.0");
                if (image.Equals(IntPtr.Zero))
                {
                    image = LibraryLoader.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Audio", "Codecs", "Opus", "Libs", "libopus.so"));
                }
            }

            if (image != IntPtr.Zero)
            {
                var type = typeof(NativeMethods);
                foreach (var member in type.GetFields(BindingFlags.Static | BindingFlags.NonPublic))
                {
                    var methodName = member.Name;
                    if (methodName == "opus_encoder_ctl_out")
                    {
                        methodName = "opus_encoder_ctl";
                    }
                    var fieldType = member.FieldType;
                    var ptr       = LibraryLoader.ResolveSymbol(image, methodName);
                    if (ptr == IntPtr.Zero)
                    {
                        throw new Exception(string.Format("Could not resolve symbol \"{0}\"", methodName));
                    }
                    member.SetValue(null, Marshal.GetDelegateForFunctionPointer(ptr, fieldType));
                }
            }
        }
        protected LibraryManager()
        {
            this.Status = "Please load library instance";

            this.OpenDirectoryCommand = ReactiveCommand.Create(async() =>
            {
                var dialog = new OpenFolderDialog();

                var result = await dialog.ShowAsync(App.MainWindow);

                if (string.IsNullOrEmpty(result))
                {
                    return;
                }

                this.Status = "Scanning library files...";

                // Scan files and create library
                var libraryFile = await Task.Run(() =>
                {
                    var directories = new string[] { result };

                    return(LibraryLoader.Load(directories));
                });

                // Load Library from library file
                this.Library = new Library(libraryFile);

                this.Status = "Searching for album artwork...";

                // Resolve artwork
                var libraryFileWithArtwork = await Task.Run(() =>
                {
                    LibraryArtworkLoader.Load(libraryFile);

                    return(libraryFile);
                });

                // Load Library from library file
                this.Library = new Library(libraryFileWithArtwork);

                this.Status = "Library Ready!";
            });
        }
Exemple #8
0
 static SDL()
 {
     LibraryLoader.Load("SDL2");
 }
Exemple #9
0
 public static GL GetApi()
 {
     return(LibraryLoader <GL> .Load(new OpenGLESLibraryNameContainer()));
 }
Exemple #10
0
 public static GL GetApi() => LibraryLoader <GL> .Load
     (new OpenGLESLibraryNameContainer(), SilkManager.Get <GLSymbolLoader>());
Exemple #11
0
 /// <summary>
 /// Gets an instance of the API.
 /// </summary>
 /// <returns>The instance.</returns>
 public static ALContext GetApi()
 {
     return(LibraryLoader.Load <ALContext>(new OpenALLibraryNameContainer()));
 }
Exemple #12
0
 static BASSNative()
 {
     LibraryLoader.Load("bass");
 }
        public static void InitNativeLibrary()
        {
#if _LOVE_SHARP_DEBUG_SELF_GUID_f320fj032jf2j3fj2039
            var debug_loader = LibraryLoader.Load(new LibraryConfig()
            {
                Win32 = new LibraryContent[]
                {
                    new LibraryContent("love.dll", () => System.IO.File.ReadAllBytes("love.dll")),
                },
            });
            functionAddrLoader = debug_loader.GetFunctionLoader("love.dll");
            Console.WriteLine(NativeLibraryUtil.NativlibTool.GetHashAssembly());
            return;
#endif

            byte[] Load(string zipName, string entryName)
            {
                var zs = NativlibTool.GetEmbedResource((name) => name.Contains(zipName));

                return(NativlibTool.GetZipFileContent(zs, entryName));
            }

            var winLibTableArray = new string[]
            {
                "SDL2.dll",
                "OpenAL32.dll",
                "mpg123.dll",
                "lua51.dll",
                "love.dll",
            };

            var linuxLibTableArray = new string[]
            {
                "libstdc++/libstdc++.so.6",
                "lib/x86_64-linux-gnu/libgcc_s.so.1",
                "lib/x86_64-linux-gnu/libz.so.1",
                "lib/x86_64-linux-gnu/libpng12.so.0",

                "usr/lib/x86_64-linux-gnu/libatomic.so.1",
                "usr/lib/x86_64-linux-gnu/libtheoradec.so.1",
                "usr/lib/x86_64-linux-gnu/libvorbis.so.0",
                "usr/lib/x86_64-linux-gnu/libvorbisfile.so.3",
                "usr/lib/x86_64-linux-gnu/libogg.so.0",
                "usr/lib/x86_64-linux-gnu/libfreetype.so.6",

                "usr/lib/libSDL2-2.0.so.0",
                "usr/lib/libluajit-5.1.so.2",
                "usr/lib/libmodplug.so.1",
                "usr/lib/x86_64-linux-gnu/libopenal.so.1",
                "usr/lib/x86_64-linux-gnu/libmpg123.so.0",
                "usr/lib/liblove-11.3.so",
            };

            var macLibTableArray = new string[]
            {
                "Ogg",
                "Theora",
                "Vorbis",
                "FreeType",
                "SDL2",
                "libmodplug",
                "Lua",
                "OpenAL-Soft",
                "mpg123",
                "love",
            };

            var pt = NativeLibraryUtil.LibraryLoader.GetPlatform(out var ixoader);
            Log.Info("Work on platform : " + pt);

            var config = new NativeLibraryUtil.LibraryConfig()
            {
                Linux64 = linuxLibTableArray.Select(libPath => new NativeLibraryUtil.LibraryContent(libPath, () => Load("native_lib_linux_x64", libPath))).ToArray(),
                Win32   = winLibTableArray.Select(libPath => new NativeLibraryUtil.LibraryContent(libPath, () => Load("native_lib_win_x86", libPath))).ToArray(),
                Win64   = winLibTableArray.Select(libPath => new NativeLibraryUtil.LibraryContent(libPath, () => Load("native_lib_win_x64", libPath))).ToArray(),
                Mac64   = macLibTableArray.Select(libPath => new NativeLibraryUtil.LibraryContent(libPath, () => Load("native_lib_mac_x64", libPath))).ToArray(),
            };

            var loader = NativeLibraryUtil.LibraryLoader.Load(config);

            switch (pt)
            {
            case NativeLibraryUtil.LibraryLoaderPlatform.Win32: functionAddrLoader = loader.GetFunctionLoader(winLibTableArray.Last()); break;

            case NativeLibraryUtil.LibraryLoaderPlatform.Win64: functionAddrLoader = loader.GetFunctionLoader(winLibTableArray.Last()); break;

            case NativeLibraryUtil.LibraryLoaderPlatform.Linux32: throw new Exception("unsupport platform : linux - 32 bit !");

            case NativeLibraryUtil.LibraryLoaderPlatform.Linux64: functionAddrLoader = loader.GetFunctionLoader(linuxLibTableArray.Last()); break;

            case NativeLibraryUtil.LibraryLoaderPlatform.Mac64: functionAddrLoader = loader.GetFunctionLoader(macLibTableArray.Last()); break;

            default: throw new Exception("unsupport platform !");
            }
        }
Exemple #14
0
 static GLFW3()
 {
     _handle = LibraryLoader.Load(typeof(GLFW3));
     glfwInit();
 }
Exemple #15
0
 static Opus()
 {
     _handle = LibraryLoader.Load(typeof(Opus));
 }
 static LZ4()
 {
     _handle = LibraryLoader.Load(typeof(LZ4));
 }
Exemple #17
0
 public static GL GetApi()
 {
     return(LibraryLoader <GL> .Load(new GLCoreLibraryNameContainer()));
 }
Exemple #18
0
 static BASSFXNative()
 {
     LibraryLoader.Load("bass_fx");
 }
 /// <summary>
 /// Loads the API for the given extension, using the base API.
 /// </summary>
 /// <param name="device">The device of the context.</param>
 /// <param name="baseAPI">The base API instance.</param>
 /// <typeparam name="TContextExtension">The extension type.</typeparam>
 /// <returns>The extension.</returns>
 /// <exception cref="ExtensionNotSupportedException">Thrown if the API doesn't support the extension.</exception>
 internal static TContextExtension LoadContextExtension <TContextExtension>(ALContext baseApi)
     where TContextExtension : NativeExtension <ALContext>
 {
     return(LibraryLoader.Load <TContextExtension, ALContext>(baseApi));
 }
Exemple #20
0
 /// <summary>
 /// Gets an instance of the API.
 /// </summary>
 /// <returns>The instance.</returns>
 public static EGL GetApi()
 {
     return(LibraryLoader <EGL> .Load(new EGLLibraryNameContainer()));
 }
Exemple #21
0
 public static CL GetApi()
 {
     return(LibraryLoader <CL> .Load(new OpenCLLibraryNameContainer()));
 }
 static STBTrueType()
 {
     _handle = LibraryLoader.Load(typeof(STBTrueType));
 }
    static PortAudio()
    {
        _handle = LibraryLoader.Load(typeof(PortAudio));

        Pa_Assert(Pa_Initialize());
    }