Skip to content

Instantly share code, notes, and snippets.

@icculus
Created September 3, 2017 18:47
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icculus/ad23f873393423e1f1069502b92ad035 to your computer and use it in GitHub Desktop.
Save icculus/ad23f873393423e1f1069502b92ad035 to your computer and use it in GitHub Desktop.
SDL vulkan explanation...
/*
Ok, I answered too quickly, and Twitter is terrible for this, so have a gist.
You call this function twice: the first time with a NULL and it just sets
extension_count to the number of strings it plans to give you, so you can
allocate space for them and call the function again.
*/
// (you should check return values for errors in all this, but whatever.)
unsigned int count = 0;
const char **names = NULL;
SDL_Vulkan_GetInstanceExtensions(window, &count, NULL);
// now count is (probably) 2. Now you can make space:
names = new const char *[count];
// now call again with that not-NULL array you just allocated.
SDL_Vulkan_GetInstanceExtensions(window, &count, names);
// Now names should have (count) strings in it:
for (unsigned int i = 0; i < count; i++) {
printf("Extension %d: %s\n", i, names[i]);
}
// use it for VkInstanceCreateInfo and when you're done, free it:
delete[] names;
// Ship your successful C++ game and retire a millionaire. THE END. --ryan.
@but0n
Copy link

but0n commented Jul 10, 2018

Hi, it still returns as 0 here 😕
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment