minecraftvulkan/engine/xe_window.hpp

38 lines
982 B
C++
Raw Normal View History

2022-09-19 01:20:51 +00:00
#pragma once
#include <vulkan/vulkan_core.h>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <string>
namespace xe {
2022-09-25 01:16:13 +00:00
class Window {
2022-09-19 01:20:51 +00:00
public:
2022-09-25 01:16:13 +00:00
Window(int w, int h, std::string name);
~Window();
2022-09-19 01:20:51 +00:00
2022-09-25 01:16:13 +00:00
Window(const Window &) = delete;
Window &operator=(const Window &);
2022-09-19 01:20:51 +00:00
bool shouldClose() { return glfwWindowShouldClose(window); }
VkExtent2D getExtent() { return { static_cast<uint32_t>(width), static_cast<uint32_t>(height)}; }
bool wasWindowResized() { return frameBufferResized; }
void resetWindowResizedFlag() { frameBufferResized = false; }
GLFWwindow *getGLFWwindow() const { return window; }
void createWindowSurface(VkInstance instance, VkSurfaceKHR *surface);
private:
static void framebufferResizeCallback(GLFWwindow *window, int width, int height);
void initWindow();
int width;
int height;
bool frameBufferResized = false;
std::string windowName;
GLFWwindow *window;
};
}