diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2021-01-18 22:56:18 +0100 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2021-01-18 22:56:18 +0100 |
| commit | 7c0d53684c638af98bece65edc7e744cae80806c (patch) | |
| tree | 5736e296cbc15832b565f0143e059fa21bf79f7b /src/main.cpp | |
| parent | 25125b2e23c02199bdefb3a638584465229fd833 (diff) | |
Event logic & handle resize & close for xcb windows
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 03db2ab..56e8d08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,17 +55,31 @@ int main() { while(wnd.isOpen) { wnd.poll_events(); + for (auto event: wnd.events) { + switch(event.type) { + case EVENT_TYPES::RESIZE: { + renderer.recreate_swapchain(); + renderer.mapped_data->width = event.width; + renderer.mapped_data->height = event.height; + break; + } + case EVENT_TYPES::QUIT: { + exit(1); + } + default: { + } + } + } + + wnd.events.clear(); + // To start a frame capture, call StartFrameCapture. // You can specify NULL, NULL for the device to capture on if you have only one device and // either no windows at all or only one window, and it will capture from that device. // See the documentation below for a longer explanation if(rdoc_api) rdoc_api->StartFrameCapture(NULL, NULL); - auto start = std::chrono::high_resolution_clock::now(); renderer.compute(); - auto end = std::chrono::high_resolution_clock::now(); - - std::cerr << "Image generation took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl; // stop the capture if(rdoc_api) rdoc_api->EndFrameCapture(NULL, NULL); |
