MayaFlux 0.1.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 56 of file VKContext.cpp.

57{
58 if (!window) {
60 "Cannot create surface: null window");
61 return nullptr;
62 }
63
64 auto* glfw_window = dynamic_cast<GlfwWindow*>(window.get());
65 if (!glfw_window) {
67 "Cannot create surface: window is not a GlfwWindow");
68 return nullptr;
69 }
70
71 GLFWwindow* glfw_handle = glfw_window->get_glfw_handle();
72 if (!glfw_handle) {
74 "Cannot create surface: null GLFW handle");
75 return nullptr;
76 }
77
78 VkSurfaceKHR c_surface;
79 VkResult result = glfwCreateWindowSurface(
80 static_cast<VkInstance>(m_instance.get_instance()),
81 glfw_handle,
82 nullptr,
83 &c_surface);
84
85 if (result != VK_SUCCESS) {
87 "Failed to create window surface");
88 return nullptr;
89 }
90
91 vk::SurfaceKHR surface(c_surface);
92 m_surfaces.push_back(surface);
93
95 "Surface created for window '{}'", window->get_create_info().title);
96
97 return surface;
98}
#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.

References MayaFlux::Journal::Core, 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: