Add window surface creation to glfwinfo

The glfwinfo tool now attempts Vulkan surface creation via
glfwCreateWindowSurface and reports the results.

(cherry picked from commit 0beadfdc66)
This commit is contained in:
Camilla Löwy 2021-04-11 21:26:27 +02:00
parent 05e28537a3
commit c7a5333873

View File

@ -753,6 +753,17 @@ int main(int argc, char** argv)
if (list_extensions)
list_context_extensions(client, major, minor);
glfwDestroyWindow(window);
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
printf("Vulkan loader: %s\n",
glfwVulkanSupported() ? "available" : "missing");
@ -851,6 +862,19 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
if (re)
{
VkSurfaceKHR surface = VK_NULL_HANDLE;
if (glfwCreateWindowSurface(instance, window, NULL, &surface) == VK_SUCCESS)
{
printf("Vulkan window surface created successfully\n");
vkDestroySurfaceKHR(instance, surface, NULL);
}
else
printf("Failed to create Vulkan window surface\n");
}
free((void*) re);
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, instance);
@ -937,6 +961,8 @@ int main(int argc, char** argv)
vkDestroyInstance(instance, NULL);
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}