mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
ebitenutil: Use gopherwasm
This commit is contained in:
parent
2ec075004a
commit
9b7f5f7273
@ -21,7 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/gopherjs/gopherjs/js"
|
"github.com/hajimehoshi/gopherwasm/js"
|
||||||
)
|
)
|
||||||
|
|
||||||
type file struct {
|
type file struct {
|
||||||
@ -34,7 +34,7 @@ func (f *file) Close() error {
|
|||||||
|
|
||||||
func OpenFile(path string) (ReadSeekCloser, error) {
|
func OpenFile(path string) (ReadSeekCloser, error) {
|
||||||
var err error
|
var err error
|
||||||
var content *js.Object
|
var content js.Value
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
req := js.Global.Get("XMLHttpRequest").New()
|
req := js.Global.Get("XMLHttpRequest").New()
|
||||||
req.Call("open", "GET", path, true)
|
req.Call("open", "GET", path, true)
|
||||||
@ -58,7 +58,8 @@ func OpenFile(path string) (ReadSeekCloser, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
data := js.Global.Get("Uint8Array").New(content).Interface().([]uint8)
|
var data []byte
|
||||||
|
js.ValueOf(data).Call("set", content)
|
||||||
f := &file{bytes.NewReader(data)}
|
f := &file{bytes.NewReader(data)}
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user