예제 #1
0
        /// <summary>
        ///
        /// </summary>
        public NativeLibrary()
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                this.library = Kernel32.LoadLibrary("vulkan-1.dll");
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                this.library = LibDl.dlopen("libvulkan.so.1", LibDl.RtldNow);

                if (this.library == IntPtr.Zero)
                {
                    this.library = LibDl.dlopen("libvulkan.so", LibDl.RtldNow);
                }
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                this.library = LibDlOSX.dlopen("libvulkan.dylib.1", LibDlOSX.RtldNow);

                if (this.library == IntPtr.Zero)
                {
                    this.library = LibDlOSX.dlopen("libvulkan.dylib", LibDlOSX.RtldNow);
                }
            }
            else
            {
                throw new NotSupportedException($"{RuntimeInformation.OSDescription} is not a supported platform for SharpVK.");
            }
        }
 private static IntPtr dlopen(string fileName, int flags)
 {
     try
     {
         return(LibDlSo2.dlopen(fileName, flags));
     }
     catch (DllNotFoundException)
     {
         return(LibDl.dlopen(fileName, flags));
     }
 }