coral_window.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <string>
  3. #define GLFW_INCLUDE_VULKAN
  4. #include <GLFW/glfw3.h>
  5. #include <vulkan/vulkan.h>
  6. namespace coral_3d
  7. {
  8. class coral_window final
  9. {
  10. public:
  11. coral_window(int width, int height, const std::string& name);
  12. ~coral_window();
  13. coral_window(const coral_window&) = delete;
  14. coral_window& operator=(const coral_window&) = delete;
  15. bool should_close() const { return glfwWindowShouldClose(pWindow_); }
  16. VkExtent2D get_extent() const { return { static_cast<uint32_t>(width_), static_cast<uint32_t>(height_)}; }
  17. bool was_window_resized() const { return is_framebuffer_resized_; }
  18. void reset_window_resized() { is_framebuffer_resized_ = false; }
  19. GLFWwindow* get_glfw_window() const { return pWindow_; }
  20. void create_window_surface(VkInstance instance, VkSurfaceKHR* surface);
  21. private:
  22. static void framebuffer_resize_callback(GLFWwindow* pWindow, int width, int height);
  23. void init_window();
  24. int width_;
  25. int height_;
  26. bool is_framebuffer_resized_{ false };
  27. std::string window_name_;
  28. GLFWwindow* pWindow_;
  29. };
  30. }