vkcube: Add options --width and --height to specify width and height
authorNicolas Caramelli <caramelli.devel@gmail.com>
Fri, 8 Jan 2021 16:46:07 +0000 (17:46 +0100)
committerTony-LunarG <tony@lunarg.com>
Fri, 15 Jan 2021 22:31:28 +0000 (15:31 -0700)
Change-Id: Ie2533ad22e4bf9672f749138baddc0313169d09b

cube/cube.c
cube/cube.cpp

index 800a069..f00eae7 100644 (file)
@@ -3857,6 +3857,8 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
     demo->frameCount = INT32_MAX;
     /* Autodetect suitable / best GPU by default */
     demo->gpu_number = -1;
+    demo->width = 500;
+    demo->height = 500;
 
     for (int i = 1; i < argc; i++) {
         if (strcmp(argv[i], "--use_staging") == 0) {
@@ -3890,6 +3892,14 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
             i++;
             continue;
         }
+        if (strcmp(argv[i], "--width") == 0 && i < argc - 1 && sscanf(argv[i + 1], "%d", &demo->width) == 1 && demo->width > 0) {
+            i++;
+            continue;
+        }
+        if (strcmp(argv[i], "--height") == 0 && i < argc - 1 && sscanf(argv[i + 1], "%d", &demo->height) == 1 && demo->height > 0) {
+            i++;
+            continue;
+        }
         if (strcmp(argv[i], "--suppress_popups") == 0) {
             demo->suppress_popups = true;
             continue;
@@ -3918,6 +3928,7 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
             "\t[--incremental_present] [--display_timing]\n"
             "\t[--gpu_number <index of physical device>]\n"
             "\t[--present_mode <present mode enum>]\n"
+            "\t[--width <width>] [--height <height>]\n"
             "\t<present_mode_enum>\n"
             "\t\tVK_PRESENT_MODE_IMMEDIATE_KHR = %d\n"
             "\t\tVK_PRESENT_MODE_MAILBOX_KHR = %d\n"
@@ -3946,9 +3957,6 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
 
     demo_init_vk(demo);
 
-    demo->width = 500;
-    demo->height = 500;
-
     demo->spin_angle = 4.0f;
     demo->spin_increment = 0.2f;
     demo->pause = false;
index 8efea2a..69da9a9 100644 (file)
@@ -939,6 +939,8 @@ void Demo::init(int argc, char **argv) {
 
     presentMode = vk::PresentModeKHR::eFifo;
     frameCount = UINT32_MAX;
+    width = 500;
+    height = 500;
     use_xlib = false;
     /* Autodetect suitable / best GPU by default */
     gpu_number = -1;
@@ -970,6 +972,14 @@ void Demo::init(int argc, char **argv) {
             i++;
             continue;
         }
+        if (strcmp(argv[i], "--width") == 0 && i < argc - 1 && sscanf(argv[i + 1], "%" SCNu32, &width) == 1 && width > 0) {
+            i++;
+            continue;
+        }
+        if (strcmp(argv[i], "--height") == 0 && i < argc - 1 && sscanf(argv[i + 1], "%" SCNu32, &height) == 1 && height > 0) {
+            i++;
+            continue;
+        }
         if (strcmp(argv[i], "--suppress_popups") == 0) {
             suppress_popups = true;
             continue;
@@ -985,6 +995,7 @@ void Demo::init(int argc, char **argv) {
               << "\t[--break] [--c <framecount>] [--suppress_popups]\n"
               << "\t[--gpu_number <index of physical device>]\n"
               << "\t[--present_mode <present mode enum>]\n"
+              << "\t[--width <width>] [--height <height>]\n"
               << "\t<present_mode_enum>\n"
               << "\t\tVK_PRESENT_MODE_IMMEDIATE_KHR = " << VK_PRESENT_MODE_IMMEDIATE_KHR << "\n"
               << "\t\tVK_PRESENT_MODE_MAILBOX_KHR = " << VK_PRESENT_MODE_MAILBOX_KHR << "\n"
@@ -1006,9 +1017,6 @@ void Demo::init(int argc, char **argv) {
 
     init_vk();
 
-    width = 500;
-    height = 500;
-
     spin_angle = 4.0f;
     spin_increment = 0.2f;
     pause = false;