I’m trying to port over a vulkan framework to SDL2, but having some issues. I’m currently at the point of trying to create a vulkan surface, like this (simplified):
void createSurface() {
VkSurfaceKHR surface;
if ( !SDL_Vulkan_CreateSurface(sdl_window, instance, &surface) ) {
throw std::runtime_error("failed to create surface!");
}
}
But I’m a bit stuck on how to properly create instance
. I’ve read in the API that " instance
must have been created with extensions returned by SDL_Vulkan_GetInstanceExtensions() enabled."
But how do we directly use SDL_Vulkan_GetInstanceExtensions
to create a VkInstance
object though? I’m currently using SDL_Vulkan_GetInstanceExtensions
like this to get extension names:
std::vector<const char *> getRequiredExtensions() {
unsigned int sdlExtensionCount = 0;
const char **sdlExtensions;
if( !SDL_Vulkan_GetInstanceExtensions(sdl_window, &sdlExtensionCount, nullptr) ){
std::runtime_error("failed ! ");
}
std::vector<const char *> extensions;
if( !SDL_Vulkan_GetInstanceExtensions(sdl_window, &sdlExtensionCount, extensions.data())){
std::runtime_error("failed ! ");
}
return extensions;
}