From 96bb90b5e9f01109abe307adb27fde776673c6d8 Mon Sep 17 00:00:00 2001 From: tc Date: Thu, 7 Feb 2019 22:18:10 +0100 Subject: [PATCH] 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 --- panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index aac8beb033..357582180b 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/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());