Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 332e5bc

Browse files
committed
[macos] align HeadlessDisplay with SDK OpenGL context creation options
1 parent b5bc4fd commit 332e5bc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

platform/darwin/src/headless_display_cgl.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ HeadlessDisplay::Impl::Impl() {
1818
// TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported
1919
// If it is, use kCGLOGLPVersion_3_2_Core and enable that extension.
2020
CGLPixelFormatAttribute attributes[] = {
21-
kCGLPFAOpenGLProfile,
22-
static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_Legacy),
21+
kCGLPFAOpenGLProfile, static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_Legacy),
22+
// Not adding kCGLPFAAccelerated, as this will make headless rendering impossible when running in VMs.
23+
kCGLPFAClosestPolicy,
24+
kCGLPFAAccumSize, static_cast<CGLPixelFormatAttribute>(32),
25+
kCGLPFAColorSize, static_cast<CGLPixelFormatAttribute>(24),
26+
kCGLPFAAlphaSize, static_cast<CGLPixelFormatAttribute>(8),
27+
kCGLPFADepthSize, static_cast<CGLPixelFormatAttribute>(16),
28+
kCGLPFAStencilSize, static_cast<CGLPixelFormatAttribute>(8),
2329
kCGLPFASupportsAutomaticGraphicsSwitching,
2430
kCGLPFAAllowOfflineRenderers, // Allows using the integrated GPU
2531
static_cast<CGLPixelFormatAttribute>(0)

platform/macos/src/MGLOpenGLLayer.mm

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ - (CGRect)frame {
2222

2323
- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask {
2424
NSOpenGLPixelFormatAttribute pfas[] = {
25+
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy,
2526
NSOpenGLPFAAccelerated,
2627
NSOpenGLPFAClosestPolicy,
2728
NSOpenGLPFAAccumSize, 32,

0 commit comments

Comments
 (0)