diff options
Diffstat (limited to 'test/test_utils.h')
-rw-r--r-- | test/test_utils.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/test_utils.h b/test/test_utils.h index 8e21d97..e26e970 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -22,6 +22,9 @@ typedef struct { int samples; int doubleBuffer; int sync; + int glApi; + int glMajorVersion; + int glMinorVersion; bool continuous; bool help; bool ignoreKeyRepeat; @@ -314,6 +317,8 @@ static inline void puglPrintTestUsage(const char* prog, const char* posHelp) { printf("Usage: %s [OPTION]... %s\n\n" + " -E Use OpenGL ES\n" + " -G OpenGL context version\n" " -a Enable anti-aliasing\n" " -c Continuously animate and draw\n" " -d Directly draw to window (no double-buffering)\n" @@ -335,6 +340,9 @@ puglParseTestOptions(int* pargc, char*** pargv) 0, PUGL_TRUE, PUGL_DONT_CARE, + PUGL_OPENGL_API, + 3, + 3, false, false, false, @@ -346,7 +354,21 @@ puglParseTestOptions(int* pargc, char*** pargv) char** const argv = *pargv; int i = 1; for (; i < *pargc; ++i) { - if (!strcmp(argv[i], "-a")) { + if (!strcmp(argv[i], "-E")) { + opts.glApi = PUGL_OPENGL_ES_API; + } else if (!strcmp(argv[i], "-G")) { + if (++i == *pargc) { + fprintf(stderr, "error: Missing OpenGL version argument\n"); + return opts; + } + + const int matches = + sscanf(argv[i], "%u.%u", &opts.glMajorVersion, &opts.glMinorVersion); + if (matches != 2) { + fprintf(stderr, "error: Invalid OpenGL version argument\n"); + return opts; + } + } else if (!strcmp(argv[i], "-a")) { opts.samples = 4; } else if (!strcmp(argv[i], "-c")) { opts.continuous = true; |