summaryrefslogtreecommitdiff
path: root/engine/xe_window.hpp
blob: 02f3e3d6a86b817172bfb01d119eb08e215b3f44 (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
39
40
41
42
#pragma once

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

#include <GLFW/glfw3.h>
#include <GLFW/glfw3.h>
#include <stdexcept>
#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;

};
 
}