Updated the window to hold the vulkan context and a vulkan surface as well as providing a cast operator for the surface
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "vulkan/basalt_window.h"
|
||||
#include "vulkan/basalt_context.h"
|
||||
|
||||
basalt::Window::Window(Window&& other) noexcept
|
||||
{
|
||||
@@ -6,11 +7,12 @@ basalt::Window::Window(Window&& other) noexcept
|
||||
this->window_title = other.window_title;
|
||||
this->height = other.height;
|
||||
this->width = other.width;
|
||||
this->ctx = other.ctx;
|
||||
other.height = 0;
|
||||
other.width = 0;
|
||||
other.window = nullptr;
|
||||
other.window_title = nullptr;
|
||||
|
||||
other.ctx = nullptr;
|
||||
}
|
||||
|
||||
basalt::Window& basalt::Window::operator=(Window&& other) noexcept
|
||||
@@ -21,25 +23,30 @@ basalt::Window& basalt::Window::operator=(Window&& other) noexcept
|
||||
this->window_title = other.window_title;
|
||||
this->height = other.height;
|
||||
this->width = other.width;
|
||||
this->ctx = other.ctx;
|
||||
other.height = 0;
|
||||
other.width = 0;
|
||||
other.window = nullptr;
|
||||
other.window_title = nullptr;
|
||||
other.ctx = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
basalt::Window::Window(uint16_t width, uint16_t height, const char* title) :
|
||||
width(width), height(height), window_title(title)
|
||||
basalt::Window::Window(basalt::Context& ctx, uint16_t width, uint16_t height, const char* title) :
|
||||
ctx(&ctx), width(width), height(height), window_title(title)
|
||||
{
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
||||
this->window = glfwCreateWindow(width, height, title, nullptr, nullptr);
|
||||
VkResult err = VK_SUCCESS;
|
||||
VK_ASSERT(glfwCreateWindowSurface(*this->ctx, this->window, this->ctx->vk_alloc, &this->surface), "Failed to create vulkan window surface\n\tAt %s:%d\n\tError %s\n");
|
||||
}
|
||||
|
||||
basalt::Window::~Window(void) noexcept
|
||||
{
|
||||
vkDestroySurfaceKHR(*this->ctx, this->surface, this->ctx->vk_alloc);
|
||||
glfwDestroyWindow(this->window);
|
||||
}
|
||||
|
||||
@@ -66,7 +73,8 @@ void basalt::Window::swap(Window& other) noexcept
|
||||
basalt::Window::operator GLFWwindow* (void) const noexcept
|
||||
{ return this->window; }
|
||||
|
||||
basalt::Window::operator VkSurfaceKHR(void) const noexcept
|
||||
{ return this->surface; }
|
||||
|
||||
const bool basalt::Window::should_close(void) const noexcept
|
||||
{
|
||||
return glfwWindowShouldClose(this->window);
|
||||
}
|
||||
{ return glfwWindowShouldClose(this->window); }
|
||||
|
||||
Reference in New Issue
Block a user