37 lines
858 B
C++
37 lines
858 B
C++
|
#include "hk_window.hpp"
|
||
|
|
||
|
// std
|
||
|
#include <stdexcept>
|
||
|
|
||
|
namespace hk
|
||
|
{
|
||
|
Window::Window(int w, int h, const std::string& name)
|
||
|
: m_width(w), m_height(h), m_windowName(name)
|
||
|
{
|
||
|
initWindow();
|
||
|
}
|
||
|
|
||
|
Window::~Window()
|
||
|
{
|
||
|
glfwDestroyWindow(m_window);
|
||
|
glfwTerminate();
|
||
|
}
|
||
|
|
||
|
void Window::createWindowSurface(VkInstance instance, VkSurfaceKHR *surface)
|
||
|
{
|
||
|
if (glfwCreateWindowSurface(instance, m_window, nullptr, surface) != VK_SUCCESS)
|
||
|
{
|
||
|
throw std::runtime_error("failed to create window surface!");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Window::initWindow()
|
||
|
{
|
||
|
glfwInit();
|
||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||
|
|
||
|
m_window = glfwCreateWindow(m_width, m_height, m_windowName.c_str(), nullptr, nullptr);
|
||
|
}
|
||
|
|
||
|
}
|