monogame: Set viewports

Updates #1078
This commit is contained in:
Hajime Hoshi 2020-04-06 02:17:49 +09:00
parent 7f64043ba5
commit f0c2c0e8e9
3 changed files with 9 additions and 9 deletions

View File

@ -114,8 +114,8 @@ type screen struct {
game *monogame.Game game *monogame.Game
} }
func (s *screen) SetAsDestination() { func (s *screen) SetAsDestination(viewportWidth, viewportHeight int) {
s.game.ResetDestination() s.game.ResetDestination(viewportWidth, viewportHeight)
} }
func (s *screen) SetAsSource() { func (s *screen) SetAsSource() {

View File

@ -21,7 +21,7 @@ import (
) )
type RenderTarget2D interface { type RenderTarget2D interface {
SetAsDestination() SetAsDestination(viewportWidth, viewportHeight int)
SetAsSource() SetAsSource()
ReplacePixels(args []*driver.ReplacePixelsArgs) ReplacePixels(args []*driver.ReplacePixelsArgs)
Dispose() Dispose()
@ -48,7 +48,7 @@ func (*Image) Pixels() ([]byte, error) {
} }
func (i *Image) SetAsDestination() { func (i *Image) SetAsDestination() {
i.v.SetAsDestination() i.v.SetAsDestination(i.width, i.height)
} }
func (i *Image) SetAsSource() { func (i *Image) SetAsSource() {

View File

@ -110,8 +110,8 @@ func (g *Game) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, co
g.binding.Call("Draw", indexLen, indexOffset) g.binding.Call("Draw", indexLen, indexOffset)
} }
func (g *Game) ResetDestination() { func (g *Game) ResetDestination(viewportWidth, viewportHeight int) {
g.binding.Set("Dst", nil) g.binding.Call("SetDestination", nil, viewportWidth, viewportHeight)
} }
type RenderTarget2D struct { type RenderTarget2D struct {
@ -132,10 +132,10 @@ func (r *RenderTarget2D) ReplacePixels(args []*driver.ReplacePixelsArgs) {
} }
} }
func (r *RenderTarget2D) SetAsDestination() { func (r *RenderTarget2D) SetAsDestination(viewportWidth, viewportHeight int) {
r.binding.Set("Dst", r.v) r.binding.Call("SetDestination", r.v, viewportWidth, viewportHeight)
} }
func (r *RenderTarget2D) SetAsSource() { func (r *RenderTarget2D) SetAsSource() {
r.binding.Set("Src", r.v) r.binding.Call("SetSource", r.v)
} }