foo
[vktest3] / src / app.c
index 044a885..9a72309 100644 (file)
--- a/src/app.c
+++ b/src/app.c
@@ -3,6 +3,8 @@
 #include "app.h"
 #include "vk.h"
 
+static VkSemaphore sem_getimg;
+
 int app_init(void)
 {
        unsigned int flags;
@@ -10,17 +12,36 @@ int app_init(void)
        if(vk_init(VKINIT_DEPTH, &flags) == -1) {
                return -1;
        }
+
+       sem_getimg = vk_create_sem();
+       sem_draw = vk_create_sem();
        return 0;
 }
 
 void app_cleanup(void)
 {
+       vk_free_sem(sem_getimg);
+       vk_free_sem(sem_draw);
        vk_cleanup();
 }
 
 
 void app_display(void)
 {
+       int imgid;
+       VkCommandBuffer cmdbuf;
+
+       /* get the next image from the swap chain */
+       imgid = vk_next_image(sem_getimg);
+       cmdbuf = vk_get_cmdbuf(imgid);
+
+       /* TODO record */
+
+       /* submit the command buffer, wait for one semaphore, signal another */
+       vk_submit(cmdbuf, sem_getimg, sem_draw);
+
+       /* swap buffers after drawing is finished */
+       vk_present(sem_draw);
 }
 
 void app_reshape(int x, int y)