init commit

This commit is contained in:
Jeff Carr 2023-03-15 07:37:39 -05:00
commit 4db71b8b76
5 changed files with 128 additions and 0 deletions

18
Makefile Normal file
View File

@ -0,0 +1,18 @@
all:
gomobile install
install:
go install golang.org/x/mobile/cmd/gomobile@latest
init:
init:
build:
# gomobile build -androidapi 16 -target=android -o myapp.apk main.go
gomobile build -target=android -o myapp.apk main.go
adb-logcat:
# this worked
adb logcat |grep jwc

11
go.mod Normal file
View File

@ -0,0 +1,11 @@
module git.wit.org/jcarr/my-gomobile
go 1.19
require golang.org/x/mobile v0.0.0-20230301163155-e0f57694e12c
require (
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 // indirect
golang.org/x/image v0.0.0-20190802002840-cff245a6509b // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
)

20
go.sum Normal file
View File

@ -0,0 +1,20 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 h1:estk1glOnSVeJ9tdEZZc5mAMDZk5lNJNyJ6DvrBkTEU=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20230301163155-e0f57694e12c h1:Gk61ECugwEHL6IiyyNLXNzmu8XslmRP2dS0xjIYhbb4=
golang.org/x/mobile v0.0.0-20230301163155-e0f57694e12c/go.mod h1:aAjjkJNdrh3PMckS4B10TGS2nag27cbKR1y2BpUxsiY=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=

79
main.go Normal file
View File

@ -0,0 +1,79 @@
package main
import (
"fmt"
"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/event/touch"
"golang.org/x/mobile/gl"
)
func main() {
app.Main(func(a app.App) {
var glctx gl.Context
fmt.Printf("does anything log anywhere. does anything work at all?")
fmt.Printf("does anything log anywhere. does anything work at all?")
fmt.Printf("does anything log anywhere. does anything work at all?")
fmt.Printf("does anything log anywhere. does anything work at all?")
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()
case lifecycle.CrossOff:
onStop()
glctx = nil
}
case size.Event:
onResize(e)
case paint.Event:
if glctx == nil {
continue
}
onDraw(glctx)
a.Publish()
case touch.Event:
onTouch(e)
}
}
})
}
func onStart() {
fmt.Println("App started")
}
func onStop() {
fmt.Println("App stopped")
}
func onResize(e size.Event) {
runtime.LockOSThread()
gl.Viewport(0, 0, e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
fmt.Printf("jwc onResize()", e.WidthPx, e.HeightPx)
runtime.UnlockOSThread()
}
func onDraw(glctx gl.Context) {
glctx.ClearColor(0.1, 0.1, 0.1, 1)
glctx.Clear(gl.COLOR_BUFFER_BIT)
}
func onTouch(e touch.Event) {
fmt.Printf("Touch event: X: %f, Y: %f\n", e.X, e.Y)
}

BIN
my_gomobile.apk Normal file

Binary file not shown.