You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

// NOTE: Order matters.
// Including glfw before Vulkan makes glfw not load Vulkan-specific functions
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>
#include <string>
#include <vector>
#include <assert.h>
#include <vulkan/vulkan_core.h>
#include "glfw.hpp"
namespace ls {
// GlfwState
GlfwState::GlfwState() {
assert(glfwInit() == GLFW_TRUE);
};
std::vector<const char*> GlfwState::get_vulkan_exts() {
std::vector<const char*> 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;
}
}