Example #1
0
        /// <summary>
        /// Create a new vulkan enabled window with GLFW.
        /// </summary>
        /// <param name="name">Caption of the window</param>
        /// <param name="_width">Width.</param>
        /// <param name="_height">Height.</param>
        /// <param name="vSync">Vertical synchronisation status for creating the swapchain.</param>
        public VkWindow(string name = "VkWindow", uint _width = 800, uint _height = 600, bool vSync = true)
        {
            Width  = _width;
            Height = _height;
            VSync  = vSync;

            Glfw3.Init();

            Glfw3.WindowHint(WindowAttribute.ClientApi, 0);
            Glfw3.WindowHint(WindowAttribute.Resizable, 1);

            hWin = Glfw3.CreateWindow((int)Width, (int)Height, name, MonitorHandle.Zero, IntPtr.Zero);

            if (hWin == IntPtr.Zero)
            {
                throw new Exception("[GLFW3] Unable to create vulkan Window");
            }

            Glfw3.SetKeyCallback(hWin, HandleKeyDelegate);
            Glfw3.SetMouseButtonPosCallback(hWin, HandleMouseButtonDelegate);
            Glfw3.SetCursorPosCallback(hWin, HandleCursorPosDelegate);
            Glfw3.SetScrollCallback(hWin, HandleScrollDelegate);
            Glfw3.SetCharCallback(hWin, HandleCharDelegate);

            windows.Add(hWin, this);
        }
Example #2
0
        public VkWindow(bool debugMarkers = false, string name = "VkWindow", uint _width = 1024, uint _height = 768, bool vSync = false)
        {
            currentWindow = this;

            width  = _width;
            height = _height;

            Glfw3.Init();

            Glfw3.WindowHint(WindowAttribute.ClientApi, 0);
            Glfw3.WindowHint(WindowAttribute.Resizable, 1);

            hWin = Glfw3.CreateWindow((int)width, (int)height, name, MonitorHandle.Zero, IntPtr.Zero);

            Glfw3.SetKeyCallback(hWin, HandleKeyDelegate);
            Glfw3.SetMouseButtonPosCallback(hWin, HandleMouseButtonDelegate);
            Glfw3.SetCursorPosCallback(hWin, HandleCursorPosDelegate);
            Glfw3.SetWindowSizeCallback(hWin, HandleWindowSizeDelegate);
            Glfw3.SetScrollCallback(hWin, HandleScrollDelegate);
            Glfw3.SetCharCallback(hWin, HandleCharDelegate);

            initVulkan(vSync, debugMarkers);
        }