zntg/sdlui/rendererfactory.go

27 lines
673 B
Go

package sdlui
import (
"github.com/veandco/go-sdl2/sdl"
"opslag.de/schobers/zntg/ui"
)
func init() {
ui.SetRendererFactory(&rendererFactory{})
}
type rendererFactory struct{}
func (f rendererFactory) New(title string, width, height int, opts ui.NewRendererOptions) (ui.Renderer, error) {
location := sdl.Point{X: sdl.WINDOWPOS_UNDEFINED, Y: sdl.WINDOWPOS_UNDEFINED}
if opts.Location != nil {
location.X = int32(opts.Location.X)
location.Y = int32(opts.Location.Y)
}
return NewRenderer(title, int32(width), int32(height), NewRendererOptions{
Borderless: opts.Borderless,
Location: location,
Resizable: opts.Resizable,
VSync: opts.VSync,
})
}