aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-10-03 19:38:54 +0200
committerDavid Robillard <d@drobilla.net>2020-10-04 12:51:35 +0200
commita36408b7c641e0b9052315aed87ce8e591a6a717 (patch)
treec0aea5cddbbbd62b822f91cf35f391b23d38bafb
parentcc5c38b1aaf93157f5558df95383491a6163cc5a (diff)
Print all view hints in shader demo and hint tests
-rw-r--r--examples/pugl_shader_demo.c1
-rw-r--r--test/test_gl_hints.c1
-rw-r--r--test/test_stub_hints.c1
-rw-r--r--test/test_utils.h53
4 files changed, 56 insertions, 0 deletions
diff --git a/examples/pugl_shader_demo.c b/examples/pugl_shader_demo.c
index 50afb37..24ae2a6 100644
--- a/examples/pugl_shader_demo.c
+++ b/examples/pugl_shader_demo.c
@@ -405,6 +405,7 @@ main(int argc, char** argv)
}
// Show window
+ printViewHints(app.view);
puglShowWindow(app.view);
// Grind away, drawing continuously
diff --git a/test/test_gl_hints.c b/test/test_gl_hints.c
index 9830e2e..0e8efbb 100644
--- a/test/test_gl_hints.c
+++ b/test/test_gl_hints.c
@@ -60,6 +60,7 @@ main(void)
// Realize view and print all hints for debugging convenience
assert(!puglRealize(view));
+ printViewHints(view);
// Check that no hints are set to PUGL_DONT_CARE
assert(puglGetViewHint(view, PUGL_USE_COMPAT_PROFILE) != PUGL_DONT_CARE);
diff --git a/test/test_stub_hints.c b/test/test_stub_hints.c
index cd4db6a..a74927e 100644
--- a/test/test_stub_hints.c
+++ b/test/test_stub_hints.c
@@ -56,6 +56,7 @@ main(void)
// Realize view and print all hints for debugging convenience
assert(!puglRealize(view));
+ printViewHints(view);
// Check that no relevant hints are set to PUGL_DONT_CARE
assert(puglGetViewHint(view, PUGL_USE_COMPAT_PROFILE) != PUGL_DONT_CARE);
diff --git a/test/test_utils.h b/test/test_utils.h
index 977fba5..4253619 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -221,6 +221,59 @@ printEvent(const PuglEvent* event, const char* prefix, const bool verbose)
return 0;
}
+static inline const char*
+puglViewHintString(const PuglViewHint hint)
+{
+ switch (hint) {
+ case PUGL_USE_COMPAT_PROFILE:
+ return "Use compatible profile";
+ case PUGL_USE_DEBUG_CONTEXT:
+ return "Use debug context";
+ case PUGL_CONTEXT_VERSION_MAJOR:
+ return "Context major version";
+ case PUGL_CONTEXT_VERSION_MINOR:
+ return "Context minor version";
+ case PUGL_RED_BITS:
+ return "Red bits";
+ case PUGL_GREEN_BITS:
+ return "Green bits";
+ case PUGL_BLUE_BITS:
+ return "Blue bits";
+ case PUGL_ALPHA_BITS:
+ return "Alpha bits";
+ case PUGL_DEPTH_BITS:
+ return "Depth bits";
+ case PUGL_STENCIL_BITS:
+ return "Stencil bits";
+ case PUGL_SAMPLES:
+ return "Samples";
+ case PUGL_DOUBLE_BUFFER:
+ return "Double buffer";
+ case PUGL_SWAP_INTERVAL:
+ return "Swap interval";
+ case PUGL_RESIZABLE:
+ return "Resizable";
+ case PUGL_IGNORE_KEY_REPEAT:
+ return "Ignore key repeat";
+ case PUGL_NUM_VIEW_HINTS:
+ return "Unknown";
+ }
+
+ return "Unknown";
+}
+
+static inline void
+printViewHints(const PuglView* view)
+{
+ for (int i = 0; i < PUGL_NUM_VIEW_HINTS; ++i) {
+ const PuglViewHint hint = (PuglViewHint)i;
+ fprintf(stderr,
+ "%s: %d\n",
+ puglViewHintString(hint),
+ puglGetViewHint(view, hint));
+ }
+}
+
static inline void
puglPrintTestUsage(const char* prog, const char* posHelp)
{