MayaFlux 0.4.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 561 of file BackendWindowHandler.cpp.

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