38 fprintf(stderr,
"glfwInit failed\n");
41 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
42 GLFWwindow *win = glfwCreateWindow(1280, 720,
"monad-engine vulkan preview",
nullptr,
nullptr);
45 fprintf(stderr,
"glfwCreateWindow failed (does the system support Vulkan?)\n");
49 glfwSetFramebufferSizeCallback(win, OnResize);
59 printf(
"[vk preview] device + swapchain online (%u images, %ux%u)\n",
62 double t0 = glfwGetTime();
63 while (!glfwWindowShouldClose(win))
66 if (glfwGetKey(win, GLFW_KEY_ESCAPE) == GLFW_PRESS)
68 glfwSetWindowShouldClose(win, GLFW_TRUE);
72 float t =
static_cast<float>(glfwGetTime() - t0);
73 float r = 0.5f + 0.5f * std::sin(t * 0.7f);
74 float g = 0.5f + 0.5f * std::sin(t * 0.9f + 2.0f);
75 float b = 0.5f + 0.5f * std::sin(t * 1.1f + 4.0f);
78 if (!ok || g_framebufferResized)
81 g_framebufferResized =
false;
86 catch (
const std::exception &ex)
88 fprintf(stderr,
"[vk preview] fatal: %s\n", ex.what());
89 glfwDestroyWindow(win);
94 glfwDestroyWindow(win);
Vulkan instance + physical/logical device + queue selection.
Owns the Vulkan instance, surface (tied to a GLFW window), physical + logical device,...