예제 #1
0
        private void loadNativeLibraries()
        {
            LDEBUG($"Available native libraries: {String.Join(", ", NativeLoader.AvailableResources.Select(n => n.Substring(16)))}");

            NativeLoader.Logger = LWARN;

            try
            {
                NativeLoader.LoadUnmanagedLibrary("glfw3", "glfw3.dll");
                LINFO($"Loaded native library for glfw3 (took {NativeLoader.LastLoadTime.TotalMilliseconds:.00} ms).");
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to load native library glfw3, reason: {e.Message}");
            }

            try
            {
                NativeLoader.LoadUnmanagedLibrary("oal", "soft_oal.dll");
                LINFO($"Loaded native library for openal (took {NativeLoader.LastLoadTime.TotalMilliseconds:.00} ms).");
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to load native library oal, reason: {e.Message}");
            }
        }
예제 #2
0
        private void dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                Window.Dispose();

                Audio.AudioEngine.Shutdown();

                Glfw.Terminate();

                NativeLoader.UnloadLibraries();
                _isDisposed = true;
            }
        }
예제 #3
0
        // Dynamically loads the functions from the library
        private static void LoadFunctions()
        {
            Stopwatch timer = Stopwatch.StartNew();

            IntPtr module = NativeLoader.GetLibraryHandle("glfw3");

            _glfwInit                                 = NativeLoader.LoadFunction <Delegates.glfwInit>(module, "glfwInit");
            _glfwTerminate                            = NativeLoader.LoadFunction <Delegates.glfwTerminate>(module, "glfwTerminate");
            _glfwSetErrorCallback                     = NativeLoader.LoadFunction <Delegates.glfwSetErrorCallback>(module, "glfwSetErrorCallback");
            _glfwWindowHint                           = NativeLoader.LoadFunction <Delegates.glfwWindowHint>(module, "glfwWindowHint");
            _glfwCreateWindow                         = NativeLoader.LoadFunction <Delegates.glfwCreateWindow>(module, "glfwCreateWindow");
            _glfwDestroyWindow                        = NativeLoader.LoadFunction <Delegates.glfwDestroyWindow>(module, "glfwDestroyWindow");
            _glfwWindowShouldClose                    = NativeLoader.LoadFunction <Delegates.glfwWindowShouldClose>(module, "glfwWindowShouldClose");
            _glfwPollEvents                           = NativeLoader.LoadFunction <Delegates.glfwPollEvents>(module, "glfwPollEvents");
            _glfwShowWindow                           = NativeLoader.LoadFunction <Delegates.glfwShowWindow>(module, "glfwShowWindow");
            _glfwVulkanSupported                      = NativeLoader.LoadFunction <Delegates.glfwVulkanSupported>(module, "glfwVulkanSupported");
            _glfwGetWindowAttrib                      = NativeLoader.LoadFunction <Delegates.glfwGetWindowAttrib>(module, "glfwGetWindowAttrib");
            _glfwSetWindowAttrib                      = NativeLoader.LoadFunction <Delegates.glfwSetWindowAttrib>(module, "glfwSetWindowAttrib");
            _glfwGetWindowSize                        = NativeLoader.LoadFunction <Delegates.glfwGetWindowSize>(module, "glfwGetWindowSize");
            _glfwSetWindowSize                        = NativeLoader.LoadFunction <Delegates.glfwSetWindowSize>(module, "glfwSetWindowSize");
            _glfwGetWindowPos                         = NativeLoader.LoadFunction <Delegates.glfwGetWindowPos>(module, "glfwGetWindowPos");
            _glfwSetWindowPos                         = NativeLoader.LoadFunction <Delegates.glfwSetWindowPos>(module, "glfwSetWindowPos");
            _glfwGetPrimaryMonitor                    = NativeLoader.LoadFunction <Delegates.glfwGetPrimaryMonitor>(module, "glfwGetPrimaryMonitor");
            _glfwGetMonitors                          = NativeLoader.LoadFunction <Delegates.glfwGetMonitors>(module, "glfwGetMonitors");
            _glfwGetMonitorPos                        = NativeLoader.LoadFunction <Delegates.glfwGetMonitorPos>(module, "glfwGetMonitorPos");
            _glfwGetVideoModes                        = NativeLoader.LoadFunction <Delegates.glfwGetVideoModes>(module, "glfwGetVideoModes");
            _glfwGetVideoMode                         = NativeLoader.LoadFunction <Delegates.glfwGetVideoMode>(module, "glfwGetVideoMode");
            _glfwSetWindowTitle                       = NativeLoader.LoadFunction <Delegates.glfwSetWindowTitle>(module, "glfwSetWindowTitle");
            _glfwSetMouseButtonCallback               = NativeLoader.LoadFunction <Delegates.glfwSetMouseButtonCallback>(module, "glfwSetMouseButtonCallback");
            _glfwSetScrollCallback                    = NativeLoader.LoadFunction <Delegates.glfwSetScrollCallback>(module, "glfwSetScrollCallback");
            _glfwSetKeyCallback                       = NativeLoader.LoadFunction <Delegates.glfwSetKeyCallback>(module, "glfwSetKeyCallback");
            _glfwGetCursorPos                         = NativeLoader.LoadFunction <Delegates.glfwGetCursorPos>(module, "glfwGetCursorPos");
            _glfwSetInputMode                         = NativeLoader.LoadFunction <Delegates.glfwSetInputMode>(module, "glfwSetInputMode");
            _glfwSetCursorEnterCallback               = NativeLoader.LoadFunction <Delegates.glfwSetCursorEnterCallback>(module, "glfwSetCursorEnterCallback");
            _glfwSetWindowPosCallback                 = NativeLoader.LoadFunction <Delegates.glfwSetWindowPosCallback>(module, "glfwSetWindowPosCallback");
            _glfwSetWindowSizeCallback                = NativeLoader.LoadFunction <Delegates.glfwSetWindowSizeCallback>(module, "glfwSetWindowSizeCallback");
            _glfwSetWindowFocusCallback               = NativeLoader.LoadFunction <Delegates.glfwSetWindowFocusCallback>(module, "glfwSetWindowFocusCallback");
            _glfwSetWindowIconifyCallback             = NativeLoader.LoadFunction <Delegates.glfwSetWindowIconifyCallback>(module, "glfwSetWindowIconifyCallback");
            _glfwGetPhysicalDevicePresentationSupport = NativeLoader.LoadFunction <Delegates.glfwGetPhysicalDevicePresentationSupport>(module, "glfwGetPhysicalDevicePresentationSupport");
            _glfwCreateWindowSurface                  = NativeLoader.LoadFunction <Delegates.glfwCreateWindowSurface>(module, "glfwCreateWindowSurface");

            LoadTime = timer.Elapsed;
        }