Added support for borderless windows.

This commit is contained in:
Sander Schobers 2022-05-01 12:40:09 +02:00
parent eb46741165
commit ddf9476920
4 changed files with 16 additions and 9 deletions

View File

@ -13,6 +13,7 @@ type rendererFactory struct{}
func (f rendererFactory) New(title string, width, height int, opts ui.NewRendererOptions) (ui.Renderer, error) { func (f rendererFactory) New(title string, width, height int, opts ui.NewRendererOptions) (ui.Renderer, error) {
renderer, err := NewRenderer(width, height, allg5.NewDisplayOptions{ renderer, err := NewRenderer(width, height, allg5.NewDisplayOptions{
Frameless: opts.Borderless,
Resizable: opts.Resizable, Resizable: opts.Resizable,
Vsync: opts.VSync, Vsync: opts.VSync,
}) })

View File

@ -33,9 +33,10 @@ var _ ui.Renderer = &Renderer{}
var _ ui.Texture = &Renderer{} var _ ui.Texture = &Renderer{}
type NewRendererOptions struct { type NewRendererOptions struct {
Location sdl.Point Borderless bool
Resizable bool Location sdl.Point
VSync bool Resizable bool
VSync bool
} }
func NewRenderer(title string, width, height int32, opts NewRendererOptions) (*Renderer, error) { func NewRenderer(title string, width, height int32, opts NewRendererOptions) (*Renderer, error) {
@ -57,6 +58,9 @@ func NewRenderer(title string, width, height int32, opts NewRendererOptions) (*R
} }
sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, "1") sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, "1")
windowFlags := uint32(sdl.WINDOW_SHOWN) windowFlags := uint32(sdl.WINDOW_SHOWN)
if opts.Borderless {
windowFlags |= sdl.WINDOW_BORDERLESS
}
if opts.Resizable { if opts.Resizable {
windowFlags |= sdl.WINDOW_RESIZABLE windowFlags |= sdl.WINDOW_RESIZABLE
} }

View File

@ -18,8 +18,9 @@ func (f rendererFactory) New(title string, width, height int, opts ui.NewRendere
location.Y = int32(opts.Location.Y) location.Y = int32(opts.Location.Y)
} }
return NewRenderer(title, int32(width), int32(height), NewRendererOptions{ return NewRenderer(title, int32(width), int32(height), NewRendererOptions{
Location: location, Borderless: opts.Borderless,
Resizable: opts.Resizable, Location: location,
VSync: opts.VSync, Resizable: opts.Resizable,
VSync: opts.VSync,
}) })
} }

View File

@ -40,7 +40,8 @@ func SetRendererFactory(factory RendererFactory) {
// NewRendererOptions provides options when creating a new renderer. // NewRendererOptions provides options when creating a new renderer.
type NewRendererOptions struct { type NewRendererOptions struct {
Location *geom.PointF32 Location *geom.PointF32
Resizable bool Borderless bool
VSync bool Resizable bool
VSync bool
} }