diff options
-rw-r--r-- | bindings/cpp/include/pugl/pugl.hpp | 1 | ||||
-rw-r--r-- | include/pugl/pugl.h | 1 | ||||
-rw-r--r-- | src/common.c | 1 | ||||
-rw-r--r-- | src/mac_gl.m | 3 | ||||
-rw-r--r-- | src/win_gl.c | 7 | ||||
-rw-r--r-- | src/x11_gl.c | 27 | ||||
-rw-r--r-- | test/test_gl_hints.c | 2 | ||||
-rw-r--r-- | test/test_utils.h | 2 |
8 files changed, 30 insertions, 14 deletions
diff --git a/bindings/cpp/include/pugl/pugl.hpp b/bindings/cpp/include/pugl/pugl.hpp index 5f939d5..4fe7244 100644 --- a/bindings/cpp/include/pugl/pugl.hpp +++ b/bindings/cpp/include/pugl/pugl.hpp @@ -352,6 +352,7 @@ enum class ViewHint { alphaBits, ///< @copydoc PUGL_ALPHA_BITS depthBits, ///< @copydoc PUGL_DEPTH_BITS stencilBits, ///< @copydoc PUGL_STENCIL_BITS + sampleBuffers, ///< @copydoc PUGL_SAMPLE_BUFFERS samples, ///< @copydoc PUGL_SAMPLES doubleBuffer, ///< @copydoc PUGL_DOUBLE_BUFFER swapInterval, ///< @copydoc PUGL_SWAP_INTERVAL diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index 338aa4d..0e97f91 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -882,6 +882,7 @@ typedef enum { PUGL_ALPHA_BITS, ///< Number of bits for alpha channel PUGL_DEPTH_BITS, ///< Number of bits for depth buffer PUGL_STENCIL_BITS, ///< Number of bits for stencil buffer + PUGL_SAMPLE_BUFFERS, ///< Number of sample buffers (AA) PUGL_SAMPLES, ///< Number of samples per pixel (AA) PUGL_DOUBLE_BUFFER, ///< True if double buffering should be used PUGL_SWAP_INTERVAL, ///< Number of frames between buffer swaps 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); diff --git a/test/test_gl_hints.c b/test/test_gl_hints.c index 7e91035..64c7342 100644 --- a/test/test_gl_hints.c +++ b/test/test_gl_hints.c @@ -55,6 +55,7 @@ main(void) assert(!puglSetViewHint(view, PUGL_ALPHA_BITS, PUGL_DONT_CARE)); assert(!puglSetViewHint(view, PUGL_DEPTH_BITS, PUGL_DONT_CARE)); assert(!puglSetViewHint(view, PUGL_STENCIL_BITS, PUGL_DONT_CARE)); + assert(!puglSetViewHint(view, PUGL_SAMPLE_BUFFERS, PUGL_DONT_CARE)); assert(!puglSetViewHint(view, PUGL_SAMPLES, PUGL_DONT_CARE)); assert(!puglSetViewHint(view, PUGL_DOUBLE_BUFFER, PUGL_DONT_CARE)); assert(!puglSetViewHint(view, PUGL_REFRESH_RATE, PUGL_DONT_CARE)); @@ -74,6 +75,7 @@ main(void) assert(puglGetViewHint(view, PUGL_ALPHA_BITS) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_DEPTH_BITS) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_STENCIL_BITS) != PUGL_DONT_CARE); + assert(puglGetViewHint(view, PUGL_SAMPLE_BUFFERS) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_SAMPLES) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_DOUBLE_BUFFER) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_SWAP_INTERVAL) != PUGL_DONT_CARE); diff --git a/test/test_utils.h b/test/test_utils.h index 85276fb..db3485b 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -275,6 +275,8 @@ puglViewHintString(const PuglViewHint hint) return "Depth bits"; case PUGL_STENCIL_BITS: return "Stencil bits"; + case PUGL_SAMPLE_BUFFERS: + return "Sample buffers"; case PUGL_SAMPLES: return "Samples"; case PUGL_DOUBLE_BUFFER: |