vengine  0.1.0
3D graphics engine made with Vulkan
Loading...
Searching...
No Matches
Window.hpp
Go to the documentation of this file.
1///
2/// @file Window.hpp
3/// @brief This file contains the Window class
4/// @namespace ven
5///
6
7#pragma once
8
9#include <string>
10
11#define GLFW_INCLUDE_VULKAN
12#include <GLFW/glfw3.h>
13#include <vulkan/vulkan.h>
14
15namespace ven {
16
17 class Window {
18
19 public:
20
21 Window(const uint32_t width, const uint32_t height, const std::string &title) : m_window(createWindow(width, height, title)), m_width(width), m_height(height) {};
22 ~Window() { glfwDestroyWindow(m_window); glfwTerminate(); m_window = nullptr;};
23
24 [[nodiscard]] GLFWwindow* createWindow(uint32_t width, uint32_t height, const std::string &title);
25 void createWindowSurface(VkInstance instance, VkSurfaceKHR* surface) const;
26
27 [[nodiscard]] GLFWwindow* getGLFWindow() const { return m_window; };
28
29 [[nodiscard]] VkExtent2D getExtent() const { return {m_width, m_height}; };
30 [[nodiscard]] bool wasWindowResized() const { return m_framebufferResized; }
32
33 private:
34
35 static void framebufferResizeCallback(GLFWwindow* window, int width, int height);
36
37 GLFWwindow* m_window{nullptr};
38 uint32_t m_width;
39 uint32_t m_height;
40
42
43 }; // class Window
44
45} // namespace ven
void createWindowSurface(VkInstance instance, VkSurfaceKHR *surface) const
Definition window.cpp:24
GLFWwindow * createWindow(uint32_t width, uint32_t height, const std::string &title)
Definition window.cpp:5
static void framebufferResizeCallback(GLFWwindow *window, int width, int height)
Definition window.cpp:31
GLFWwindow * getGLFWindow() const
Definition Window.hpp:27
uint32_t m_height
Definition Window.hpp:39
VkExtent2D getExtent() const
Definition Window.hpp:29
bool m_framebufferResized
Definition Window.hpp:41
uint32_t m_width
Definition Window.hpp:38
GLFWwindow * m_window
Definition Window.hpp:37
Window(const uint32_t width, const uint32_t height, const std::string &title)
Definition Window.hpp:21
void resetWindowResizedFlag()
Definition Window.hpp:31
bool wasWindowResized() const
Definition Window.hpp:30