MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ create_surface()

vk::SurfaceKHR MayaFlux::Core::VKContext::create_surface ( std::shared_ptr< Window window)

Create surface from window's native handles.

Parameters
windowWindow to create surface for
Returns
Surface handle, or null on failure

Definition at line 58 of file VKContext.cpp.

59{
60 if (!window) {
62 "Cannot create surface: null window");
63 return nullptr;
64 }
65
66 auto* glfw_window = dynamic_cast<GlfwWindow*>(window.get());
67 if (!glfw_window) {
69 "Cannot create surface: window is not a GlfwWindow");
70 return nullptr;
71 }
72
73 GLFWwindow* glfw_handle = glfw_window->get_glfw_handle();
74 if (!glfw_handle) {
76 "Cannot create surface: null GLFW handle");
77 return nullptr;
78 }
79
80 VkSurfaceKHR c_surface;
81 VkResult result = Parallel::dispatch_main_sync([&]() {
82 return glfwCreateWindowSurface(
83 static_cast<VkInstance>(m_instance.get_instance()),
84 glfw_handle,
85 nullptr,
86 &c_surface);
87 });
88
89 if (result != VK_SUCCESS) {
91 "Failed to create window surface");
92 return nullptr;
93 }
94
95 vk::SurfaceKHR surface(c_surface);
96 m_surfaces.push_back(surface);
97
99 "Surface created for window '{}'", window->get_create_info().title);
100
101 return surface;
102}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
std::vector< vk::SurfaceKHR > m_surfaces
vk::Instance get_instance() const
Get the Vulkan instance handle.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.
auto dispatch_main_sync(Func &&func, Args &&... args) -> decltype(auto)
Definition Parallel.hpp:110

References MayaFlux::Journal::Core, MayaFlux::Parallel::dispatch_main_sync(), MayaFlux::Core::VKInstance::get_instance(), MayaFlux::Journal::GraphicsBackend, m_instance, m_surfaces, MF_ERROR, and MF_INFO.

Referenced by MayaFlux::Core::BackendWindowHandler::register_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: