aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/mac_gl.m
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-10-03 19:38:53 +0200
committerDavid Robillard <d@drobilla.net>2020-10-04 12:51:32 +0200
commitcc5c38b1aaf93157f5558df95383491a6163cc5a (patch)
treea1b858c00ad84a0479b98247f84e608ac0d62866 /pugl/detail/mac_gl.m
parent6ca124d3787a901129252a2e26c091da1c1ff455 (diff)
downloadpugl-cc5c38b1aaf93157f5558df95383491a6163cc5a.tar.gz
pugl-cc5c38b1aaf93157f5558df95383491a6163cc5a.tar.bz2
pugl-cc5c38b1aaf93157f5558df95383491a6163cc5a.zip
Add puglGetViewHint()
This allows retrieving properties of the view that may be needed, such as the actual bit depth (which may vary from the suggested depth provided as a hint).
Diffstat (limited to 'pugl/detail/mac_gl.m')
-rw-r--r--pugl/detail/mac_gl.m30
1 files changed, 27 insertions, 3 deletions
diff --git a/pugl/detail/mac_gl.m b/pugl/detail/mac_gl.m
index 4bf6fc1..4d4f324 100644
--- a/pugl/detail/mac_gl.m
+++ b/pugl/detail/mac_gl.m
@@ -48,12 +48,36 @@
? NSOpenGLProfileVersion4_1Core
: NSOpenGLProfileVersion3_2Core));
- NSOpenGLPixelFormatAttribute pixelAttribs[16] = {
+ // 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_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;
+ }
+
+ const unsigned colorSize = (unsigned)(puglview->hints[PUGL_RED_BITS] +
+ puglview->hints[PUGL_BLUE_BITS] +
+ puglview->hints[PUGL_GREEN_BITS] +
+ puglview->hints[PUGL_ALPHA_BITS]);
+
+ NSOpenGLPixelFormatAttribute pixelAttribs[17] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
NSOpenGLPFAOpenGLProfile, profile,
- NSOpenGLPFAColorSize, 32,
- NSOpenGLPFADepthSize, 32,
+ NSOpenGLPFAColorSize, colorSize,
+ NSOpenGLPFADepthSize, (unsigned)puglview->hints[PUGL_DEPTH_BITS],
+ NSOpenGLPFAStencilSize, (unsigned)puglview->hints[PUGL_STENCIL_BITS],
NSOpenGLPFAMultisample, samples ? 1 : 0,
NSOpenGLPFASampleBuffers, samples ? 1 : 0,
NSOpenGLPFASamples, samples,