mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +01:00
parent
8809076682
commit
57a5783ca0
@ -45,5 +45,6 @@ func (*Image) SetAsDestination() {
|
|||||||
func (*Image) SetAsSource() {
|
func (*Image) SetAsSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Image) ReplacePixels(args []*driver.ReplacePixelsArgs) {
|
func (i *Image) ReplacePixels(args []*driver.ReplacePixelsArgs) {
|
||||||
|
i.v.ReplacePixels(args)
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package monogame
|
|||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: This implementation depends on some C# files that are not uploaded yet.
|
// TODO: This implementation depends on some C# files that are not uploaded yet.
|
||||||
@ -53,7 +55,7 @@ func NewGame(ud UpdateDrawer) *Game {
|
|||||||
return ud.Draw()
|
return ud.Draw()
|
||||||
})
|
})
|
||||||
|
|
||||||
v := js.Global().Get(".net").Get(temporaryNamespace+".GoBinding").New(update, draw)
|
v := js.Global().Get(".net").Get(temporaryNamespace+".GameGoBinding").New(update, draw)
|
||||||
g := &Game{
|
g := &Game{
|
||||||
binding: v,
|
binding: v,
|
||||||
update: update,
|
update: update,
|
||||||
@ -76,8 +78,9 @@ func (g *Game) Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) NewRenderTarget2D(width, height int) *RenderTarget2D {
|
func (g *Game) NewRenderTarget2D(width, height int) *RenderTarget2D {
|
||||||
|
v := g.binding.Call("NewRenderTarget2D", width, height)
|
||||||
r := &RenderTarget2D{
|
r := &RenderTarget2D{
|
||||||
v: g.binding.Call("NewRenderTarget2D", width, height),
|
v: v,
|
||||||
}
|
}
|
||||||
runtime.SetFinalizer(r, (*RenderTarget2D).Dispose)
|
runtime.SetFinalizer(r, (*RenderTarget2D).Dispose)
|
||||||
return r
|
return r
|
||||||
@ -91,3 +94,11 @@ func (r *RenderTarget2D) Dispose() {
|
|||||||
runtime.SetFinalizer(r, nil)
|
runtime.SetFinalizer(r, nil)
|
||||||
r.v.Call("Dispose")
|
r.v.Call("Dispose")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RenderTarget2D) ReplacePixels(args []*driver.ReplacePixelsArgs) {
|
||||||
|
for _, a := range args {
|
||||||
|
arr := js.Global().Get("Uint8Array").New(len(a.Pixels))
|
||||||
|
js.CopyBytesToJS(arr, a.Pixels)
|
||||||
|
r.v.Call("ReplacePixels", arr, a.X, a.Y, a.Width, a.Height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user