From e6ae53a27f4fd7cfa2943f2ae47b96cba8eb01c9 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Thu, 17 Dec 2020 00:02:56 -0500 Subject: [PATCH] gl: add darwin/arm64 (macOS) support Update the build constraints so that OpenGL is used both on macOS AMD64 and ARM64, while OpenGL ES is used on iOS. This fixes the build on M1 Macs. For golang/go#43237. Change-Id: Iad2d406eaf0ddbe72f221f497dd074ad0b22015e Reviewed-on: https://go-review.googlesource.com/c/mobile/+/278779 Trust: Dmitri Shuralyov Reviewed-by: Hajime Hoshi --- gl/work.c | 2 +- gl/work.go | 30 +++++++++++++----------------- gl/work.h | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/gl/work.c b/gl/work.c index 7203acf26..587856c57 100644 --- a/gl/work.c +++ b/gl/work.c @@ -356,7 +356,7 @@ uintptr_t processFn(struct fnargs* args, char* parg) { glScissor((GLint)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3); break; case glfnShaderSource: -#if defined(os_ios) || defined(os_osx) +#if defined(os_ios) || defined(os_macos) glShaderSource((GLuint)args->a0, (GLsizei)args->a1, (const GLchar *const *)args->a2, NULL); #else glShaderSource((GLuint)args->a0, (GLsizei)args->a1, (const GLchar **)args->a2, NULL); diff --git a/gl/work.go b/gl/work.go index 9f340c109..bf1739446 100644 --- a/gl/work.go +++ b/gl/work.go @@ -7,23 +7,19 @@ package gl /* -#cgo ios LDFLAGS: -framework OpenGLES -#cgo darwin,amd64,!ios LDFLAGS: -framework OpenGL -#cgo darwin,arm LDFLAGS: -framework OpenGLES -#cgo darwin,arm64 LDFLAGS: -framework OpenGLES -#cgo linux LDFLAGS: -lGLESv2 -#cgo openbsd LDFLAGS: -L/usr/X11R6/lib/ -lGLESv2 - -#cgo android CFLAGS: -Dos_android -#cgo ios CFLAGS: -Dos_ios -#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 - -#cgo openbsd CFLAGS: -I/usr/X11R6/include/ +#cgo ios LDFLAGS: -framework OpenGLES +#cgo darwin,!ios LDFLAGS: -framework OpenGL +#cgo linux LDFLAGS: -lGLESv2 +#cgo openbsd LDFLAGS: -L/usr/X11R6/lib/ -lGLESv2 + +#cgo android CFLAGS: -Dos_android +#cgo ios CFLAGS: -Dos_ios +#cgo darwin,!ios CFLAGS: -Dos_macos +#cgo darwin CFLAGS: -DGL_SILENCE_DEPRECATION +#cgo linux CFLAGS: -Dos_linux +#cgo openbsd CFLAGS: -Dos_openbsd + +#cgo openbsd CFLAGS: -I/usr/X11R6/include/ #include #include "work.h" diff --git a/gl/work.h b/gl/work.h index cc2e48cc3..5bc093b37 100644 --- a/gl/work.h +++ b/gl/work.h @@ -18,7 +18,7 @@ #include #endif -#ifdef os_osx +#ifdef os_macos #include #define GL_ES_VERSION_3_0 1 #endif