vulkan_test2
diff src/wsys_x11.c @ 5:cec4b0e7fce8
created swapchain
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 22 Sep 2017 17:48:18 +0300 |
parents | c31c4115d44a |
children | 1dd2c7398afc |
line diff
1.1 --- a/src/wsys_x11.c Fri Sep 22 15:26:29 2017 +0300 1.2 +++ b/src/wsys_x11.c Fri Sep 22 17:48:18 2017 +0300 1.3 @@ -24,6 +24,8 @@ 1.4 1.5 static Display *dpy; 1.6 static Window win; 1.7 +static VkSurfaceKHR surf; 1.8 +static VkSwapchainKHR swapchain; 1.9 static Atom xa_wm_delete; 1.10 static int win_width, win_height; 1.11 static int win_mapped; 1.12 @@ -87,6 +89,14 @@ 1.13 XSelectInput(dpy, win, evmask); 1.14 XSetWMProtocols(dpy, win, &xa_wm_delete, 1); 1.15 1.16 + if(!(surf = vku_xlib_create_surface(dpy, win))) { 1.17 + fprintf(stderr, "failed to create vulkan surface for the window\n"); 1.18 + XDestroyWindow(dpy, win); 1.19 + XCloseDisplay(dpy); 1.20 + return -1; 1.21 + } 1.22 + /* swapchain gets created before the first reshape invocation */ 1.23 + 1.24 wsys_set_window_title("X11 window"); 1.25 XMapWindow(dpy, win); 1.26 1.27 @@ -206,6 +216,13 @@ 1.28 XEvent xev; 1.29 1.30 if(pending & RESHAPE) { 1.31 + VkSwapchainKHR sc; 1.32 + if(!(sc = vku_create_swapchain(surf, win_width, win_height, 2, VK_PRESENT_MODE_FIFO_KHR, swapchain))) { 1.33 + fprintf(stderr, "Failed to create %dx%d double-buffered swapchain\n", win_width, win_height); 1.34 + return -1; 1.35 + } 1.36 + swapchain = sc; 1.37 + 1.38 if(cb.reshape) { 1.39 cb.reshape(win_width, win_height); 1.40 }