MayaFlux 0.5.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 563 of file BackendWindowHandler.cpp.

564{
565 if (window->is_graphics_registered() || find_window_context(window)) {
566 return false;
567 }
568
569 vk::SurfaceKHR surface = m_context.create_surface(window);
570 if (!surface) {
572 "Failed to create Vulkan surface for window '{}'",
573 window->get_create_info().title);
574 return false;
575 }
576
577 if (!m_context.update_present_family(surface)) {
579 "No presentation support for window '{}'", window->get_create_info().title);
580 m_context.destroy_surface(surface);
581 return false;
582 }
583
584 WindowRenderContext config;
585 config.window = window;
586 config.surface = surface;
587 config.swapchain = std::make_unique<VKSwapchain>();
588
589 if (!config.swapchain->create(m_context, surface, window->get_create_info())) {
591 "Failed to create swapchain for window '{}'", window->get_create_info().title);
592 return false;
593 }
594
595 if (!create_sync_objects(config)) {
597 "Failed to create sync objects for window '{}'",
598 window->get_create_info().title);
599 config.swapchain->cleanup();
600 m_context.destroy_surface(surface);
601 return false;
602 }
603
604 m_window_contexts.emplace_back(std::move(config));
605 window->set_graphics_registered(true);
606
607 window->set_event_callback([this, window_ptr = window](const WindowEvent& event) {
608 if (event.type == WindowEventType::WINDOW_RESIZED) {
609 auto* config = find_window_context(window_ptr);
610 if (config) {
611 config->needs_recreation = true;
612 }
613 }
614 });
615
617 "Registered window '{}' for graphics processing", window->get_create_info().title);
618
619 return true;
620}
#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:73
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: