Files
LearningVulkan/GlfwWindowManager.h
2026-01-05 10:36:27 -05:00

62 lines
1.5 KiB
C++

#pragma once
#include <string>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.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();
bool ShouldClose() const;
void PollEvents();
void WaitEvents() const;
void SetTitle(const std::string& Title);
GLFWwindow* GetHandle() const { return Window; }
uint32_t GetWidth() const { return Width; }
uint32_t GetHeight() const { return Height; }
const std::string& GetTitle() const { return Title; }
bool IsInitialized() const { return Window != nullptr; }
VkSurfaceKHR CreateSurface(VkInstance Instance) const;
void SetResizeCallback(GLFWwindowsizefun Callback);
void SetKeyCallback(GLFWkeyfun Callback);
void SetMouseButtonCallback(GLFWmousebuttonfun Callback);
void SetCursorPositionCallback(GLFWcursorposfun Callback);
void SetScrollCallback(GLFWscrollfun Callback);
private:
// static bool bGlfwInitialized;
void InitializeGlfw();
GLFWwindow* Window = nullptr;
std::string Title;
uint32_t Width = 0;
uint32_t Height = 0;
void DestroyWindow();
};