EngoEngine / engo

Engo is an open-source 2D game engine written in Go.
https://engoengine.github.io
MIT License
1.73k stars 137 forks source link

Support WebGL and Android #775

Closed zurgeg closed 3 years ago

zurgeg commented 3 years ago

Currently, Engo uses github.com/go-gl/gl, which limits us to darwin, windows, and linux (and freebsd iirc). Engo should switch to a more cross-platform GL port. I propose the usage of https://github.com/goxjs/gl.

Noofbiz commented 3 years ago

Actually, engo uses github.com/EngoEngine/gl which has support for mobile and web!

zurgeg commented 3 years ago

Actually, engo uses github.com/EngoEngine/gl which has support for mobile and web!

Huh, I tried to build for Web and it failed

Noofbiz commented 3 years ago

I currently use https://github.com/Noofbiz/engoWasmServer as an automated tool for testing myself, but all it uses is the normal go tools with goos=js and goarch=wasm to build. If you need more help building for us let me know, I’ll keep this open.

zurgeg commented 3 years ago

I currently use https://github.com/Noofbiz/engoWasmServer as an automated tool for testing myself, but all it uses is the normal go tools with goos=js and goarch=wasm to build. If you need more help building for us let me know, I’ll keep this open.

Alright, I will grab the error later.

zurgeg commented 3 years ago

@Noofbiz After further research, I get src/github.com/EngoEngine/gl/gl_webgl.go:1541:2: undefined: log.Error when attempting to build EngoEngine/gl, rather then a constraint related error like I got before, but still an error. Any idea why this happens?

Noofbiz commented 3 years ago

I updated to use the latest gl, should take care of that error message

zurgeg commented 3 years ago

I updated to use the latest gl, should take care of that error message

Great, I will try building, glad I could help ^^)

zurgeg commented 3 years ago

@Noofbiz Now it fails with:

/home/redacted/go/src/github.com/EngoEngine/engo/engo_js.go:46:25: document.Get("body").IsNull undefined (type js.Value has no field or method IsNull)
/home/redacted/go/src/github.com/EngoEngine/engo/engo_js.go:172:9: joy.IsNull undefined (type js.Value has no field or method IsNull)
/home/redacted/go/src/github.com/EngoEngine/engo/engo_js.go:188:9: joy.IsNull undefined (type js.Value has no field or method IsNull)
/home/redacted/go/src/github.com/EngoEngine/engo/gamepads_js.go:32:19: gpds.Index(i).IsNull undefined (type js.Value has no field or method IsNull)
/home/redacted/go/src/github.com/EngoEngine/engo/gamepads_js.go:54:11: window.IsUndefined undefined (type js.Value has no field or method IsUndefined)
/home/redacted/go/src/github.com/EngoEngine/engo/gamepads_js.go:54:52: window.Get("navigator").IsUndefined undefined (type js.Value has no field or method IsUndefined)
/home/redacted/go/src/github.com/EngoEngine/engo/gamepads_js.go:66:20: gpds.Index(i).IsNull undefined (type js.Value has no field or method IsNull)

EDIT: Turns out it was an outdated version of Go

zurgeg commented 3 years ago

@Noofbiz Turns out that on some versions of Go, you need to use ValueEqual. Build fails with this error for reference:

engo_js.go:45:26: invalid operation: document.Get("body") == js.Null() (struct containing [0]func() cannot be compared)
zurgeg commented 3 years ago

Oh wait, turns out my version of Engo was outdated haha, will try building once I fix that

zurgeg commented 3 years ago

Can confirm, it works now