-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.cpp
36 lines (30 loc) · 851 Bytes
/
Window.cpp
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
#include "Window.h"
Window::Window() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
}
void Window::CreateWin() {
if (!resizable) {
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
}
window = glfwCreateWindow(800, 600, "Vulkan window", nullptr, nullptr);
Render.InitRenderer(WindowTitle, window);
glfwSetWindowUserPointer(window, &Render);
glfwSetFramebufferSizeCallback(window, Render.framebufferResizeCallback);
}
bool Window::Mainloop() {
if (!glfwWindowShouldClose(window)) {
glfwPollEvents();
Render.drawFrame();
vkDeviceWaitIdle(Render.device);
return false;
} else {
vkDeviceWaitIdle(Render.device);
return true;
}
}
void Window::CloseWindow() {
Render.DestructRenderer();
glfwDestroyWindow(window);
glfwTerminate();
}