From 3f5593d6132b627ff59b5cf1fd68429b6ca5a67c Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 26 Nov 2022 13:57:12 -0500
Subject: [PATCH] cocoa: Patched to compile on macOS SDK < 10.10.
Fixes #6586.
(cherry picked from commit fa5adcafd52303fde86c64094462303404259d75)
---
src/video/cocoa/SDL_cocoaopengl.h | 3 +++
src/video/cocoa/SDL_cocoaopengl.m | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h
index fe8a8e51c134..9330b5744936 100644
--- a/src/video/cocoa/SDL_cocoaopengl.h
+++ b/src/video/cocoa/SDL_cocoaopengl.h
@@ -59,6 +59,9 @@ struct SDL_GLDriverData
- (SDL_Window*)window;
- (void)explicitUpdate;
- (void)dealloc;
+
+@property (retain, nonatomic) NSOpenGLPixelFormat* openglPixelFormat; // macOS 10.10 has -[NSOpenGLContext pixelFormat] but this handles older OS releases.
+
@end
/* OpenGL functions */
diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m
index 607f30716164..2cdbc17e9f0c 100644
--- a/src/video/cocoa/SDL_cocoaopengl.m
+++ b/src/video/cocoa/SDL_cocoaopengl.m
@@ -76,6 +76,7 @@ - (id)initWithFormat:(NSOpenGLPixelFormat *)format
{
self = [super initWithFormat:format shareContext:share];
if (self) {
+ self.openglPixelFormat = format;
SDL_AtomicSet(&self->dirty, 0);
self->window = NULL;
SDL_AtomicSet(&self->swapIntervalSetting, 0);
@@ -100,7 +101,7 @@ - (id)initWithFormat:(NSOpenGLPixelFormat *)format
- (void)movedToNewScreen
{
if (self->displayLink) {
- CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(self->displayLink, [self CGLContextObj], [[self pixelFormat] CGLPixelFormatObj]);
+ CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(self->displayLink, [self CGLContextObj], [[self openglPixelFormat] CGLPixelFormatObj]);
}
}