コード例 #1
0
        /// <summary>
        /// Creates a new instance of the GlfwProvider class.
        /// </summary>
        static GlfwProvider()
        {
            GLFW = new Lazy <Glfw>
                   (
                () =>
            {
                var glfw = Glfw.GetApi();
                glfw.Init();
                glfw.SetErrorCallback(Glfw.ErrorCallback);

                return(glfw);
            }
                   );
        }
コード例 #2
0
        /// <summary>
        /// Unloads the loaded <see cref="GLFW" /> interface implementation.
        /// </summary>
        public static void Unload()
        {
            GLFW.Value.Terminate();
            GLFW = new Lazy <Glfw>
                   (
                () =>
            {
                var glfw = Glfw.GetApi();
                glfw.Init();
                glfw.SetErrorCallback(Glfw.ErrorCallback);

                return(glfw);
            }
                   );
        }
コード例 #3
0
        /// <summary>
        /// Creates a new instance of the GlfwProvider class.
        /// </summary>
        static GlfwProvider()
        {
            ThreadDispatcher = new Dispatcher();
            GLFW             = new Lazy <Glfw>(() =>
            {
                if (ThreadDispatcher == null)
                {
                    ThreadDispatcher = new Dispatcher();
                }

                var glfw = Glfw.GetApi();

                ThreadDispatcher.Invoke(() =>
                {
                    glfw.Init();
                    glfw.SetErrorCallback(Glfw.ErrorCallback);
                });

                return(glfw);
            });
        }
コード例 #4
0
ファイル: GlfwProvider.cs プロジェクト: jinyuttt/Silk.NET
        /// <summary>
        /// Creates a new instance of the GlfwProvider class.
        /// </summary>
        static unsafe GlfwProvider()
        {
            GLFW = new Lazy <Glfw>
                   (
                () =>
            {
                var glfw = Glfw.GetApi();

                if (!glfw.Init())
                {
                    var code = glfw.GetError(out byte *pDesc);
                    var len  = new ReadOnlySpan <byte>(pDesc, int.MaxValue).IndexOf((byte)'\0');
                    var desc = len <= 0 ? "Unknown" : System.Text.Encoding.UTF8.GetString(pDesc, len);
                    throw new GlfwException($"GLFW Init failed, {code}: {desc}");
                }

                glfw.SetErrorCallback(Glfw.ErrorCallback);

                return(glfw);
            }
                   );
        }