7 int win_width, win_height;
9 static int rpass, pipeln, fb;
10 static VkSemaphore sem_getimg, sem_draw;
17 if(vk_init(VKINIT_DEPTH, &flags) == -1) {
21 if(!(queue = vk_getq(VKQ_GFX | VKQ_PRESENT, 0))) {
25 rpass = vk_create_rpass();
28 vk_fb_size(fb, win_width, win_height);
29 vk_fb_rpass(fb, rpass);
31 pipeln = vk_create_pipeln();
34 sem_getimg = vk_create_sem();
35 sem_draw = vk_create_sem();
39 void app_cleanup(void)
41 vk_free_sem(sem_getimg);
42 vk_free_sem(sem_draw);
47 void app_display(void)
50 VkCommandBuffer cmdbuf;
52 /* get the next image from the swap chain */
53 imgid = vk_next_image(sem_getimg);
54 cmdbuf = vk_get_cmdbuf(imgid);
57 VkCommandBufferBeginInfo cmdbegin = {0};
58 VkRenderPassBeginInfo rpbegin = {0};
61 cmdbegin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
62 cmdbegin.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
64 if(vkBeginCommandBuffer(cmdbuf, &cmdbegin) != 0) {
65 fprintf(stderr, "failed to begin command buffer recording\n");
69 clear.color.float32[0] = 0.5f;
70 clear.color.float32[1] = 0.1f;
71 clear.color.float32[2] = 0.2f;
72 clear.color.float32[3] = 1.0f;
74 rpbegin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
78 /* submit the command buffer, wait for one semaphore, signal another */
79 vk_submit(queue, cmdbuf, sem_getimg, sem_draw);
81 /* swap buffers after drawing is finished */
82 vk_present(queue, imgid, sem_draw);
85 void app_reshape(int x, int y)
87 if(vk_reshape(x, y) == -1) {
92 void app_keyboard(int key, int press)
103 void app_mouse(int bn, int press, int x, int y)
107 void app_motion(int x, int y)