From 3a5f0a7a9574daf3e0b0d0d29388401d9958d84b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 5 Apr 2020 16:34:34 +0900 Subject: [PATCH] graphicsdriver/monogame: Implement some functions Updates #1078 --- internal/graphicsdriver/monogame/graphics.go | 16 ++++++++++++++-- internal/graphicsdriver/monogame/image.go | 8 ++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/graphicsdriver/monogame/graphics.go b/internal/graphicsdriver/monogame/graphics.go index a213745e5..953a604fb 100644 --- a/internal/graphicsdriver/monogame/graphics.go +++ b/internal/graphicsdriver/monogame/graphics.go @@ -24,6 +24,10 @@ import ( ) type Graphics struct { + dst *Image + src *Image + vertices []float32 + indices []uint16 } var theGraphics Graphics @@ -33,25 +37,31 @@ func Get() *Graphics { } func (g *Graphics) SetThread(thread *thread.Thread) { - panic("monogame: SetThread is not implemented yet") + panic("monogame: SetThread is not implemented") } func (g *Graphics) Begin() { + // Do nothing } func (g *Graphics) End() { + // Do nothing } func (g *Graphics) SetTransparent(transparent bool) { + panic("monogame: SetTransparent is not implemented yet") } func (g *Graphics) SetVertices(vertices []float32, indices []uint16) { + g.vertices = vertices + g.indices = indices } func (g *Graphics) NewImage(width, height int) (driver.Image, error) { v := monogame.CurrentGame().NewRenderTarget2D(width, height) return &Image{ v: v, + g: g, width: width, height: height, }, nil @@ -59,6 +69,7 @@ func (g *Graphics) NewImage(width, height int) (driver.Image, error) { func (g *Graphics) NewScreenFramebufferImage(width, height int) (driver.Image, error) { return &Image{ + g: g, width: width, height: height, }, nil @@ -69,11 +80,12 @@ func (g *Graphics) Reset() error { } func (g *Graphics) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) error { + // TODO: Implement return nil } func (g *Graphics) SetVsyncEnabled(enabled bool) { - // TODO: Implement this + panic("monogame: SetVsyncEnabled is not implemented yet") } func (g *Graphics) VDirection() driver.VDirection { diff --git a/internal/graphicsdriver/monogame/image.go b/internal/graphicsdriver/monogame/image.go index 2875c256a..d12683dbb 100644 --- a/internal/graphicsdriver/monogame/image.go +++ b/internal/graphicsdriver/monogame/image.go @@ -23,6 +23,7 @@ import ( type Image struct { v *monogame.RenderTarget2D + g *Graphics width int height int } @@ -36,13 +37,16 @@ func (*Image) IsInvalidated() bool { } func (*Image) Pixels() ([]byte, error) { + panic("monogame: Pixels is not implemented yet") return nil, nil } -func (*Image) SetAsDestination() { +func (i *Image) SetAsDestination() { + i.g.dst = i } -func (*Image) SetAsSource() { +func (i *Image) SetAsSource() { + i.g.src = i } func (i *Image) ReplacePixels(args []*driver.ReplacePixelsArgs) {