ebiten/graphics/rendertarget/render_target.go

28 lines
644 B
Go
Raw Normal View History

2013-10-25 21:15:27 +02:00
package rendertarget
import (
"github.com/hajimehoshi/go-ebiten/graphics/texture"
)
2013-11-26 15:05:54 +01:00
type OffscreenSetter interface {
Set(framebuffer interface{}, x, y, width, height int)
}
2013-10-25 21:15:27 +02:00
type RenderTarget struct {
texture *texture.Texture
framebuffer interface{}
}
func NewWithFramebuffer(texture *texture.Texture, framebuffer interface{}) *RenderTarget {
return &RenderTarget{
texture: texture,
framebuffer: framebuffer,
}
}
2013-11-26 15:05:54 +01:00
func (renderTarget *RenderTarget) SetAsOffscreen(setter OffscreenSetter) {
2013-10-27 15:55:44 +01:00
renderTarget.texture.SetAsViewport(func(x, y, width, height int) {
2013-11-26 15:05:54 +01:00
setter.Set(renderTarget.framebuffer, x, y, width, height)
2013-10-27 15:55:44 +01:00
})
2013-10-27 13:27:16 +01:00
}