From e5b9605ab2dc8fd73bdc44ff0d40034d326c1bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 9 Feb 2017 12:08:23 +0100 Subject: [macos] reuse OpenGL context when switching screens Cherry-picked from 43e81509fb0be54bea5912fb5a10bfa0e0667a44. --- platform/macos/src/MGLOpenGLLayer.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLOpenGLLayer.mm b/platform/macos/src/MGLOpenGLLayer.mm index 654fa4f2bc..b1040f26e8 100644 --- a/platform/macos/src/MGLOpenGLLayer.mm +++ b/platform/macos/src/MGLOpenGLLayer.mm @@ -4,7 +4,9 @@ #import -@implementation MGLOpenGLLayer +@implementation MGLOpenGLLayer { + NSOpenGLContext *_context; +} - (MGLMapView *)mapView { return (MGLMapView *)super.view; @@ -22,6 +24,13 @@ return self.view.bounds; } +- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat { + if (!_context) { + _context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; + } + return _context; +} + - (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask { NSOpenGLPixelFormatAttribute pfas[] = { NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy, -- cgit v1.2.1