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
This commit is contained in:
tc 2019-02-07 22:18:10 +01:00 committed by rdb
parent 666568a513
commit 96bb90b5e9

View File

@ -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());