updated gogl backend to work on ios as well, updated ios example
This commit is contained in:
parent
654d9b1796
commit
f8aa4d62ce
5 changed files with 19 additions and 10 deletions
|
@ -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 <KHR/khrplatform.h>
|
||||
// #include "khrplatform.h"
|
||||
// typedef unsigned int GLenum;
|
||||
// typedef unsigned char GLboolean;
|
||||
// typedef unsigned int GLbitfield;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <GLES2/gl2.h>
|
||||
#cgo android CFLAGS: -DANDROID
|
||||
#cgo ios CFLAGS: -DIOS
|
||||
#ifdef ANDROID
|
||||
#include <GLES2/gl2.h>
|
||||
#endif
|
||||
#ifdef IOS
|
||||
#include <OpenGLES/ES2/GL.h>
|
||||
#endif
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue