Exemple #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);
        }
Exemple #2
0
 private static void SetCallbacks(Window window)
 {
     Glfw3.SetCharCallback(window.Handle, new CharDelegate((handle, codepoint) =>
                                                           Console.WriteLine("CharDelegate called (codepoint: " + codepoint + ")")));
     Glfw3.SetScrollCallback(window.Handle, new ScrollDelegate((handle, xoffset, yoffset) =>
                                                               Console.WriteLine("ScrollDelegate called (xoffset: " + xoffset + ", yoffset: " + yoffset + ")")));
     Glfw3.SetCursorPosCallback(window.Handle, new CursorPosDelegate((handle, xpos, ypos) =>
                                                                     Console.WriteLine("CursorPosDelegate called (xpos: " + xpos + ", ypos: " + ypos + ")")));
     Glfw3.SetMouseButtonPosCallback(window.Handle, new MouseButtonDelegate((handle, button, action, mods) =>
                                                                            Console.WriteLine("MouseButtonDelegate called (button: " + button + ", action: " +
                                                                                              Enum.GetName(typeof(InputAction), action) + ", mods: " + Enum.GetName(typeof(Modifier), mods) + ")")));
 }
Exemple #3
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);
        }