diff --git a/ebitenutil/loadimage_js.go b/ebitenutil/loadimage_js.go index faab17f2f..364d9b079 100644 --- a/ebitenutil/loadimage_js.go +++ b/ebitenutil/loadimage_js.go @@ -27,7 +27,7 @@ import ( func NewImageFromFile(path string, filter ebiten.Filter) (*ebiten.Image, image.Image, error) { var err error - var content js.Object + var content *js.Object ch := make(chan struct{}) req := js.Global.Get("XMLHttpRequest").New() req.Call("open", "GET", path, true) diff --git a/exp/audio/internal/audio_js.go b/exp/audio/internal/audio_js.go index 7be097c66..d282c8ffa 100644 --- a/exp/audio/internal/audio_js.go +++ b/exp/audio/internal/audio_js.go @@ -26,9 +26,9 @@ func withChannels(f func()) { // Keep this so as not to be destroyed by GC. var ( - nodes = []js.Object{} - dummies = []js.Object{} // Dummy source nodes for iOS. - context js.Object + nodes = []*js.Object{} + dummies = []*js.Object{} // Dummy source nodes for iOS. + context *js.Object ) const bufferSize = 1024 @@ -37,7 +37,7 @@ type audioProcessor struct { channel int } -func (a *audioProcessor) Process(e js.Object) { +func (a *audioProcessor) Process(e *js.Object) { // Can't use 'go' here. Probably it may cause race conditions. b := e.Get("outputBuffer") l := b.Call("getChannelData", 0) diff --git a/internal/graphics/internal/opengl/context_js.go b/internal/graphics/internal/opengl/context_js.go index 03dfa2532..ae4dfe074 100644 --- a/internal/graphics/internal/opengl/context_js.go +++ b/internal/graphics/internal/opengl/context_js.go @@ -24,25 +24,25 @@ import ( ) type Texture struct { - js.Object + *js.Object } type Framebuffer struct { - js.Object + *js.Object } var ZeroFramebuffer Framebuffer type Shader struct { - js.Object + *js.Object } type Program struct { - js.Object + *js.Object } type Buffer struct { - js.Object + *js.Object } // TODO: Remove this after the GopherJS bug was fixed (#159) @@ -51,7 +51,7 @@ func (p Program) Equals(other Program) bool { } type UniformLocation struct { - js.Object + *js.Object } type AttribLocation int @@ -192,7 +192,7 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) { return Framebuffer{f}, nil } -var lastBindedFramebuffer js.Object +var lastBindedFramebuffer *js.Object func (c *Context) SetViewport(f Framebuffer, width, height int) error { // TODO: Not sure if Flush is needed here. diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index fb5113775..ce13fb1dc 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -65,7 +65,7 @@ func SetScreenScale(scale int) (bool, int) { return result, actualScale } -var canvas js.Object +var canvas *js.Object type userInterface struct{} @@ -161,55 +161,55 @@ func Init() { canvas.Get("style").Set("outline", "none") // Keyboard - canvas.Call("addEventListener", "keydown", func(e js.Object) { + canvas.Call("addEventListener", "keydown", func(e *js.Object) { e.Call("preventDefault") code := e.Get("keyCode").Int() currentInput.KeyDown(code) }) - canvas.Call("addEventListener", "keyup", func(e js.Object) { + canvas.Call("addEventListener", "keyup", func(e *js.Object) { e.Call("preventDefault") code := e.Get("keyCode").Int() currentInput.KeyUp(code) }) // Mouse - canvas.Call("addEventListener", "mousedown", func(e js.Object) { + canvas.Call("addEventListener", "mousedown", func(e *js.Object) { e.Call("preventDefault") button := e.Get("button").Int() currentInput.MouseDown(button) setMouseCursorFromEvent(e) }) - canvas.Call("addEventListener", "mouseup", func(e js.Object) { + canvas.Call("addEventListener", "mouseup", func(e *js.Object) { e.Call("preventDefault") button := e.Get("button").Int() currentInput.MouseUp(button) setMouseCursorFromEvent(e) }) - canvas.Call("addEventListener", "mousemove", func(e js.Object) { + canvas.Call("addEventListener", "mousemove", func(e *js.Object) { e.Call("preventDefault") setMouseCursorFromEvent(e) }) - canvas.Call("addEventListener", "contextmenu", func(e js.Object) { + canvas.Call("addEventListener", "contextmenu", func(e *js.Object) { e.Call("preventDefault") }) // Touch (emulating mouse events) // TODO: Create indimendent touch functions - canvas.Call("addEventListener", "touchstart", func(e js.Object) { + canvas.Call("addEventListener", "touchstart", func(e *js.Object) { e.Call("preventDefault") currentInput.MouseDown(0) touches := e.Get("changedTouches") touch := touches.Index(0) setMouseCursorFromEvent(touch) }) - canvas.Call("addEventListener", "touchend", func(e js.Object) { + canvas.Call("addEventListener", "touchend", func(e *js.Object) { e.Call("preventDefault") currentInput.MouseUp(0) touches := e.Get("changedTouches") touch := touches.Index(0) setMouseCursorFromEvent(touch) }) - canvas.Call("addEventListener", "touchmove", func(e js.Object) { + canvas.Call("addEventListener", "touchmove", func(e *js.Object) { e.Call("preventDefault") touches := e.Get("changedTouches") touch := touches.Index(0) @@ -217,12 +217,12 @@ func Init() { }) // Gamepad - window.Call("addEventListener", "gamepadconnected", func(e js.Object) { + window.Call("addEventListener", "gamepadconnected", func(e *js.Object) { // Do nothing. }) } -func setMouseCursorFromEvent(e js.Object) { +func setMouseCursorFromEvent(e *js.Object) { scale := canvas.Get("dataset").Get("ebitenScale").Int() rect := canvas.Call("getBoundingClientRect") x, y := e.Get("clientX").Int(), e.Get("clientY").Int()