aboutsummaryrefslogtreecommitdiffstats
path: root/src/win_gl.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-08 19:44:41 -0500
committerDavid Robillard <d@drobilla.net>2023-01-08 22:32:09 -0500
commit426222903151173637c9a49246c182e79618bf83 (patch)
tree536914cb50c2e6e32f32190d2e3b7c997cb01ca7 /src/win_gl.c
parentf1524acbd3e708d1764b7f1533d707b22254ae95 (diff)
downloadpugl-426222903151173637c9a49246c182e79618bf83.tar.gz
pugl-426222903151173637c9a49246c182e79618bf83.tar.bz2
pugl-426222903151173637c9a49246c182e79618bf83.zip
Use ensureHint pattern everywhere
Diffstat (limited to 'src/win_gl.c')
-rw-r--r--src/win_gl.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/win_gl.c b/src/win_gl.c
index 9850b6f..532fd2b 100644
--- a/src/win_gl.c
+++ b/src/win_gl.c
@@ -89,6 +89,14 @@ puglWinGlGetProcs(void)
return procs;
}
+static void
+ensureHint(PuglView* const view, const PuglViewHint hint, const int value)
+{
+ if (view->hints[hint] == PUGL_DONT_CARE) {
+ view->hints[hint] = value;
+ }
+}
+
static PuglStatus
puglWinGlConfigure(PuglView* view)
{
@@ -96,24 +104,12 @@ puglWinGlConfigure(PuglView* view)
// Set attributes to default if they are unset
// (There is no GLX_DONT_CARE equivalent on Windows)
- if (view->hints[PUGL_DEPTH_BITS] == PUGL_DONT_CARE) {
- view->hints[PUGL_DEPTH_BITS] = 0;
- }
- if (view->hints[PUGL_STENCIL_BITS] == PUGL_DONT_CARE) {
- view->hints[PUGL_STENCIL_BITS] = 0;
- }
- if (view->hints[PUGL_SAMPLES] == PUGL_DONT_CARE) {
- view->hints[PUGL_SAMPLES] = 0;
- }
- if (view->hints[PUGL_SAMPLE_BUFFERS] == PUGL_DONT_CARE) {
- view->hints[PUGL_SAMPLE_BUFFERS] = view->hints[PUGL_SAMPLES] > 0;
- }
- if (view->hints[PUGL_DOUBLE_BUFFER] == PUGL_DONT_CARE) {
- view->hints[PUGL_DOUBLE_BUFFER] = 1;
- }
- if (view->hints[PUGL_SWAP_INTERVAL] == PUGL_DONT_CARE) {
- view->hints[PUGL_SWAP_INTERVAL] = 1;
- }
+ ensureHint(view, PUGL_DEPTH_BITS, 0);
+ ensureHint(view, PUGL_STENCIL_BITS, 0);
+ ensureHint(view, PUGL_SAMPLES, 0);
+ ensureHint(view, PUGL_SAMPLE_BUFFERS, view->hints[PUGL_SAMPLES] > 0);
+ ensureHint(view, PUGL_DOUBLE_BUFFER, 1);
+ ensureHint(view, PUGL_SWAP_INTERVAL, 1);
// clang-format off
const int pixelAttrs[] = {