4 #include "windowview.h"
5 #include "windowview_backend.h"
10 VulkanWindowView::~VulkanWindowView()
15 void VulkanWindowView::render()
17 Device &device = static_cast<const WindowView *>(this)->device;
19 Semaphore *sem = semaphores+frame_index*2;
20 unsigned image_index = swap_chain->begin_frame(sem[0]);
21 current_target = &framebuffers[image_index];
23 if(!internal_renderer)
24 internal_renderer = new Renderer;
25 internal_renderer->begin(sem[0]);
26 View::render(*internal_renderer);
27 internal_renderer->end(sem[1]);
29 swap_chain->present_frame(sem[1]);
30 frame_index = (frame_index+1)%device.get_n_frames_in_flight();
32 device.get_destroy_queue().tick();
35 void VulkanWindowView::resize_framebuffer(unsigned w, unsigned h)
37 Device &device = static_cast<const WindowView *>(this)->device;
42 swap_chain = new SwapChain(w, h, device.get_n_frames_in_flight());
44 unsigned n_images = swap_chain->get_n_images();
45 framebuffers.reserve(n_images);
46 for(unsigned i=0; i<n_images; ++i)
48 const SwapChainTexture &image = swap_chain->get_image(i);
49 framebuffers.emplace_back((COLOR_ATTACHMENT, image.get_format()));
50 framebuffers.back().attach(COLOR_ATTACHMENT, swap_chain->get_image(i));
53 current_target = &framebuffers.front();