diff --git a/backend/gogl/gl/package.go b/backend/gogl/gl/package.go index dac4af1..3791b18 100644 --- a/backend/gogl/gl/package.go +++ b/backend/gogl/gl/package.go @@ -16,7 +16,7 @@ // package gl -// #cgo darwin LDFLAGS: -framework OpenGL +// #cgo darwin LDFLAGS: -framework OpenGLES // #cgo linux,!android LDFLAGS: -lGL // #cgo freebsd,!android LDFLAGS: -lGL // #cgo windows LDFLAGS: -lopengl32 @@ -49,7 +49,7 @@ package gl // typedef float GLfloat; // typedef double GLdouble; // typedef char GLchar; -// #include +// #include "khrplatform.h" // typedef unsigned int GLenum; // typedef unsigned char GLboolean; // typedef unsigned int GLbitfield; diff --git a/backend/gogl/gl/procaddr.go b/backend/gogl/gl/procaddr.go index cfcb387..5059d2a 100644 --- a/backend/gogl/gl/procaddr.go +++ b/backend/gogl/gl/procaddr.go @@ -1,4 +1,4 @@ -// +build !android +// +build !android,!ios // Code generated by glow (https://github.com/go-gl/glow). DO NOT EDIT. // This file implements GlowGetProcAddress for every supported platform. The diff --git a/backend/gogl/gl/procaddr_android.go b/backend/gogl/gl/procaddr_mobile.go similarity index 98% rename from backend/gogl/gl/procaddr_android.go rename to backend/gogl/gl/procaddr_mobile.go index 61c339e..129e863 100644 --- a/backend/gogl/gl/procaddr_android.go +++ b/backend/gogl/gl/procaddr_mobile.go @@ -1,3 +1,5 @@ +// +build android ios + // Code generated by glow (https://github.com/go-gl/glow). DO NOT EDIT. // This file implements GlowGetProcAddress for every supported platform. The @@ -17,7 +19,14 @@ package gl /* #cgo android LDFLAGS: -lGLESv2 -#include +#cgo android CFLAGS: -DANDROID +#cgo ios CFLAGS: -DIOS +#ifdef ANDROID + #include +#endif +#ifdef IOS + #include +#endif */ import "C" import "unsafe" diff --git a/examples/ios/README.md b/examples/ios/README.md index 2fd0e28..4ccd0fe 100644 --- a/examples/ios/README.md +++ b/examples/ios/README.md @@ -1,5 +1,7 @@ +As of this writing, gomobile does not support go modules. In this case this project can only be compiled while it is in the GOPATH/src directory. + Run this command: -gomobile bind -target ios +gomobile bind -target ios -tags ios Then add the resulting Example.framework into the Xcode project, and it should compile and run from there diff --git a/examples/ios/ios.go b/examples/ios/ios.go index c5eb41b..d0c8d7c 100644 --- a/examples/ios/ios.go +++ b/examples/ios/ios.go @@ -2,10 +2,9 @@ package example import ( "math" - "time" "github.com/tfriedel6/canvas" - "github.com/tfriedel6/canvas/glimpl/ios" + "github.com/tfriedel6/canvas/backend/gogl" ) var cv *canvas.Canvas @@ -16,12 +15,11 @@ func TouchEvent(typ string, x, y int) { } func LoadGL(w, h int) { - err := canvas.LoadGL(glimplios.GLImpl{}) + backend, err := goglbackend.New(0, 0, w, h) if err != nil { - time.Sleep(100 * time.Millisecond) panic(err) } - cv = canvas.New(0, 0, w, h) + cv = canvas.New(backend) } func DrawFrame() {