// NOTE: Order matters. // Including glfw before Vulkan makes glfw not load Vulkan-specific functions #include #include #include #include #include #include #include "glfw.hpp" namespace ls { // GlfwState GlfwState::GlfwState() { assert(glfwInit() == GLFW_TRUE); }; std::vector GlfwState::get_vulkan_exts() { std::vector res; uint32_t glfw_exts_count = 0; const char** glfw_exts = glfwGetRequiredInstanceExtensions(&glfw_exts_count); for(int i = 0; i < glfw_exts_count; i++) { res.push_back(glfw_exts[i]); } return res; } // GlfwWindow GlfwWindow::GlfwWindow(GlfwState* state, uint32_t x_size, uint32_t y_size, std::string title) { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); this->__window = glfwCreateWindow(x_size, y_size, title.c_str(), NULL, NULL); }; void GlfwWindow::show() { glfwShowWindow(__window); } void GlfwWindow::set_title(const std::string title) { this->__title = title; glfwSetWindowTitle(this->__window, this->__title.c_str()); } VkResult GlfwWindow::__make_surface(VkInstance instance, VkSurfaceKHR* surface) { return glfwCreateWindowSurface(instance, this->__window, NULL, surface); } GLFWwindow* GlfwWindow::__get_backing() { return __window; } }