summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan C. Gordon <icculus@icculus.org>2018-10-18 12:05:05 -0400
committerRyan C. Gordon <icculus@icculus.org>2018-10-18 12:05:05 -0400
commit5d2733a5a4688c46b244cc31c4ab52517f2ab6a0 (patch)
tree52837b0e04c4b62f84ddcbcf99fa82ee8186607e
parent7d7cc2c88f915515636f71d4f2e5b18303573b37 (diff)
downloadsdl-5d2733a5a4688c46b244cc31c4ab52517f2ab6a0.tar.gz
cocoa: Fix OpenGL rendering on macOS 10.14 ("Mojave").
Fixes Bugzilla #4272. (transplanted from 86dcfbbcacaf0c4a556501644af11b7f99b4352d)
-rw-r--r--src/video/cocoa/SDL_cocoawindow.m22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 1785ab1ee..cd61c539e 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -632,8 +632,6 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock;
_data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSEventModifierFlagCapsLock) | newflags;
SDL_ToggleModState(KMOD_CAPS, newflags != 0);
-
- ScheduleContextUpdates(_data);
}
- (void)windowDidResignKey:(NSNotification *)aNotification
@@ -1145,14 +1143,18 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
- (BOOL)mouseDownCanMoveWindow;
- (void)drawRect:(NSRect)dirtyRect;
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
+- (BOOL)wantsUpdateLayer;
+- (void)updateLayer;
@end
@implementation SDLView
+
- (void)setSDLWindow:(SDL_Window*)window
{
_sdlWindow = window;
}
+/* this is used on older macOS revisions. 10.8 and later use updateLayer. */
- (void)drawRect:(NSRect)dirtyRect
{
/* Force the graphics context to clear to black so we don't get a flash of
@@ -1163,6 +1165,21 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0);
}
+-(BOOL) wantsUpdateLayer
+{
+ return YES;
+}
+
+-(void) updateLayer
+{
+ /* Force the graphics context to clear to black so we don't get a flash of
+ white until the app is ready to draw. In practice on modern macOS, this
+ only gets called for window creation and other extraordinary events. */
+ self.layer.backgroundColor = NSColor.blackColor.CGColor;
+ ScheduleContextUpdates((SDL_WindowData *) _sdlWindow->driverdata);
+ SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0);
+}
+
- (void)rightMouseDown:(NSEvent *)theEvent
{
[[self nextResponder] rightMouseDown:theEvent];
@@ -1345,6 +1362,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
[contentView setWantsBestResolutionOpenGLSurface:YES];
}
}
+
#if SDL_VIDEO_OPENGL_ES2
#if SDL_VIDEO_OPENGL_EGL
if ((window->flags & SDL_WINDOW_OPENGL) &&