From f6e2f3a8d80f9adf8f9c2931e635a3788ad071eb Mon Sep 17 00:00:00 2001 From: Anten Skrabec Date: Sun, 15 Aug 2021 23:31:06 -0600 Subject: [PATCH] add check for valid msaa values in NewWindow() --- pixelgl/window.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pixelgl/window.go b/pixelgl/window.go index 121921b..d199f49 100644 --- a/pixelgl/window.go +++ b/pixelgl/window.go @@ -1,6 +1,7 @@ package pixelgl import ( + "fmt" "image" "image/color" "runtime" @@ -123,6 +124,17 @@ func NewWindow(cfg WindowConfig) (*Window, error) { w := &Window{bounds: cfg.Bounds, cursorVisible: true} + flag := false + for _, v := range []int{0, 2, 4, 8, 16} { + if cfg.SamplesMSAA == v { + flag = true + break + } + } + if !flag { + return nil, fmt.Errorf("invalid value '%v' for msaaSamples", cfg.SamplesMSAA) + } + err := mainthread.CallErr(func() error { var err error