light/modules/renderer/private/backend/vk/context/surface.cpp
light7734 61473c2758
Some checks failed
continuous-integration/drone/push Build is failing
test(renderer): overhaul tests & fix many bugs
2025-10-07 16:09:50 +03:30

40 lines
1.1 KiB
C++

#include <renderer/backend/vk/context/instance.hpp>
#include <renderer/backend/vk/context/surface.hpp>
#include <surface/components.hpp>
namespace lt::renderer::vk {
Surface::Surface(IInstance *instance, const ecs::Entity &surface_entity)
: m_surface_entity(surface_entity)
, m_instance(static_cast<Instance *>(instance))
{
const auto &component = surface_entity.get<surface::SurfaceComponent>();
ensure(component.get_native_data().display, "Failed to initialize vk::Surface: null x-display");
ensure(component.get_native_data().window, "Failed to initialize vk::Surface: null x-window");
m_surface = m_instance->create_xlib_surface(
VkXlibSurfaceCreateInfoKHR {
.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR,
.dpy = component.get_native_data().display,
.window = component.get_native_data().window,
}
);
}
Surface::~Surface()
{
if (!m_instance)
{
return;
}
m_instance->destroy_surface(m_surface);
}
[[nodiscard]] auto Surface::get_framebuffer_size() const -> math::uvec2
{
return m_surface_entity.get<surface::SurfaceComponent>().get_resolution();
}
} // namespace lt::renderer::vk