+ atexit(cleanup);
+
+ if (!init()) {
+ return 1;
+ }
+
+ /* reshape window once just in case */
+
+ glfwGetWindowSize(win, &win_w, &win_h);
+ clb_reshape(win, win_w, win_h);
+
+ /* event loop */
+
+ while(!glfwWindowShouldClose(win)) {
+ display();
+ glfwPollEvents();
+ }
+
+ return 0;
+}
+
+/* static functions */
+
+static bool
+init()
+{
+ /* initialize GLFW */
+
+ if (!glfwInit()) {
+ fprintf(stderr, "Failed to initialize GLFW.\n");
+ return false;
+ }
+
+ if (glfwVulkanSupported() != GLFW_TRUE) {
+ fprintf(stderr, "Vulkan is not supported on this device.\n");
+ return false;
+ }
+
+ /* initialize Vulkan context */
+
+ if (!vk_init_ctx_for_rendering(&vk_core)) {
+ fprintf(stderr, "Failed to initialize Vulkan context.\n");
+ return false;
+ }
+
+ memset(&vk_swap, 0, sizeof vk_swap);
+
+ /* create window */
+
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+ win = glfwCreateWindow(win_w, win_h, "helloworld rt", 0, 0);
+
+ if (!win) {
+ fprintf(stderr, "Failed to create GLFW window\n");
+ return false;
+ }
+
+ /* create (Xcb) surface */
+
+ glfwGetFramebufferSize(win, &win_h, &win_h);
+ if (glfwCreateWindowSurface(vk_core.inst, win, 0, &vk_swap.surface)
+ != VK_SUCCESS) {
+ fprintf(stderr, "Failed to create XCB surface.\n");
+ return false;
+ }
+
+ /* create Vulkan swapchain */
+
+ /* aquire images? */
+
+ /* create shaders */
+
+ /* create semaphores? */
+
+ /* create renderer */
+
+ /* set GLFW callbacks */
+
+ glfwSetKeyCallback(win, clb_key);
+ glfwSetWindowSizeCallback(win, clb_reshape);
+
+ /*
+ glfwSetCursorPosCallback(win, clb_motion);
+ glfwSetMouseButtonCallback(win, clb_mouse);
+ */
+
+ return true;
+}
+
+static void
+display()
+{
+}
+
+static void
+cleanup()
+{
+ vk_cleanup_ctx(&vk_core);
+ glfwTerminate();
+}
+
+/* glfw callbacks */
+
+static void
+clb_key(GLFWwindow *win, int key, int scancode,
+ int action, int mods)
+{
+ if (action == GLFW_PRESS) {
+ switch(key) {
+ case GLFW_KEY_ESCAPE:
+ glfwSetWindowShouldClose(win, GLFW_TRUE);
+ return;
+ }
+ }
+}
+
+static void
+clb_reshape(GLFWwindow *win, int width, int height)
+{
+ /* set viewport */
+
+ win_w = width;
+ win_h = height;