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,6 +33,7 @@ var _ ui.Renderer = &Renderer{}
var _ ui.Texture = &Renderer{} var _ ui.Texture = &Renderer{}
type NewRendererOptions struct { type NewRendererOptions struct {
Borderless bool
Location sdl.Point Location sdl.Point
Resizable bool Resizable bool
VSync bool VSync bool
@ -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,6 +18,7 @@ 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{
Borderless: opts.Borderless,
Location: location, Location: location,
Resizable: opts.Resizable, Resizable: opts.Resizable,
VSync: opts.VSync, VSync: opts.VSync,

View File

@ -41,6 +41,7 @@ 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
Borderless bool
Resizable bool Resizable bool
VSync bool VSync bool
} }