From d703a5270cc0b81ae09428d06f73a6d5ab347f57 Mon Sep 17 00:00:00 2001 From: bloeys Date: Sat, 7 Oct 2023 11:28:59 +0400 Subject: [PATCH] x8 MSAA --- engine/engine.go | 13 +++++++++++++ main.go | 2 ++ 2 files changed, 15 insertions(+) diff --git a/engine/engine.go b/engine/engine.go index d55c891..71d1f0a 100755 --- a/engine/engine.go +++ b/engine/engine.go @@ -142,6 +142,9 @@ func initSDL() error { sdl.GLSetAttribute(sdl.GL_DEPTH_SIZE, 24) sdl.GLSetAttribute(sdl.GL_STENCIL_SIZE, 8) + // Allow us to do MSAA + sdl.GLSetAttribute(sdl.GL_MULTISAMPLEBUFFERS, 8) + sdl.GLSetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_CORE) return nil @@ -198,6 +201,7 @@ func initOpenGL() error { gl.FrontFace(gl.CCW) gl.Enable(gl.BLEND) + gl.Enable(gl.MULTISAMPLE) gl.Enable(gl.FRAMEBUFFER_SRGB) gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) @@ -223,3 +227,12 @@ func SetVSync(enabled bool) { sdl.GLSetSwapInterval(0) } } + +func SetMSAA(isEnabled bool) { + + if isEnabled { + gl.Enable(gl.MULTISAMPLE) + } else { + gl.Disable(gl.MULTISAMPLE) + } +} diff --git a/main.go b/main.go index 4c83799..fc8359f 100755 --- a/main.go +++ b/main.go @@ -141,7 +141,9 @@ func main() { } defer window.Destroy() + engine.SetMSAA(true) engine.SetVSync(false) + engine.SetSrgbFramebuffer(true) game := &OurGame{ Win: window,