Skip to content

Commit 7483007

Browse files
committed
Allow specifying wanted multisample samples for OpenGL contexts
1 parent 789383f commit 7483007

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/SDL/Video.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ createWindow title config = liftIO $ do
124124
, if isJust $ windowOpenGL config then Raw.SDL_WINDOW_OPENGL else 0
125125
, if windowResizable config then Raw.SDL_WINDOW_RESIZABLE else 0
126126
]
127-
setGLAttributes (OpenGLConfig (V4 r g b a) d s p) = do
127+
setGLAttributes (OpenGLConfig (V4 r g b a) d s ms p) = do
128128
let (msk, v0, v1, flg) = case p of
129129
Core Debug v0' v1' -> (Raw.SDL_GL_CONTEXT_PROFILE_CORE, v0', v1', Raw.SDL_GL_CONTEXT_DEBUG_FLAG)
130130
Core Normal v0' v1' -> (Raw.SDL_GL_CONTEXT_PROFILE_CORE, v0', v1', 0)
@@ -139,6 +139,8 @@ createWindow title config = liftIO $ do
139139
, (Raw.SDL_GL_ALPHA_SIZE, a)
140140
, (Raw.SDL_GL_DEPTH_SIZE, d)
141141
, (Raw.SDL_GL_STENCIL_SIZE, s)
142+
, (Raw.SDL_GL_MULTISAMPLEBUFFERS, if ms > 1 then 1 else 0)
143+
, (Raw.SDL_GL_MULTISAMPLESAMPLES, if ms > 1 then ms else 0)
142144
, (Raw.SDL_GL_CONTEXT_PROFILE_MASK, msk)
143145
, (Raw.SDL_GL_CONTEXT_MAJOR_VERSION, v0)
144146
, (Raw.SDL_GL_CONTEXT_MINOR_VERSION, v1)

src/SDL/Video/OpenGL.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import Control.Applicative
5353
-- { 'glColorPrecision' = V4 8 8 8 0
5454
-- , 'glDepthPrecision' = 24
5555
-- , 'glStencilPrecision' = 8
56+
-- , 'glMultisampleSamples' = 1
5657
-- , 'glProfile' = 'Compatibility' 'Normal' 2 1
5758
-- }
5859
-- @
@@ -61,15 +62,17 @@ defaultOpenGL = OpenGLConfig
6162
{ glColorPrecision = V4 8 8 8 0
6263
, glDepthPrecision = 24
6364
, glStencilPrecision = 8
65+
, glMultisampleSamples = 1
6466
, glProfile = Compatibility Normal 2 1
6567
}
6668

6769
-- | Configuration used when creating an OpenGL rendering context.
6870
data OpenGLConfig = OpenGLConfig
69-
{ glColorPrecision :: V4 CInt -- ^ Defaults to 'V4' @8 8 8 0@.
70-
, glDepthPrecision :: CInt -- ^ Defaults to @24@.
71-
, glStencilPrecision :: CInt -- ^ Defaults to @8@.
72-
, glProfile :: Profile -- ^ Defaults to 'Compatibility' 'Normal' @2 1@.
71+
{ glColorPrecision :: V4 CInt -- ^ Defaults to 'V4' @8 8 8 0@.
72+
, glDepthPrecision :: CInt -- ^ Defaults to @24@.
73+
, glStencilPrecision :: CInt -- ^ Defaults to @8@.
74+
, glMultisampleSamples :: CInt -- ^ Defaults to @1@.
75+
, glProfile :: Profile -- ^ Defaults to 'Compatibility' 'Normal' @2 1@.
7376
} deriving (Eq, Generic, Ord, Read, Show, Typeable)
7477

7578
-- | The profile a driver should use when creating an OpenGL context.

0 commit comments

Comments
 (0)