vengine  0.0.1
3D graphics engine
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 static constexpr std::string_view DEFAULT_TITLE = "VEngine";
18 static constexpr uint32_t DEFAULT_WIDTH = 1920;
19 static constexpr uint32_t DEFAULT_HEIGHT = 1080;
20
21 ///
22 /// @class Window
23 /// @brief Class for window
24 /// @namespace ven
25 ///
26 class Window {
27
28 public:
29
30 explicit Window(const uint32_t width = DEFAULT_WIDTH, const uint32_t height = DEFAULT_HEIGHT) : m_window(createWindow(width, height, DEFAULT_TITLE.data())), m_width(width), m_height(height) { setWindowIcon("assets/icons/icon64x64.png"); }
31 ~Window() { glfwDestroyWindow(m_window); glfwTerminate(); m_window = nullptr; }
32
33 Window(const Window&) = delete;
34 Window& operator=(const Window&) = delete;
35 Window(Window&&) = delete;
36 Window& operator=(Window&&) = delete;
37
38 [[nodiscard]] GLFWwindow* createWindow(uint32_t width, uint32_t height, const std::string &title);
39 void createWindowSurface(VkInstance instance, VkSurfaceKHR* surface) const;
40
41 [[nodiscard]] GLFWwindow* getGLFWindow() const { return m_window; }
42
43 [[nodiscard]] VkExtent2D getExtent() const { return {m_width, m_height}; }
44 [[nodiscard]] bool wasWindowResized() const { return m_framebufferResized; }
46
47 void setFullscreen(bool fullscreen, uint32_t width, uint32_t height);
48 void setWindowIcon(const std::string& path);
49
50 private:
51
52 static void framebufferResizeCallback(GLFWwindow* window, int width, int height);
53
54 GLFWwindow* m_window{nullptr};
55 uint32_t m_width{0};
56 uint32_t m_height{0};
57
59
60 }; // class Window
61
62} // namespace ven
Class for window.
Definition Window.hpp:26
void createWindowSurface(VkInstance instance, VkSurfaceKHR *surface) const
Definition window.cpp:27
Window & operator=(Window &&)=delete
GLFWwindow * createWindow(uint32_t width, uint32_t height, const std::string &title)
Definition window.cpp:8
static void framebufferResizeCallback(GLFWwindow *window, int width, int height)
Definition window.cpp:34
Window(Window &&)=delete
Window(const Window &)=delete
GLFWwindow * getGLFWindow() const
Definition Window.hpp:41
uint32_t m_height
Definition Window.hpp:56
VkExtent2D getExtent() const
Definition Window.hpp:43
Window & operator=(const Window &)=delete
bool m_framebufferResized
Definition Window.hpp:58
uint32_t m_width
Definition Window.hpp:55
GLFWwindow * m_window
Definition Window.hpp:54
void setFullscreen(bool fullscreen, uint32_t width, uint32_t height)
Definition window.cpp:42
void setWindowIcon(const std::string &path)
Definition window.cpp:62
Window(const uint32_t width=DEFAULT_WIDTH, const uint32_t height=DEFAULT_HEIGHT)
Definition Window.hpp:30
void resetWindowResizedFlag()
Definition Window.hpp:45
bool wasWindowResized() const
Definition Window.hpp:44
static constexpr uint32_t DEFAULT_WIDTH
Definition Window.hpp:18
static constexpr uint32_t DEFAULT_HEIGHT
Definition Window.hpp:19
static constexpr std::string_view DEFAULT_TITLE
Definition Window.hpp:17