#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 <framecount>] [--suppress_popups] [--incremental_present] [--display_timing]\n"
- "\t[--present_mode <present mode enum>]\n"
- "\t <present_mode_enum>\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 <framecount>] [--suppress_popups]\n"
+ "\t[--incremental_present] [--display_timing]\n"
+ "\t[--present_mode <present mode enum>]\n"
+ "\t<present_mode_enum>\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
}
#include <cstdlib>
#include <cstring>
#include <csignal>
+#include <iostream>
+#include <sstream>
#include <memory>
#define VULKAN_HPP_NO_SMART_HANDLE
continue;
}
- fprintf(stderr,
- "Usage:\n %s [--use_staging] [--validate] [--break] [--c <framecount>] \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 <framecount>] [--suppress_popups]\n"
+ << "\t[--present_mode <present mode enum>]\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"
+ << "\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);
}
// 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();