zntg/allg5ui/rendererfactory.go

29 lines
691 B
Go
Raw Normal View History

package allg5ui
import (
"opslag.de/schobers/allg5"
"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) {
renderer, err := NewRenderer(width, height, allg5.NewDisplayOptions{
Resizable: opts.Resizable,
Vsync: opts.VSync,
})
if err != nil {
return nil, err
}
renderer.SetWindowTitle(title)
return renderer, nil
}