68 lines
1.6 KiB
C++
68 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#define VK_USE_PLATFORM_WIN32_KHR
|
|
#define GLFW_INCLUDE_VULKAN
|
|
#include <GLFW/glfw3.h>
|
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
|
#include <GLFW/glfw3native.h>
|
|
|
|
struct FWindowConfig
|
|
{
|
|
std::string Title = "Learning Vulkan";
|
|
uint32_t Width = 800;
|
|
uint32_t Height = 600;
|
|
bool bResizable = false;
|
|
bool bFullscreen = false;
|
|
};
|
|
|
|
class GlfwWindowManager
|
|
{
|
|
public:
|
|
GlfwWindowManager();
|
|
~GlfwWindowManager();
|
|
|
|
// GlfwWindowManager(const GlfwWindowManager&) = delete;
|
|
// GlfwWindowManager& operator=(const GlfwWindowManager&) = delete;
|
|
|
|
// GlfwWindowManager(GlfwWindowManager&& Other) noexcept;
|
|
// GlfwWindowManager& operator=(GlfwWindowManager&& Other) noexcept;
|
|
|
|
void Initialize(const FWindowConfig& Config);
|
|
void Cleanup(VkInstance Instance);
|
|
|
|
bool ShouldClose() const;
|
|
void PollEvents();
|
|
void WaitEvents() const;
|
|
void SetTitle(const std::string& Title);
|
|
|
|
GLFWwindow* GetHandle() const { return Window; }
|
|
uint32_t GetWidth() const { return Config.Width; }
|
|
uint32_t GetHeight() const { return Config.Height; }
|
|
const std::string& GetTitle() const { return Config.Title; }
|
|
|
|
bool IsInitialized() const { return Window && Surface; }
|
|
|
|
void SetResizeCallback(GLFWwindowsizefun Callback);
|
|
void SetKeyCallback(GLFWkeyfun Callback);
|
|
void SetMouseButtonCallback(GLFWmousebuttonfun Callback);
|
|
void SetCursorPositionCallback(GLFWcursorposfun Callback);
|
|
void SetScrollCallback(GLFWscrollfun Callback);
|
|
|
|
void CreateSurface(VkInstance Instance);
|
|
|
|
static VkSurfaceKHR Surface;
|
|
|
|
static GLFWwindow* Window;
|
|
|
|
private:
|
|
FWindowConfig Config;
|
|
|
|
// VkSurfaceKHR Surface = VK_NULL_HANDLE;
|
|
|
|
void InitializeGlfw();
|
|
|
|
void DestroyWindow();
|
|
};
|