parent
a06652bfed
commit
88b39c35fc
10
Makefile
10
Makefile
|
@ -6,9 +6,6 @@ install:
|
|||
|
||||
init:
|
||||
|
||||
init:
|
||||
|
||||
|
||||
build:
|
||||
# gomobile build -androidapi 16 -target=android -o myapp.apk main.go
|
||||
gomobile build -target=android -o myapp.apk main.go
|
||||
|
@ -16,3 +13,10 @@ build:
|
|||
adb-logcat:
|
||||
# this worked
|
||||
adb logcat |grep jwc
|
||||
|
||||
untar:
|
||||
mkdir junk/
|
||||
cd junk && apktool decode ../my_gomobile.apk
|
||||
|
||||
test-gui:
|
||||
go get -v check.lab.wit.org/gui@lastest
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
all:
|
||||
go build
|
||||
./desktop
|
|
@ -0,0 +1,68 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/mobile/app"
|
||||
"golang.org/x/mobile/event/lifecycle"
|
||||
"golang.org/x/mobile/event/paint"
|
||||
"golang.org/x/mobile/event/size"
|
||||
// "golang.org/x/mobile/geom"
|
||||
"golang.org/x/mobile/gl"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app.Main(func(a app.App) {
|
||||
var (
|
||||
glctx gl.Context
|
||||
sz size.Event
|
||||
// rotation geom.Angle
|
||||
)
|
||||
|
||||
for e := range a.Events() {
|
||||
switch e := a.Filter(e).(type) {
|
||||
case lifecycle.Event:
|
||||
switch e.Crosses(lifecycle.StageVisible) {
|
||||
case lifecycle.CrossOn:
|
||||
glctx, _ = e.DrawContext.(gl.Context)
|
||||
onStart(glctx)
|
||||
case lifecycle.CrossOff:
|
||||
onStop()
|
||||
glctx = nil
|
||||
}
|
||||
case size.Event:
|
||||
sz = e
|
||||
case paint.Event:
|
||||
if glctx == nil {
|
||||
continue
|
||||
}
|
||||
onDraw(glctx, sz)
|
||||
a.Publish()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func onStart(glctx gl.Context) {
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started")
|
||||
glctx.ClearColor(0.1, 0.5, 0.8, 0.5)
|
||||
glctx.Clear(gl.COLOR_BUFFER_BIT)
|
||||
}
|
||||
|
||||
func onStop() {
|
||||
log.Println("App stopped")
|
||||
}
|
||||
|
||||
func onDraw(glctx gl.Context, sz size.Event) {
|
||||
runtime.LockOSThread()
|
||||
|
||||
glctx.ClearColor(0.1, 0.5, 0.8, 0.5)
|
||||
glctx.Clear(gl.COLOR_BUFFER_BIT)
|
||||
|
||||
runtime.UnlockOSThread()
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/mobile/app"
|
||||
"golang.org/x/mobile/event/lifecycle"
|
||||
"golang.org/x/mobile/event/paint"
|
||||
"golang.org/x/mobile/event/size"
|
||||
// "golang.org/x/mobile/geom"
|
||||
"golang.org/x/mobile/gl"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app.Main(func(a app.App) {
|
||||
var (
|
||||
glctx gl.Context
|
||||
sz size.Event
|
||||
// rotation geom.Angle
|
||||
)
|
||||
|
||||
for e := range a.Events() {
|
||||
switch e := a.Filter(e).(type) {
|
||||
case lifecycle.Event:
|
||||
switch e.Crosses(lifecycle.StageVisible) {
|
||||
case lifecycle.CrossOn:
|
||||
glctx, _ = e.DrawContext.(gl.Context)
|
||||
onStart(glctx)
|
||||
case lifecycle.CrossOff:
|
||||
onStop()
|
||||
glctx = nil
|
||||
}
|
||||
case size.Event:
|
||||
sz = e
|
||||
case paint.Event:
|
||||
if glctx == nil {
|
||||
continue
|
||||
}
|
||||
onDraw(glctx, sz)
|
||||
a.Publish()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func onStart(glctx gl.Context) {
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started")
|
||||
log.Println("jwc OPENGL App started # purple")
|
||||
// glctx.ClearColor(1, 0, 1, 0.5)
|
||||
glctx.ClearColor(1, 0, 1, 0.5) // purple
|
||||
glctx.Clear(gl.COLOR_BUFFER_BIT)
|
||||
}
|
||||
|
||||
func onStop() {
|
||||
log.Println("App stopped")
|
||||
}
|
||||
|
||||
func onDraw(glctx gl.Context, sz size.Event) {
|
||||
runtime.LockOSThread()
|
||||
|
||||
// glctx.ClearColor(0.1, 0.5, 0.8, 0.5) // blue
|
||||
// glctx.ClearColor(0.8, 0.5, 0.1, 0.5) // orange
|
||||
// glctx.ClearColor(0.5, 0.8, 0.1, 0.5) // green
|
||||
// glctx.ClearColor(0.5, 0.8, 0.1, 0.5)
|
||||
// glctx.Clear(gl.COLOR_BUFFER_BIT)
|
||||
|
||||
runtime.UnlockOSThread()
|
||||
}
|
BIN
my_gomobile.apk
BIN
my_gomobile.apk
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
junk/
|
||||
junk/my_gomobile
|
||||
junk/my_gomobile/original
|
||||
junk/my_gomobile/original/META-INF
|
||||
junk/my_gomobile/original/META-INF/CERT.RSA
|
||||
junk/my_gomobile/original/META-INF/CERT.SF
|
||||
junk/my_gomobile/original/META-INF/MANIFEST.MF
|
||||
junk/my_gomobile/original/AndroidManifest.xml
|
||||
junk/my_gomobile/AndroidManifest.xml
|
||||
junk/my_gomobile/lib
|
||||
junk/my_gomobile/lib/x86_64
|
||||
junk/my_gomobile/lib/x86_64/libmy_gomobile.so
|
||||
junk/my_gomobile/lib/x86
|
||||
junk/my_gomobile/lib/x86/libmy_gomobile.so
|
||||
junk/my_gomobile/lib/arm64-v8a
|
||||
junk/my_gomobile/lib/arm64-v8a/libmy_gomobile.so
|
||||
junk/my_gomobile/lib/armeabi-v7a
|
||||
junk/my_gomobile/lib/armeabi-v7a/libmy_gomobile.so
|
||||
junk/my_gomobile/apktool.yml
|
||||
junk/my_gomobile/smali
|
||||
junk/my_gomobile/smali/org
|
||||
junk/my_gomobile/smali/org/golang
|
||||
junk/my_gomobile/smali/org/golang/app
|
||||
junk/my_gomobile/smali/org/golang/app/GoNativeActivity.smali
|
||||
junk/my_gomobile.apk
|
Loading…
Reference in New Issue