aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-08 12:54:56 -0500
committerDavid Robillard <d@drobilla.net>2023-01-08 22:31:51 -0500
commitf1524acbd3e708d1764b7f1533d707b22254ae95 (patch)
tree83a0a08ca2a7360abaca32e2717090e07b21f0aa /src
parent1e8431373a494c27c74e34bfa7ab0247e3c29677 (diff)
downloadpugl-f1524acbd3e708d1764b7f1533d707b22254ae95.tar.gz
pugl-f1524acbd3e708d1764b7f1533d707b22254ae95.tar.bz2
pugl-f1524acbd3e708d1764b7f1533d707b22254ae95.zip
Add PUGL_SAMPLE_BUFFERS hint
Towards a more direct and explicit mapping to platform hints, and more consistent behaviour across platforms. OpenGL applications are generally expected to be explicit about hints like this.
Diffstat (limited to 'src')
-rw-r--r--src/common.c1
-rw-r--r--src/mac_gl.m3
-rw-r--r--src/win_gl.c7
-rw-r--r--src/x11_gl.c27
4 files changed, 24 insertions, 14 deletions
diff --git a/src/common.c b/src/common.c
index 9bb2d2e..90a75cf 100644
--- a/src/common.c
+++ b/src/common.c
@@ -101,6 +101,7 @@ puglSetDefaultHints(PuglHints hints)
hints[PUGL_ALPHA_BITS] = 8;
hints[PUGL_DEPTH_BITS] = 0;
hints[PUGL_STENCIL_BITS] = 0;
+ hints[PUGL_SAMPLE_BUFFERS] = PUGL_DONT_CARE;
hints[PUGL_SAMPLES] = 0;
hints[PUGL_DOUBLE_BUFFER] = PUGL_TRUE;
hints[PUGL_SWAP_INTERVAL] = PUGL_DONT_CARE;
diff --git a/src/mac_gl.m b/src/mac_gl.m
index 53daf97..69acde7 100644
--- a/src/mac_gl.m
+++ b/src/mac_gl.m
@@ -40,6 +40,9 @@
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;
}
diff --git a/src/win_gl.c b/src/win_gl.c
index 44795f5..9850b6f 100644
--- a/src/win_gl.c
+++ b/src/win_gl.c
@@ -103,7 +103,10 @@ puglWinGlConfigure(PuglView* view)
view->hints[PUGL_STENCIL_BITS] = 0;
}
if (view->hints[PUGL_SAMPLES] == PUGL_DONT_CARE) {
- view->hints[PUGL_SAMPLES] = 1;
+ 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;
@@ -119,7 +122,7 @@ puglWinGlConfigure(PuglView* view)
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_DOUBLE_BUFFER_ARB, view->hints[PUGL_DOUBLE_BUFFER],
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
- WGL_SAMPLE_BUFFERS_ARB, view->hints[PUGL_SAMPLES] ? 1 : 0,
+ WGL_SAMPLE_BUFFERS_ARB, view->hints[PUGL_SAMPLE_BUFFERS],
WGL_SAMPLES_ARB, view->hints[PUGL_SAMPLES],
WGL_RED_BITS_ARB, view->hints[PUGL_RED_BITS],
WGL_GREEN_BITS_ARB, view->hints[PUGL_GREEN_BITS],
diff --git a/src/x11_gl.c b/src/x11_gl.c
index 2e15092..f1dc56b 100644
--- a/src/x11_gl.c
+++ b/src/x11_gl.c
@@ -52,18 +52,19 @@ puglX11GlConfigure(PuglView* view)
// clang-format off
const int attrs[] = {
- GLX_X_RENDERABLE, True,
- GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
- GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_SAMPLES, puglX11GlHintValue(view->hints[PUGL_SAMPLES]),
- GLX_RED_SIZE, puglX11GlHintValue(view->hints[PUGL_RED_BITS]),
- GLX_GREEN_SIZE, puglX11GlHintValue(view->hints[PUGL_GREEN_BITS]),
- GLX_BLUE_SIZE, puglX11GlHintValue(view->hints[PUGL_BLUE_BITS]),
- GLX_ALPHA_SIZE, puglX11GlHintValue(view->hints[PUGL_ALPHA_BITS]),
- GLX_DEPTH_SIZE, puglX11GlHintValue(view->hints[PUGL_DEPTH_BITS]),
- GLX_STENCIL_SIZE, puglX11GlHintValue(view->hints[PUGL_STENCIL_BITS]),
- GLX_DOUBLEBUFFER, puglX11GlHintValue(view->hints[PUGL_DOUBLE_BUFFER]),
+ GLX_X_RENDERABLE, True,
+ GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
+ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_SAMPLE_BUFFERS, puglX11GlHintValue(view->hints[PUGL_SAMPLE_BUFFERS]),
+ GLX_SAMPLES, puglX11GlHintValue(view->hints[PUGL_SAMPLES]),
+ GLX_RED_SIZE, puglX11GlHintValue(view->hints[PUGL_RED_BITS]),
+ GLX_GREEN_SIZE, puglX11GlHintValue(view->hints[PUGL_GREEN_BITS]),
+ GLX_BLUE_SIZE, puglX11GlHintValue(view->hints[PUGL_BLUE_BITS]),
+ GLX_ALPHA_SIZE, puglX11GlHintValue(view->hints[PUGL_ALPHA_BITS]),
+ GLX_DEPTH_SIZE, puglX11GlHintValue(view->hints[PUGL_DEPTH_BITS]),
+ GLX_STENCIL_SIZE, puglX11GlHintValue(view->hints[PUGL_STENCIL_BITS]),
+ GLX_DOUBLEBUFFER, puglX11GlHintValue(view->hints[PUGL_DOUBLE_BUFFER]),
None
};
// clang-format on
@@ -89,6 +90,8 @@ puglX11GlConfigure(PuglView* view)
puglX11GlGetAttrib(display, fbc[0], GLX_DEPTH_SIZE);
view->hints[PUGL_STENCIL_BITS] =
puglX11GlGetAttrib(display, fbc[0], GLX_STENCIL_SIZE);
+ view->hints[PUGL_SAMPLE_BUFFERS] =
+ puglX11GlGetAttrib(display, fbc[0], GLX_SAMPLE_BUFFERS);
view->hints[PUGL_SAMPLES] = puglX11GlGetAttrib(display, fbc[0], GLX_SAMPLES);
view->hints[PUGL_DOUBLE_BUFFER] =
puglX11GlGetAttrib(display, fbc[0], GLX_DOUBLEBUFFER);