diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index adf3004f..3674bf4a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,7 +34,7 @@ add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${GLAD}) add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT} ${GLAD}) add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD}) add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD}) -add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GLAD}) +add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD}) target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") target_link_libraries(threads "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") diff --git a/tests/windows.c b/tests/windows.c index 89a4b224..21db08d5 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -33,6 +33,8 @@ #include #include +#include "getopt.h" + static const char* titles[] = { "Red", @@ -52,6 +54,14 @@ static const struct { 0.98f, 0.74f, 0.04f } }; +static void usage(void) +{ + printf("Usage: windows [-h] [-b]\n"); + printf("Options:\n"); + printf(" -b create decorated windows\n"); + printf(" -h show this help\n"); +} + static void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); @@ -80,16 +90,33 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, int main(int argc, char** argv) { - int i; + int i, ch; + int decorated = GLFW_FALSE; int running = GLFW_TRUE; GLFWwindow* windows[4]; + while ((ch = getopt(argc, argv, "bh")) != -1) + { + switch (ch) + { + case 'b': + decorated = GLFW_TRUE; + break; + case 'h': + usage(); + exit(EXIT_SUCCESS); + default: + usage(); + exit(EXIT_FAILURE); + } + } + glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); - glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); + glfwWindowHint(GLFW_DECORATED, decorated); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); for (i = 0; i < 4; i++)