diff options
author | David Robillard <d@drobilla.net> | 2020-03-08 18:40:13 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-03-08 18:40:13 +0100 |
commit | 7f0169be0db0f16a91d859a54b22535f26fdcb38 (patch) | |
tree | b055403fb76449954d49a318e2ec90616745f27b | |
parent | 838deb81c24030d7d7891ad1f1317f63428bf29b (diff) | |
download | pugl-7f0169be0db0f16a91d859a54b22535f26fdcb38.tar.gz pugl-7f0169be0db0f16a91d859a54b22535f26fdcb38.tar.bz2 pugl-7f0169be0db0f16a91d859a54b22535f26fdcb38.zip |
Add vsync command line options to demos
-rw-r--r-- | examples/pugl_embed_demo.c | 4 | ||||
-rw-r--r-- | examples/pugl_gl3_demo.c | 2 | ||||
-rw-r--r-- | examples/pugl_window_demo.c | 2 | ||||
-rw-r--r-- | test/test_utils.h | 21 |
4 files changed, 23 insertions, 6 deletions
diff --git a/examples/pugl_embed_demo.c b/examples/pugl_embed_demo.c index b122253..96df463 100644 --- a/examples/pugl_embed_demo.c +++ b/examples/pugl_embed_demo.c @@ -280,7 +280,7 @@ main(int argc, char** argv) puglSetViewHint(app.parent, PUGL_RESIZABLE, opts.resizable); puglSetViewHint(app.parent, PUGL_SAMPLES, opts.samples); puglSetViewHint(app.parent, PUGL_DOUBLE_BUFFER, opts.doubleBuffer); - puglSetViewHint(app.parent, PUGL_SWAP_INTERVAL, opts.doubleBuffer); + puglSetViewHint(app.parent, PUGL_SWAP_INTERVAL, opts.sync); puglSetViewHint(app.parent, PUGL_IGNORE_KEY_REPEAT, opts.ignoreKeyRepeat); puglSetHandle(app.parent, &app); puglSetEventFunc(app.parent, onParentEvent); @@ -299,7 +299,7 @@ main(int argc, char** argv) puglSetViewHint(app.child, PUGL_USE_DEBUG_CONTEXT, opts.errorChecking); puglSetViewHint(app.child, PUGL_SAMPLES, opts.samples); puglSetViewHint(app.child, PUGL_DOUBLE_BUFFER, opts.doubleBuffer); - puglSetViewHint(app.child, PUGL_SWAP_INTERVAL, 0); + puglSetViewHint(app.child, PUGL_SWAP_INTERVAL, opts.sync); puglSetBackend(app.child, puglGlBackend()); puglSetViewHint(app.child, PUGL_IGNORE_KEY_REPEAT, opts.ignoreKeyRepeat); puglSetHandle(app.child, &app); diff --git a/examples/pugl_gl3_demo.c b/examples/pugl_gl3_demo.c index 52c5dd3..9efe185 100644 --- a/examples/pugl_gl3_demo.c +++ b/examples/pugl_gl3_demo.c @@ -268,7 +268,7 @@ main(int argc, char** argv) puglSetViewHint(app.view, PUGL_RESIZABLE, app.opts.resizable); puglSetViewHint(app.view, PUGL_SAMPLES, app.opts.samples); puglSetViewHint(app.view, PUGL_DOUBLE_BUFFER, app.opts.doubleBuffer); - puglSetViewHint(app.view, PUGL_SWAP_INTERVAL, app.opts.doubleBuffer); + puglSetViewHint(app.view, PUGL_SWAP_INTERVAL, app.opts.sync); puglSetViewHint(app.view, PUGL_IGNORE_KEY_REPEAT, PUGL_TRUE); puglSetHandle(app.view, &app); puglSetEventFunc(app.view, onEvent); diff --git a/examples/pugl_window_demo.c b/examples/pugl_window_demo.c index e9c09a3..fdcd8cb 100644 --- a/examples/pugl_window_demo.c +++ b/examples/pugl_window_demo.c @@ -201,7 +201,7 @@ main(int argc, char** argv) puglSetViewHint(view, PUGL_RESIZABLE, opts.resizable); puglSetViewHint(view, PUGL_SAMPLES, opts.samples); puglSetViewHint(view, PUGL_DOUBLE_BUFFER, opts.doubleBuffer); - puglSetViewHint(view, PUGL_SWAP_INTERVAL, 0);//opts.doubleBuffer && i == 0); + puglSetViewHint(view, PUGL_SWAP_INTERVAL, opts.sync); puglSetViewHint(view, PUGL_IGNORE_KEY_REPEAT, opts.ignoreKeyRepeat); puglSetHandle(view, cube); puglSetEventFunc(view, onEvent); diff --git a/test/test_utils.h b/test/test_utils.h index 6a2a644..b79c0b9 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -25,6 +25,7 @@ typedef struct { int samples; int doubleBuffer; + int sync; bool continuous; bool help; bool ignoreKeyRepeat; @@ -165,17 +166,29 @@ puglPrintTestUsage(const char* prog, const char* posHelp) " -c Continuously animate and draw\n" " -d Enable double-buffering\n" " -e Enable platform error-checking\n" + " -f Fast drawing, explicitly disable vertical sync\n" " -h Display this help\n" " -i Ignore key repeat\n" " -v Print verbose output\n" - " -r Resizable window\n", + " -r Resizable window\n" + " -s Explicitly enable vertical sync\n", prog, posHelp); } static inline PuglTestOptions puglParseTestOptions(int* pargc, char*** pargv) { - PuglTestOptions opts = { 0, 0, false, false, false, false, false, false }; + PuglTestOptions opts = { + 0, + 0, + PUGL_DONT_CARE, + false, + false, + false, + false, + false, + false, + }; char** const argv = *pargv; int i = 1; @@ -188,6 +201,8 @@ puglParseTestOptions(int* pargc, char*** pargv) opts.doubleBuffer = PUGL_TRUE; } else if (!strcmp(argv[i], "-e")) { opts.errorChecking = PUGL_TRUE; + } else if (!strcmp(argv[i], "-f")) { + opts.sync = PUGL_FALSE; } else if (!strcmp(argv[i], "-h")) { opts.help = true; return opts; @@ -195,6 +210,8 @@ puglParseTestOptions(int* pargc, char*** pargv) opts.ignoreKeyRepeat = true; } else if (!strcmp(argv[i], "-r")) { opts.resizable = true; + } else if (!strcmp(argv[i], "-s")) { + opts.sync = PUGL_TRUE; } else if (!strcmp(argv[i], "-v")) { opts.verbose = true; } else if (argv[i][0] != '-') { |