MayaFlux 0.1.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 184 of file BackendWindowHandler.cpp.

185{
186 if (window->is_graphics_registered() || find_window_context(window)) {
187 return false;
188 }
189
190 vk::SurfaceKHR surface = m_context.create_surface(window);
191 if (!surface) {
193 "Failed to create Vulkan surface for window '{}'",
194 window->get_create_info().title);
195 return false;
196 }
197
198 if (!m_context.update_present_family(surface)) {
200 "No presentation support for window '{}'", window->get_create_info().title);
201 m_context.destroy_surface(surface);
202 return false;
203 }
204
205 WindowRenderContext config;
206 config.window = window;
207 config.surface = surface;
208 config.swapchain = std::make_unique<VKSwapchain>();
209
210 if (!config.swapchain->create(m_context, surface, window->get_create_info())) {
212 "Failed to create swapchain for window '{}'", window->get_create_info().title);
213 return false;
214 }
215
216 if (!create_sync_objects(config)) {
218 "Failed to create sync objects for window '{}'",
219 window->get_create_info().title);
220 config.swapchain->cleanup();
221 m_context.destroy_surface(surface);
222 return false;
223 }
224
225 m_window_contexts.emplace_back(std::move(config));
226 window->set_graphics_registered(true);
227
228 window->set_event_callback([this, window_ptr = window](const WindowEvent& event) {
229 if (event.type == WindowEventType::WINDOW_RESIZED) {
230 auto* config = find_window_context(window_ptr);
231 if (config) {
232 config->needs_recreation = true;
233 }
234 }
235 });
236
238 "Registered window '{}' for graphics processing", window->get_create_info().title);
239
240 return true;
241}
#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:56
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: