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

◆ register_window()

bool MayaFlux::Core::BackendWindowHandler::register_window ( const std::shared_ptr< Window > &  window)

Definition at line 319 of file BackendWindowHandler.cpp.

320{
321 if (window->is_graphics_registered() || find_window_context(window)) {
322 return false;
323 }
324
325 vk::SurfaceKHR surface = m_context.create_surface(window);
326 if (!surface) {
328 "Failed to create Vulkan surface for window '{}'",
329 window->get_create_info().title);
330 return false;
331 }
332
333 if (!m_context.update_present_family(surface)) {
335 "No presentation support for window '{}'", window->get_create_info().title);
336 m_context.destroy_surface(surface);
337 return false;
338 }
339
340 WindowRenderContext config;
341 config.window = window;
342 config.surface = surface;
343 config.swapchain = std::make_unique<VKSwapchain>();
344
345 if (!config.swapchain->create(m_context, surface, window->get_create_info())) {
347 "Failed to create swapchain for window '{}'", window->get_create_info().title);
348 return false;
349 }
350
351 if (!create_sync_objects(config)) {
353 "Failed to create sync objects for window '{}'",
354 window->get_create_info().title);
355 config.swapchain->cleanup();
356 m_context.destroy_surface(surface);
357 return false;
358 }
359
360 m_window_contexts.emplace_back(std::move(config));
361 window->set_graphics_registered(true);
362
363 window->set_event_callback([this, window_ptr = window](const WindowEvent& event) {
364 if (event.type == WindowEventType::WINDOW_RESIZED) {
365 auto* config = find_window_context(window_ptr);
366 if (config) {
367 config->needs_recreation = true;
368 }
369 }
370 });
371
373 "Registered window '{}' for graphics processing", window->get_create_info().title);
374
375 return true;
376}
#define MF_INFO(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
std::vector< WindowRenderContext > m_window_contexts
bool create_sync_objects(WindowRenderContext &config)
Create synchronization objects for a window's swapchain.
WindowRenderContext * find_window_context(const std::shared_ptr< Window > &window)
bool update_present_family(vk::SurfaceKHR surface)
Update presentation support for a surface.
vk::SurfaceKHR create_surface(std::shared_ptr< Window > window)
Create surface from window's native handles.
Definition VKContext.cpp:58
void destroy_surface(vk::SurfaceKHR surface)
Destroy a specific surface Called when window is unregistered.
@ GraphicsSubsystem
Graphics subsystem operations (Vulkan, rendering pipeline)
@ GraphicsCallback
Graphics/visual rendering callback - frame-rate real-time.
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Core::VKContext::create_surface(), create_sync_objects(), MayaFlux::Core::VKContext::destroy_surface(), find_window_context(), MayaFlux::Journal::GraphicsCallback, m_context, m_window_contexts, MF_RT_ERROR, MayaFlux::Core::WindowRenderContext::surface, MayaFlux::Core::WindowRenderContext::swapchain, MayaFlux::Core::WindowEvent::type, MayaFlux::Core::VKContext::update_present_family(), MayaFlux::Core::WindowRenderContext::window, and MayaFlux::Core::WINDOW_RESIZED.

+ Here is the call graph for this function: