zntg/sdlui/rendererfactory.go

25 lines
689 B
Go
Raw Normal View History

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) (ui.Renderer, error) {
return f.NewOptions(title, width, height, ui.NewRendererOptions{Resizable: true})
}
func (f rendererFactory) NewOptions(title string, width, height int, opts ui.NewRendererOptions) (ui.Renderer, error) {
return NewRenderer(title, int32(width), int32(height), NewRendererOptions{
Location: sdl.Point{X: sdl.WINDOWPOS_UNDEFINED, Y: sdl.WINDOWPOS_UNDEFINED},
Resizable: opts.Resizable,
VSync: opts.VSync,
})
}