Skip to content

Commit

Permalink
gl: add darwin/arm64 (macOS) support
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Hajime Hoshi <[email protected]>
  • Loading branch information
dmitshur committed Dec 17, 2020
1 parent da85bec commit e6ae53a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gl/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 13 additions & 17 deletions gl/work.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h>
#include "work.h"
Expand Down
2 changes: 1 addition & 1 deletion gl/work.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <OpenGLES/ES2/glext.h>
#endif

#ifdef os_osx
#ifdef os_macos
#include <OpenGL/gl3.h>
#define GL_ES_VERSION_3_0 1
#endif
Expand Down

0 comments on commit e6ae53a

Please sign in to comment.