Browse Source

cocoa: guarantee 24bit depth when Config.prc has `depth-bits` set to `1`

Checks if the value of Config.prc for `depth-bits` is `1` and sets it
manually to 24.
This prevents getting a 16 bit depth buffer on macos
Intended to address #501

Closes #551
tc 6 years ago
parent
commit
96bb90b5e9
1 changed files with 10 additions and 1 deletions
  1. 10 1
      panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm

+ 10 - 1
panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm

@@ -248,8 +248,17 @@ choose_pixel_format(const FrameBufferProperties &properties,
   attribs.push_back(aux_buffers);
   attribs.push_back(NSOpenGLPFAColorSize);
   attribs.push_back(properties.get_color_bits());
+
+  // Set the depth buffer bits to 24 manually when 1 is requested.
+  // This prevents getting a depth buffer of only 16 bits when requesting 1.
   attribs.push_back(NSOpenGLPFADepthSize);
-  attribs.push_back(properties.get_depth_bits());
+  if (properties.get_depth_bits() == 1) {
+    attribs.push_back(24);
+  }
+  else {
+    attribs.push_back(properties.get_depth_bits());
+  }
+
   attribs.push_back(NSOpenGLPFAStencilSize);
   attribs.push_back(properties.get_stencil_bits());