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
}
func (s *screen) SetAsDestination() {
s.game.ResetDestination()
func (s *screen) SetAsDestination(viewportWidth, viewportHeight int) {
s.game.ResetDestination(viewportWidth, viewportHeight)
}
func (s *screen) SetAsSource() {

View File

@ -21,7 +21,7 @@ import (
)
type RenderTarget2D interface {
SetAsDestination()
SetAsDestination(viewportWidth, viewportHeight int)
SetAsSource()
ReplacePixels(args []*driver.ReplacePixelsArgs)
Dispose()
@ -48,7 +48,7 @@ func (*Image) Pixels() ([]byte, error) {
}
func (i *Image) SetAsDestination() {
i.v.SetAsDestination()
i.v.SetAsDestination(i.width, i.height)
}
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)
}
func (g *Game) ResetDestination() {
g.binding.Set("Dst", nil)
func (g *Game) ResetDestination(viewportWidth, viewportHeight int) {
g.binding.Call("SetDestination", nil, viewportWidth, viewportHeight)
}
type RenderTarget2D struct {
@ -132,10 +132,10 @@ func (r *RenderTarget2D) ReplacePixels(args []*driver.ReplacePixelsArgs) {
}
}
func (r *RenderTarget2D) SetAsDestination() {
r.binding.Set("Dst", r.v)
func (r *RenderTarget2D) SetAsDestination(viewportWidth, viewportHeight int) {
r.binding.Call("SetDestination", r.v, viewportWidth, viewportHeight)
}
func (r *RenderTarget2D) SetAsSource() {
r.binding.Set("Src", r.v)
r.binding.Call("SetSource", r.v)
}