shiny/driver/gldriver: fix 2 warnings on macOS 10.14
This CL iterates upon CL 171033 and resolves two remaining C compiler
warnings when building on macOS 10.14:
# golang.org/x/exp/shiny/driver/gldriver
cocoa.m:63:39: warning: 'NSOpenGLCPSwapInterval' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
/Applications/Xcode.app/.../NSOpenGL.h:281:39: note: 'NSOpenGLCPSwapInterval' has been explicitly marked deprecated here
cocoa.m:72:1: warning: method possibly missing a [super prepareOpenGL] call [-Wobjc-missing-super-calls]
NSOpenGLContextParameterSwapInterval is the less-deprecated version of
NSOpenGLCPSwapInterval and respects the GL_SILENCE_DEPRECATION define.
However, we can't use it because it's available only in macOS 10.12+,
but Go currently supports older macOS versions (e.g., Go 1.12 requires
macOS 10.10+). Use a targeted #pragma clang diagnostic ignored instead.
Add a [super prepareOpenGL] call to ScreenGLView.prepareOpenGL method.
I can't quite tell if it was omitted intentionally, but based on its
documentation¹, it seems reasonable to have it. I didn't notice problems
in local testing. If it turns out it shouldn't be there, then it can be
removed in a way that doesn't generate a compiler warning.
¹ https://developer.apple.com/documentation/appkit/nsopenglview/1414940-prepareopengl
Updates golang/go#11811
Change-Id: I10b6522a7af64eadeb6586fad44ef4c1ece40ab2
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171034
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/shiny/driver/gldriver/cocoa.m b/shiny/driver/gldriver/cocoa.m
index 3410b58..4b48e7b 100644
--- a/shiny/driver/gldriver/cocoa.m
+++ b/shiny/driver/gldriver/cocoa.m
@@ -57,10 +57,16 @@
@implementation ScreenGLView
- (void)prepareOpenGL {
+ [super prepareOpenGL];
+
[self setWantsBestResolutionOpenGLSurface:YES];
GLint swapInt = 1;
NSOpenGLContext *ctx = [self openGLContext];
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[ctx setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
+#pragma clang diagnostic pop
// Using attribute arrays in OpenGL 3.3 requires the use of a VBA.
// But VBAs don't exist in ES 2. So we bind a default one.