diff --git a/Makefile b/Makefile index 4a3008b..4184461 100644 --- a/Makefile +++ b/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 diff --git a/desktop/Makefile b/desktop/Makefile new file mode 100644 index 0000000..5f5c636 --- /dev/null +++ b/desktop/Makefile @@ -0,0 +1,3 @@ +all: + go build + ./desktop diff --git a/holyshitblue/main.go b/holyshitblue/main.go new file mode 100644 index 0000000..d223898 --- /dev/null +++ b/holyshitblue/main.go @@ -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() +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..ed795f7 --- /dev/null +++ b/main.go @@ -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() +} diff --git a/my_gomobile.apk b/my_gomobile.apk index dee1fbf..392311e 100644 Binary files a/my_gomobile.apk and b/my_gomobile.apk differ diff --git a/my_gomobile.apk.file-list b/my_gomobile.apk.file-list new file mode 100644 index 0000000..56fae9e --- /dev/null +++ b/my_gomobile.apk.file-list @@ -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