MayaFlux 1.0.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 580 of file BackendWindowHandler.cpp.

581{
582 if (window->is_graphics_registered() || find_window_context(window)) {
583 return false;
584 }
585
586 vk::SurfaceKHR surface = m_context.create_surface(window);
587 if (!surface) {
589 "Failed to create Vulkan surface for window '{}'",
590 window->get_create_info().title);
591 return false;
592 }
593
596 "Graphics queue family cannot present to window '{}'", window->get_create_info().title);
597 m_context.destroy_surface(surface);
598 return false;
599 }
600
601 WindowRenderContext config;
602 config.window = window;
603 config.surface = surface;
604 config.swapchain = std::make_unique<VKSwapchain>();
605
606 if (!config.swapchain->create(m_context, surface, window->get_create_info())) {
608 "Failed to create swapchain for window '{}'", window->get_create_info().title);
609 m_context.destroy_surface(surface);
610 return false;
611 }
612
613 if (!create_sync_objects(config)) {
615 "Failed to create sync objects for window '{}'",
616 window->get_create_info().title);
617 config.swapchain->cleanup();
618 m_context.destroy_surface(surface);
619 return false;
620 }
621
622 m_window_contexts.emplace_back(std::move(config));
623 window->set_graphics_registered(true);
624
625 window->set_event_callback([this, window_ptr = window](const WindowEvent& event) {
626 if (event.type == WindowEventType::WINDOW_RESIZED
627 || event.type == WindowEventType::FRAMEBUFFER_RESIZED) {
628 auto* config = find_window_context(window_ptr);
629 if (config) {
630 config->needs_recreation = true;
631 }
632 }
633 });
634
636 "Registered window '{}' for graphics processing", window->get_create_info().title);
637
638 return true;
639}
#define MF_INFO(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
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 graphics_family_can_present(vk::SurfaceKHR surface) const
Confirm the graphics family presents to a surface.
Definition VKContext.hpp:79
vk::SurfaceKHR create_surface(std::shared_ptr< Window > window)
Create surface from window's native handles.
Definition VKContext.cpp:74
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::Core::FRAMEBUFFER_RESIZED, MayaFlux::Core::VKContext::graphics_family_can_present(), 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::WindowRenderContext::window, window, and MayaFlux::Core::WINDOW_RESIZED.

+ Here is the call graph for this function: