-
Notifications
You must be signed in to change notification settings - Fork 0
/
spock_window.cpp
29 lines (24 loc) · 913 Bytes
/
spock_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
#include "spock_window.hpp"
#include <GLFW/glfw3.h>
#include <stdexcept>
#include <vulkan/vulkan_core.h>
namespace spock {
SpockWindow::SpockWindow(int width, int height, std::string name) : width(width), height(height), windowName(name) {
initWindow();
};
SpockWindow::~SpockWindow() {
glfwDestroyWindow(window);
glfwTerminate();
}
void SpockWindow::initWindow() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
window = glfwCreateWindow(width, height, windowName.c_str(), nullptr, nullptr);
}
void SpockWindow::createWindowSurface(VkInstance instance, VkSurfaceKHR* surface) {
if (glfwCreateWindowSurface(instance,window, nullptr, surface) != VK_SUCCESS) {
throw std::runtime_error("Failed to create surface");
}
}
} // namespace spock