From f1524acbd3e708d1764b7f1533d707b22254ae95 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Jan 2023 12:54:56 -0500 Subject: 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. --- src/common.c | 1 + src/mac_gl.m | 3 +++ src/win_gl.c | 7 +++++-- src/x11_gl.c | 27 +++++++++++++++------------ 4 files changed, 24 insertions(+), 14 deletions(-) (limited to 'src') 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); -- cgit v1.2.1