Verify we have glfw extension support in program
This commit is contained in:
parent
e08f86aefa
commit
f47e0682d2
1 changed files with 23 additions and 0 deletions
23
src/main.c
23
src/main.c
|
|
@ -1,6 +1,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
|
|
@ -11,6 +12,22 @@ typedef struct Application {
|
|||
VkInstance instance;
|
||||
} Application;
|
||||
|
||||
bool verifyGlfwExtensionSupport(uint32_t extensionCount,
|
||||
VkExtensionProperties *extentions,
|
||||
uint32_t glfwExtensionCount,
|
||||
const char **glfwExtensions) {
|
||||
uint32_t correctExtensions = 0;
|
||||
for (uint32_t i = 0; i < glfwExtensionCount; i++) {
|
||||
for (uint32_t j = 0; j < extensionCount; j++) {
|
||||
if (strcmp(glfwExtensions[i], extentions[j].extensionName) == 0) {
|
||||
correctExtensions++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return correctExtensions == glfwExtensionCount;
|
||||
}
|
||||
|
||||
void createInstance(Application *app) {
|
||||
VkApplicationInfo appInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
|
|
@ -44,6 +61,12 @@ void createInstance(Application *app) {
|
|||
VkExtensionProperties extensions[extensionCount];
|
||||
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, extensions);
|
||||
|
||||
if (!verifyGlfwExtensionSupport(extensionCount, extensions, glfwExtensionCount,
|
||||
glfwExtensions)) {
|
||||
fprintf(stderr, "Failed to find all required vulkan extentions for glfw\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Instance Extentions Available:\n");
|
||||
for (uint i = 0; i < extensionCount; i++) {
|
||||
printf("\t%s\n", extensions[i].extensionName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue