Skip to content

Commit e6ae53a

Browse files
committed
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 <[email protected]> Reviewed-by: Hajime Hoshi <[email protected]>
1 parent da85bec commit e6ae53a

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

gl/work.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ uintptr_t processFn(struct fnargs* args, char* parg) {
356356
glScissor((GLint)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3);
357357
break;
358358
case glfnShaderSource:
359-
#if defined(os_ios) || defined(os_osx)
359+
#if defined(os_ios) || defined(os_macos)
360360
glShaderSource((GLuint)args->a0, (GLsizei)args->a1, (const GLchar *const *)args->a2, NULL);
361361
#else
362362
glShaderSource((GLuint)args->a0, (GLsizei)args->a1, (const GLchar **)args->a2, NULL);

gl/work.go

+13-17
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@
77
package gl
88

99
/*
10-
#cgo ios LDFLAGS: -framework OpenGLES
11-
#cgo darwin,amd64,!ios LDFLAGS: -framework OpenGL
12-
#cgo darwin,arm LDFLAGS: -framework OpenGLES
13-
#cgo darwin,arm64 LDFLAGS: -framework OpenGLES
14-
#cgo linux LDFLAGS: -lGLESv2
15-
#cgo openbsd LDFLAGS: -L/usr/X11R6/lib/ -lGLESv2
16-
17-
#cgo android CFLAGS: -Dos_android
18-
#cgo ios CFLAGS: -Dos_ios
19-
#cgo darwin,amd64,!ios CFLAGS: -Dos_osx
20-
#cgo darwin,arm CFLAGS: -Dos_ios
21-
#cgo darwin,arm64 CFLAGS: -Dos_ios
22-
#cgo darwin CFLAGS: -DGL_SILENCE_DEPRECATION
23-
#cgo linux CFLAGS: -Dos_linux
24-
#cgo openbsd CFLAGS: -Dos_openbsd
25-
26-
#cgo openbsd CFLAGS: -I/usr/X11R6/include/
10+
#cgo ios LDFLAGS: -framework OpenGLES
11+
#cgo darwin,!ios LDFLAGS: -framework OpenGL
12+
#cgo linux LDFLAGS: -lGLESv2
13+
#cgo openbsd LDFLAGS: -L/usr/X11R6/lib/ -lGLESv2
14+
15+
#cgo android CFLAGS: -Dos_android
16+
#cgo ios CFLAGS: -Dos_ios
17+
#cgo darwin,!ios CFLAGS: -Dos_macos
18+
#cgo darwin CFLAGS: -DGL_SILENCE_DEPRECATION
19+
#cgo linux CFLAGS: -Dos_linux
20+
#cgo openbsd CFLAGS: -Dos_openbsd
21+
22+
#cgo openbsd CFLAGS: -I/usr/X11R6/include/
2723
2824
#include <stdint.h>
2925
#include "work.h"

gl/work.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <OpenGLES/ES2/glext.h>
1919
#endif
2020

21-
#ifdef os_osx
21+
#ifdef os_macos
2222
#include <OpenGL/gl3.h>
2323
#define GL_ES_VERSION_3_0 1
2424
#endif

0 commit comments

Comments
 (0)