-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlve_window.cpp
More file actions
37 lines (29 loc) · 1.08 KB
/
lve_window.cpp
File metadata and controls
37 lines (29 loc) · 1.08 KB
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
37
#include "lve_window.hpp"
namespace lve {
LveWindow::LveWindow(int w, int h, std::string t) : width(w), height(h), title(t){
initWindow();
};
LveWindow::~LveWindow() {
glfwDestroyWindow(window);
glfwTerminate();
}
void LveWindow::initWindow() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr);
glfwSetWindowUserPointer(window, this);
glfwSetFramebufferSizeCallback(window, framebufferResizeCallback);
}
void LveWindow::framebufferResizeCallback(GLFWwindow* window, int width, int height) {
auto lveWindow = reinterpret_cast<LveWindow*>(glfwGetWindowUserPointer(window));
lveWindow->framebufferResized = true;
lveWindow->width = width;
lveWindow->height = height;
}
void LveWindow::createWindowSurface(VkInstance instance, VkSurfaceKHR* surface) {
if (glfwCreateWindowSurface(instance, window, nullptr, surface) != VK_SUCCESS) {
throw std::runtime_error("failed to create window surface!");
}
}
}