project-aster/aster/surface.cpp

34 lines
837 B
C++

// =============================================
// Aster: surface.cpp
// Copyright (c) 2020-2024 Anish Bhobe
// =============================================
#include "surface.h"
#include "context.h"
#include "window.h"
void
Surface::Init(Context *context, const Window *window)
{
assert(!m_Surface);
VkSurfaceKHR surface;
auto result = Cast<vk::Result>(
glfwCreateWindowSurface(Cast<VkInstance>(context->m_Instance), window->m_Window, nullptr, &surface));
ERROR_IF(Failed(result), "Failed to create Surface with {}", result)
THEN_ABORT(result)
ELSE_DEBUG("Surface Created");
m_Surface = vk::SurfaceKHR(surface);
}
void
Surface::Destroy(const Context *context)
{
if (!m_Surface)
return;
context->m_Instance.destroy(Take(m_Surface), nullptr);
DEBUG("Surface Destroyed");
}