aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorladevieq <qladevie@wanadev.fr>2021-01-19 09:05:02 +0100
committerladevieq <qladevie@wanadev.fr>2021-01-19 09:05:02 +0100
commitaa96b2c7b6b5675871f8432dd71af6a6d79c65d2 (patch)
treeab79e215ffdec623347d2fe13106826b32ebc93f /src/main.cpp
parent7c0d53684c638af98bece65edc7e744cae80806c (diff)
Fix swapchain extent
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 56e8d08..b67d5f8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,14 +42,15 @@ int main() {
#endif
// Image dimensions
- // const float aspect_ratio = 16.0 / 9.0;
- const float aspect_ratio = 1;
- const uint32_t width = 400;
+ const float aspect_ratio = 16.0 / 9.0;
+ // const float aspect_ratio = 1;
+ const uint32_t width = 1920;
const uint32_t height = width / aspect_ratio;
window wnd { width , height };
auto inputs = create_inputs(width, height);
+ auto canRender = true;
vkrenderer renderer { wnd, inputs };
while(wnd.isOpen) {
@@ -58,9 +59,15 @@ int main() {
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;
+
+ if (event.width == 0 && event.height == 0) {
+ canRender = false;
+ } else {
+ canRender = true;
+ renderer.recreate_swapchain();
+ }
break;
}
case EVENT_TYPES::QUIT: {
@@ -79,7 +86,9 @@ int main() {
// See the documentation below for a longer explanation
if(rdoc_api) rdoc_api->StartFrameCapture(NULL, NULL);
- renderer.compute();
+ if (canRender) {
+ renderer.compute();
+ }
// stop the capture
if(rdoc_api) rdoc_api->EndFrameCapture(NULL, NULL);