7#define GLFW_INCLUDE_VULKAN
15 const std::vector<const char*>& required_extensions)
21 "Vulkan context initialization requested, but graphics API is not set to Vulkan!");
25 std::vector<const char*> extensions;
31 for (
const char* ext : required_extensions) {
32 if (std::ranges::find(extensions, ext) == extensions.end()) {
33 extensions.push_back(ext);
37 extensions = required_extensions;
42 "Failed to initialize Vulkan instance!");
48 "Failed to initialize Vulkan device!");
54 "Vulkan context initialized successfully.");
62 "Cannot create surface: null window");
66 auto* glfw_window =
dynamic_cast<GlfwWindow*
>(window.get());
69 "Cannot create surface: window is not a GlfwWindow");
73 GLFWwindow* glfw_handle = glfw_window->get_glfw_handle();
76 "Cannot create surface: null GLFW handle");
80 VkSurfaceKHR c_surface;
82 return glfwCreateWindowSurface(
89 if (result != VK_SUCCESS) {
91 "Failed to create window surface");
95 vk::SurfaceKHR surface(c_surface);
99 "Surface created for window '{}'", window->get_create_info().title);
109 auto it = std::ranges::find(
m_surfaces, surface);
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
static std::vector< const char * > get_required_instance_extensions()
Retrieves the list of required Vulkan instance extensions for GLFW.
static void configure(const GlfwPreInitConfig &config)
Configures GLFW with pre-initialization hints.
Platform-agnostic window wrapper.
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.
std::vector< vk::SurfaceKHR > m_surfaces
void cleanup()
Cleanup all Vulkan resources.
GlobalGraphicsConfig m_graphics_config
bool initialize(const GlobalGraphicsConfig &graphics_config, bool enable_validation=true, const std::vector< const char * > &required_extensions={})
Initialize Vulkan context.
void destroy_surface(vk::SurfaceKHR surface)
Destroy a specific surface Called when window is unregistered.
void cleanup()
Cleanup device resources.
bool update_presentation_queue(vk::SurfaceKHR surface)
Update presentation queue family for a specific surface.
bool initialize(vk::Instance instance, vk::SurfaceKHR temp_surface, const GraphicsBackendInfo &backend_info)
Initialize device (pick physical device and create logical device)
void cleanup()
Cleanup Vulkan instance.
vk::Instance get_instance() const
Get the Vulkan instance handle.
bool initialize(bool enable_validation=true, const std::vector< const char * > &required_extensions={})
Initialize Vulkan instance.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.
auto dispatch_main_sync(Func &&func, Args &&... args) -> decltype(auto)
@ GLFW
GLFW3 (default, cross-platform)
GlfwPreInitConfig glfw_preinit_config
Pre-initialization configuration for GLFW.
GraphicsBackendInfo backend_info
Graphics backend configuration.
WindowingBackend windowing_backend
Selected windowing backend.
GraphicsApi requested_api
Selected graphics API for rendering.