Esempio n. 1
0
        /// <summary>
        /// Create a Surface object for a GLFW3 window.
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="window"></param>
        /// <returns></returns>
        public unsafe static Surface CreateGlfw3Surface(this Instance instance, Window window)
        {
            Result result = Glfw3.CreateWindowSurface(instance.RawHandle, window.handle, null, out ulong surfaceHandle);

            if (SharpVkException.IsError(result))
            {
                throw SharpVkException.Create(result);
            }

            return(Surface.CreateFromHandle(instance, surfaceHandle));
        }
Esempio n. 2
0
        public InputAction GetMouseButtonState(MouseButton mouseButton)
        {
            try
            {
                ErrorUtility.Bind();

                InputAction result = Glfw3.GetMouseButton(this.handle, mouseButton);

                ErrorUtility.ThrowOnError();

                return(result);
            }
            finally
            {
                ErrorUtility.Unbind();
            }
        }
Esempio n. 3
0
        public InputAction GetKeyState(Key key)
        {
            try
            {
                ErrorUtility.Bind();

                InputAction result = Glfw3.GetKey(this.handle, key);

                ErrorUtility.ThrowOnError();

                return(result);
            }
            finally
            {
                ErrorUtility.Unbind();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Closes the window.
        /// </summary>
        public void Close()
        {
            if (!this.isDisposed)
            {
                try
                {
                    ErrorUtility.Bind();

                    Glfw3.DestroyWindow(this.handle);

                    this.isDisposed = true;

                    ErrorUtility.ThrowOnError();
                }
                finally
                {
                    ErrorUtility.Unbind();
                }
            }
        }
Esempio n. 5
0
        internal Window(int width, int height, string title, MonitorHandle monitor, Dictionary <WindowAttribute, int> windowHints)
        {
            try
            {
                ErrorUtility.Bind();

                if (windowHints != null)
                {
                    foreach (var hintPair in windowHints)
                    {
                        Glfw3.WindowHint(hintPair.Key, hintPair.Value);
                    }
                }

                this.handle = Glfw3.CreateWindow(width, height, title, monitor, WindowHandle.Zero);

                ErrorUtility.ThrowOnError();
            }
            finally
            {
                ErrorUtility.Unbind();
            }
        }
Esempio n. 6
0
 public Window(int width, int height, string title)
 {
     this.handle = Glfw3.CreateWindow(width, height, title, IntPtr.Zero, IntPtr.Zero);
 }