From de02bcf19f772e68e156632e3642dc53fdd4a6b1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 12 Apr 2020 13:32:08 +0900 Subject: [PATCH] monogame: Update Updates #1078 --- internal/graphicsdriver/monogame/graphics.go | 4 ++++ internal/graphicsdriver/monogame/image.go | 6 +++++- internal/monogame/monogame.go | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/graphicsdriver/monogame/graphics.go b/internal/graphicsdriver/monogame/graphics.go index f5f4c5fb2..f51cf5c08 100644 --- a/internal/graphicsdriver/monogame/graphics.go +++ b/internal/graphicsdriver/monogame/graphics.go @@ -129,3 +129,7 @@ func (s *screen) ReplacePixels(args []*driver.ReplacePixelsArgs) { func (s *screen) Dispose() { // Do nothing? } + +func (s *screen) IsScreen() bool { + return true +} diff --git a/internal/graphicsdriver/monogame/image.go b/internal/graphicsdriver/monogame/image.go index 2356ce288..cab5530df 100644 --- a/internal/graphicsdriver/monogame/image.go +++ b/internal/graphicsdriver/monogame/image.go @@ -26,6 +26,7 @@ type RenderTarget2D interface { SetAsSource() ReplacePixels(args []*driver.ReplacePixelsArgs) Dispose() + IsScreen() bool } type Image struct { @@ -49,7 +50,10 @@ func (*Image) Pixels() ([]byte, error) { } func (i *Image) SetAsDestination() { - w, h := graphics.InternalImageSize(i.width), graphics.InternalImageSize(i.height) + w, h := i.width, i.height + if !i.v.IsScreen() { + w, h = graphics.InternalImageSize(w), graphics.InternalImageSize(h) + } i.v.SetAsDestination(w, h) } diff --git a/internal/monogame/monogame.go b/internal/monogame/monogame.go index b88d99ffd..8efeb3df2 100644 --- a/internal/monogame/monogame.go +++ b/internal/monogame/monogame.go @@ -106,8 +106,8 @@ func (g *Game) SetVertices(vertices []float32, indices []uint16) { } func (g *Game) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) { - // TODO: Implement this - g.binding.Call("Draw", indexLen, indexOffset) + src, dst := mode.Operations() + g.binding.Call("Draw", indexLen, indexOffset, int(src), int(dst)) } func (g *Game) ResetDestination(viewportWidth, viewportHeight int) { @@ -139,3 +139,7 @@ func (r *RenderTarget2D) SetAsDestination(viewportWidth, viewportHeight int) { func (r *RenderTarget2D) SetAsSource() { r.binding.Call("SetSource", r.v) } + +func (r *RenderTarget2D) IsScreen() bool { + return false +}