From: Tony-LunarG Date: Tue, 4 Jun 2019 20:11:43 +0000 (-0600) Subject: cube: Add usage message on Windows X-Git-Tag: upstream/1.2.179~257 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d74734f77e4677ace6add7f16d43a282b6660e0b;p=platform%2Fupstream%2FVulkan-Tools.git cube: Add usage message on Windows Change-Id: Id709544863b50def407d7e18c330914bebc9c03a --- diff --git a/cube/cube.c b/cube/cube.c index ff4d5a6..12b7369 100644 --- a/cube/cube.c +++ b/cube/cube.c @@ -3711,17 +3711,31 @@ static void demo_init(struct demo *demo, int argc, char **argv) { #if defined(ANDROID) ERR_EXIT("Usage: vkcube [--validate]\n", "Usage"); #else - fprintf(stderr, - "Usage:\n %s\t[--use_staging] [--validate] [--validate-checks-disabled] [--break]\n" - "\t[--c ] [--suppress_popups] [--incremental_present] [--display_timing]\n" - "\t[--present_mode ]\n" - "\t \tVK_PRESENT_MODE_IMMEDIATE_KHR = %d\n" - "\t\t\t\tVK_PRESENT_MODE_MAILBOX_KHR = %d\n" - "\t\t\t\tVK_PRESENT_MODE_FIFO_KHR = %d\n" - "\t\t\t\tVK_PRESENT_MODE_FIFO_RELAXED_KHR = %d\n", - APP_SHORT_NAME, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_FIFO_KHR, - VK_PRESENT_MODE_FIFO_RELAXED_KHR); + char *message = + "Usage:\n %s\t[--use_staging] [--validate] [--validate-checks-disabled]\n" + "\t[--break] [--c ] [--suppress_popups]\n" + "\t[--incremental_present] [--display_timing]\n" + "\t[--present_mode ]\n" + "\t\n" + "\t\tVK_PRESENT_MODE_IMMEDIATE_KHR = %d\n" + "\t\tVK_PRESENT_MODE_MAILBOX_KHR = %d\n" + "\t\tVK_PRESENT_MODE_FIFO_KHR = %d\n" + "\t\tVK_PRESENT_MODE_FIFO_RELAXED_KHR = %d\n"; + int length = snprintf(NULL, 0, message, APP_SHORT_NAME, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_MAILBOX_KHR, + VK_PRESENT_MODE_FIFO_KHR, VK_PRESENT_MODE_FIFO_RELAXED_KHR); + char *usage = (char *)malloc(length + 1); + if (!usage) { + exit(1); + } + snprintf(usage, length + 1, message, APP_SHORT_NAME, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_MAILBOX_KHR, + VK_PRESENT_MODE_FIFO_KHR, VK_PRESENT_MODE_FIFO_RELAXED_KHR); +#if defined(_WIN32) + if (!demo->suppress_popups) MessageBox(NULL, usage, "Usage Error", MB_OK); +#else + fprintf(stderr, usage); fflush(stderr); +#endif + free(usage); exit(1); #endif } diff --git a/cube/cube.cpp b/cube/cube.cpp index 965f6fa..4f3032a 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #define VULKAN_HPP_NO_SMART_HANDLE @@ -930,18 +932,22 @@ void Demo::init(int argc, char **argv) { continue; } - fprintf(stderr, - "Usage:\n %s [--use_staging] [--validate] [--break] [--c ] \n" - " [--suppress_popups] [--present_mode {0,1,2,3}]\n" - "\n" - "Options for --present_mode:\n" - " %d: VK_PRESENT_MODE_IMMEDIATE_KHR\n" - " %d: VK_PRESENT_MODE_MAILBOX_KHR\n" - " %d: VK_PRESENT_MODE_FIFO_KHR (default)\n" - " %d: VK_PRESENT_MODE_FIFO_RELAXED_KHR\n", - APP_SHORT_NAME, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_FIFO_KHR, - VK_PRESENT_MODE_FIFO_RELAXED_KHR); - fflush(stderr); + std::stringstream usage; + usage << "Usage:\n " << APP_SHORT_NAME << "\t[--use_staging] [--validate]\n" + << "\t[--break] [--c ] [--suppress_popups]\n" + << "\t[--present_mode ]\n" + << "\t\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" + << "\t\tVK_PRESENT_MODE_FIFO_KHR = " << VK_PRESENT_MODE_FIFO_KHR << "\n" + << "\t\tVK_PRESENT_MODE_FIFO_RELAXED_KHR = " << VK_PRESENT_MODE_FIFO_RELAXED_KHR; + +#if defined(_WIN32) + if (!suppress_popups) MessageBox(NULL, usage.str().c_str(), "Usage Error", MB_OK); +#else + std::cerr << usage.str(); + std::cerr.flush(); +#endif exit(1); } @@ -3008,7 +3014,6 @@ int main(int argc, char **argv) { // Global function invoked from NS or UI views and controllers to create demo static void demo_main(struct Demo &demo, void *view, int argc, const char *argv[]) { - demo.init(argc, (char **)argv); demo.window = view; demo.init_vk_swapchain();