vulkan: fix initialization if love.graphics is loaded before love.window.

This commit is contained in:
Sasha Szpakowski
2026-03-31 20:21:14 -03:00
parent e01908e342
commit 4d25b8c97a
+6
View File
@@ -31,6 +31,7 @@
#include <SDL3/SDL_vulkan.h>
#include <SDL3/SDL_hints.h>
#include <SDL3/SDL_init.h>
#include <algorithm>
#include <vector>
@@ -95,6 +96,10 @@ static void checkOptionalInstanceExtensions(OptionalInstanceExtensions& ext)
Graphics::Graphics()
: love::graphics::Graphics("love.graphics.vulkan")
{
// Needed for SDL_Vulkan_LoadLibrary, if graphics is loaded before the window.
if (!SDL_InitSubSystem(SDL_INIT_VIDEO))
throw love::Exception("Could not initialize SDL video subsystem (%s)", SDL_GetError());
if (!SDL_Vulkan_LoadLibrary(nullptr))
throw love::Exception("could not find vulkan");
@@ -192,6 +197,7 @@ Graphics::~Graphics()
vkDestroyInstance(instance, nullptr);
SDL_Vulkan_UnloadLibrary();
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
// START OVERRIDEN FUNCTIONS