Skip to content

Instantly share code, notes, and snippets.

@cheery
Created February 28, 2016 12:15
Show Gist options
  • Save cheery/eaadc94051ad05379d1c to your computer and use it in GitHub Desktop.
Save cheery/eaadc94051ad05379d1c to your computer and use it in GitHub Desktop.
Here's how to create instance quickly in Vulkan
#include <stdio.h>
#include <stdlib.h>
#include <vulkan/vulkan.h>
static void check_impl(VkResult result, long line);
#define CHECK(x) (check_impl((x), __LINE__));
int main() {
VkInstance instance;
const char* instanceExtensions[] = { "VK_KHR_surface" };
VkInstanceCreateInfo instanceCreateInfo = {
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.enabledExtensionCount = 1,
.ppEnabledExtensionNames = instanceExtensions,
};
CHECK(vkCreateInstance(&instanceCreateInfo, NULL, &instance));
printf("Instance obtained\n");
return 0;
}
static void check_impl(VkResult result, long line) {
if (result != 0) {
printf("line %ld: VkResult %d\n", line, result);
}
}
@jeffro256
Copy link

Do you need to have Vulkan statically linked to do this?

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