Skip to content

Commit

Permalink
add multisampling
Browse files Browse the repository at this point in the history
  • Loading branch information
cebarks committed Jun 21, 2021
1 parent 98f3e74 commit 80b107c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pixelgl/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/faiface/glhf"
"github.com/faiface/mainthread"
"github.com/faiface/pixel"
"github.com/go-gl/gl/v3.3-core/gl"
"github.com/go-gl/glfw/v3.3/glfw"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -75,6 +76,9 @@ type WindowConfig struct {
// Invisible specifies whether the window will be initially hidden.
// You can make the window visible later using Window.Show().
Invisible bool

//SamplesMSAA specifies the level of MSAA to be used. 0 to disable.
SamplesMSAA int
}

// Window is a window handler. Use this type to manipulate a window (input, drawing, etc.).
Expand All @@ -100,7 +104,7 @@ type Window struct {
typed string
}

pressEvents, tempPressEvents [KeyLast + 1]bool
pressEvents, tempPressEvents [KeyLast + 1]bool
releaseEvents, tempReleaseEvents [KeyLast + 1]bool

prevJoy, currJoy, tempJoy joystickState
Expand All @@ -127,13 +131,16 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)

gl.Enable(gl.MULTISAMPLE)

glfw.WindowHint(glfw.Resizable, bool2int[cfg.Resizable])
glfw.WindowHint(glfw.Decorated, bool2int[!cfg.Undecorated])
glfw.WindowHint(glfw.Floating, bool2int[cfg.AlwaysOnTop])
glfw.WindowHint(glfw.AutoIconify, bool2int[!cfg.NoIconify])
glfw.WindowHint(glfw.TransparentFramebuffer, bool2int[cfg.TransparentFramebuffer])
glfw.WindowHint(glfw.Maximized, bool2int[cfg.Maximized])
glfw.WindowHint(glfw.Visible, bool2int[!cfg.Invisible])
glfw.WindowHint(glfw.Samples, cfg.SamplesMSAA)

if cfg.Position.X != 0 || cfg.Position.Y != 0 {
glfw.WindowHint(glfw.Visible, glfw.False)
Expand Down

0 comments on commit 80b107c

Please sign in to comment.