From 874a4fb9cdefdabe7ecf18f7f1d7bdc8994e3aad Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 6 Mar 2019 01:22:02 +0100 Subject: [PATCH] app,exp,gl: fix build Ignore deprecation warning for OpenGL and replace deprecated enum names. Change-Id: Ie07c566f1b28610add074dc4da8ab66399cef94b Reviewed-on: https://go-review.googlesource.com/c/mobile/+/165578 Run-TryBot: Elias Naur Reviewed-by: Brad Fitzpatrick --- app/darwin_desktop.go | 2 +- app/darwin_desktop.m | 14 +++++++++----- app/darwin_ios.go | 2 +- exp/font/font_darwin.go | 4 ++-- exp/gl/glutil/context_darwin_desktop.go | 1 + gl/work.go | 1 + 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/darwin_desktop.go b/app/darwin_desktop.go index ecbc45a..5a0302f 100644 --- a/app/darwin_desktop.go +++ b/app/darwin_desktop.go @@ -12,7 +12,7 @@ package app // than screens with touch panels. /* -#cgo CFLAGS: -x objective-c +#cgo CFLAGS: -x objective-c -DGL_SILENCE_DEPRECATION #cgo LDFLAGS: -framework Cocoa -framework OpenGL #import // for HIToolbox/Events.h #import diff --git a/app/darwin_desktop.m b/app/darwin_desktop.m index b4f2e8d..615c29b 100644 --- a/app/darwin_desktop.m +++ b/app/darwin_desktop.m @@ -35,7 +35,11 @@ uint64 threadID() { - (void)prepareOpenGL { [self setWantsBestResolutionOpenGLSurface:YES]; GLint swapInt = 1; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [[self openGLContext] 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. @@ -168,7 +172,7 @@ uint64 threadID() { uint8_t direction; if ([theEvent isARepeat]) { direction = 0; - } else if (theEvent.type == NSKeyDown) { + } else if (theEvent.type == NSEventTypeKeyDown) { direction = 1; } else { direction = 2; @@ -209,13 +213,13 @@ runApp(void) { NSRect rect = NSMakeRect(0, 0, 600, 800); NSWindow* window = [[[NSWindow alloc] initWithContentRect:rect - styleMask:NSTitledWindowMask + styleMask:NSWindowStyleMaskTitled backing:NSBackingStoreBuffered defer:NO] autorelease]; - window.styleMask |= NSResizableWindowMask; - window.styleMask |= NSMiniaturizableWindowMask ; - window.styleMask |= NSClosableWindowMask; + window.styleMask |= NSWindowStyleMaskResizable; + window.styleMask |= NSWindowStyleMaskMiniaturizable; + window.styleMask |= NSWindowStyleMaskClosable; window.title = name; [window cascadeTopLeftFromPoint:NSMakePoint(20,20)]; diff --git a/app/darwin_ios.go b/app/darwin_ios.go index 935b41b..f21816c 100644 --- a/app/darwin_ios.go +++ b/app/darwin_ios.go @@ -8,7 +8,7 @@ package app /* -#cgo CFLAGS: -x objective-c +#cgo CFLAGS: -x objective-c -DGL_SILENCE_DEPRECATION #cgo LDFLAGS: -framework Foundation -framework UIKit -framework GLKit -framework OpenGLES -framework QuartzCore #include #include diff --git a/exp/font/font_darwin.go b/exp/font/font_darwin.go index e82713c..7f9f1d3 100644 --- a/exp/font/font_darwin.go +++ b/exp/font/font_darwin.go @@ -68,9 +68,9 @@ func buildFont(f C.CTFontRef) []byte { } func buildDefault() ([]byte, error) { - return buildFont(C.CTFontCreateUIFontForLanguage(C.kCTFontSystemFontType, 0, nil)), nil + return buildFont(C.CTFontCreateUIFontForLanguage(C.kCTFontSystemFontType, 0, 0)), nil } func buildMonospace() ([]byte, error) { - return buildFont(C.CTFontCreateUIFontForLanguage(C.kCTFontUserFixedPitchFontType, 0, nil)), nil + return buildFont(C.CTFontCreateUIFontForLanguage(C.kCTFontUserFixedPitchFontType, 0, 0)), nil } diff --git a/exp/gl/glutil/context_darwin_desktop.go b/exp/gl/glutil/context_darwin_desktop.go index e9e9355..42488a2 100644 --- a/exp/gl/glutil/context_darwin_desktop.go +++ b/exp/gl/glutil/context_darwin_desktop.go @@ -12,6 +12,7 @@ package glutil // TODO(crawshaw): Support android and windows. /* +#cgo CFLAGS: -DGL_SILENCE_DEPRECATION #cgo LDFLAGS: -framework OpenGL #import #import diff --git a/gl/work.go b/gl/work.go index 3a8bacf..9f340c1 100644 --- a/gl/work.go +++ b/gl/work.go @@ -19,6 +19,7 @@ package gl #cgo darwin,amd64,!ios CFLAGS: -Dos_osx #cgo darwin,arm CFLAGS: -Dos_ios #cgo darwin,arm64 CFLAGS: -Dos_ios +#cgo darwin CFLAGS: -DGL_SILENCE_DEPRECATION #cgo linux CFLAGS: -Dos_linux #cgo openbsd CFLAGS: -Dos_openbsd