Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Window.cpp
Go to the documentation of this file.
2
3#include <functional>
4#include <stdexcept>
5
8
9namespace EngineCore {
10 Window::Window(std::weak_ptr<InputHandler> inputHandler, GLFWframebuffersizefun windowResizeCallback) :
11 window(nullptr)
12 {
13 if (!glfwInit()) {
14 throw std::runtime_error("Failed to initialize glfw!");
15 return;
16 }
17
18 if (!glfwVulkanSupported()) {
19 throw std::runtime_error("Vulkan not supported by glfw!");
20 return;
21 }
22
23 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
24 glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
25
27 "Vulkan Schnee", nullptr, nullptr);
28
30 glfwSetWindowUserPointer(window, engine);
31
32 glfwSetFramebufferSizeCallback(window, windowResizeCallback);
33 setupInputHandler(inputHandler);
34 }
35
36 void Window::setupInputHandler(const std::weak_ptr<InputHandler> &inputHandler) {
37 if (inputHandler.expired()) throw std::runtime_error("Input handler could not be setup. Weak pointer has expired");
38
39 //std::shared_ptr<InputHandler> elevatedInputHandler = inputHandler.lock();
40
41 }
42
43 void Window::createSurface(VkInstance instance, VkSurfaceKHR &surface) {
44 if (glfwCreateWindowSurface(instance, window, nullptr, &surface) != VK_SUCCESS) {
45 throw std::runtime_error("failed to create window surface!");
46 }
47 }
48
49 GLFWwindow * Window::getWindowInstance() const {
50 return window;
51 }
52
54 glfwDestroyWindow(window);
55 glfwTerminate();
56 }
57}
constexpr int INITIAL_WINDOW_HEIGHT
Definition Settings.h:25
constexpr int INITIAL_WINDOW_WIDTH
Definition Settings.h:24
EngineCore::Engine * getEngineModule()
gets the pointer to the engine object
Definition Engine.cpp:1140
static EngineManager & getInstance()
gets a reference to the engine manager
Definition Engine.cpp:1135
GLFWwindow * getWindowInstance() const
Definition Window.cpp:49
Window(std::weak_ptr< InputHandler > inputHandler, GLFWframebuffersizefun windowResizeCallback)
Definition Window.cpp:10
void createSurface(VkInstance instance, VkSurfaceKHR &surface)
Definition Window.cpp:43
GLFWwindow * window
Definition Window.h:23
void setupInputHandler(const std::weak_ptr< InputHandler > &inputHandler)
Definition Window.cpp:36
Log category system implementation.