diff options
author | David Robillard <d@drobilla.net> | 2023-01-08 19:44:41 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-01-08 22:32:09 -0500 |
commit | 426222903151173637c9a49246c182e79618bf83 (patch) | |
tree | 536914cb50c2e6e32f32190d2e3b7c997cb01ca7 /src/mac_gl.m | |
parent | f1524acbd3e708d1764b7f1533d707b22254ae95 (diff) | |
download | pugl-426222903151173637c9a49246c182e79618bf83.tar.gz pugl-426222903151173637c9a49246c182e79618bf83.tar.bz2 pugl-426222903151173637c9a49246c182e79618bf83.zip |
Use ensureHint pattern everywhere
Diffstat (limited to 'src/mac_gl.m')
-rw-r--r-- | src/mac_gl.m | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/mac_gl.m b/src/mac_gl.m index 69acde7..b1430d9 100644 --- a/src/mac_gl.m +++ b/src/mac_gl.m @@ -11,6 +11,14 @@ # define NSOpenGLProfileVersion4_1Core NSOpenGLProfileVersion3_2Core #endif +static void +ensureHint(PuglView* const view, const PuglViewHint hint, const int value) +{ + if (view->hints[hint] == PUGL_DONT_CARE) { + view->hints[hint] = value; + } +} + @interface PuglOpenGLView : NSOpenGLView @end @@ -31,24 +39,12 @@ // Set attributes to default if they are unset // (There is no GLX_DONT_CARE equivalent on MacOS) - if (puglview->hints[PUGL_DEPTH_BITS] == PUGL_DONT_CARE) { - puglview->hints[PUGL_DEPTH_BITS] = 0; - } - if (puglview->hints[PUGL_STENCIL_BITS] == PUGL_DONT_CARE) { - puglview->hints[PUGL_STENCIL_BITS] = 0; - } - if (puglview->hints[PUGL_SAMPLES] == PUGL_DONT_CARE) { - puglview->hints[PUGL_SAMPLES] = 1; - } - if (puglview->hints[PUGL_SAMPLE_BUFFERS] == PUGL_DONT_CARE) { - puglview->hints[PUGL_SAMPLE_BUFFERS] = puglview->hints[PUGL_SAMPLES] > 0; - } - if (puglview->hints[PUGL_DOUBLE_BUFFER] == PUGL_DONT_CARE) { - puglview->hints[PUGL_DOUBLE_BUFFER] = 1; - } - if (puglview->hints[PUGL_SWAP_INTERVAL] == PUGL_DONT_CARE) { - puglview->hints[PUGL_SWAP_INTERVAL] = 1; - } + ensureHint(puglview, PUGL_DEPTH_BITS, 0); + ensureHint(puglview, PUGL_STENCIL_BITS, 0); + ensureHint(puglview, PUGL_SAMPLES, 1); + ensureHint(puglview, PUGL_SAMPLE_BUFFERS, puglview->hints[PUGL_SAMPLES] > 0); + ensureHint(puglview, PUGL_DOUBLE_BUFFER, 1); + ensureHint(puglview, PUGL_SWAP_INTERVAL, 1); const unsigned colorSize = (unsigned)(puglview->hints[PUGL_RED_BITS] + puglview->hints[PUGL_BLUE_BITS] + |