summaryrefslogtreecommitdiff
path: root/engine/xe_window.hpp
blob: bf80bd7f36aa323764bcdd85d7d74419a6aa58b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include <vulkan/vulkan_core.h>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

#include <string>
namespace xe {
    
class XeWindow {
  public:
    XeWindow(int w, int h, std::string name);
    ~XeWindow();

    XeWindow(const XeWindow &) = delete;
    XeWindow &operator=(const XeWindow &);

    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;
};
 
}