From 208ea1dd24166ff65dc5038265fb9c86b157fdfc Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 30 Apr 2019 00:22:29 +0200 Subject: [PATCH] handle multiwin branch --- src/Load.hs | 2 +- src/Main.hs | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Load.hs b/src/Load.hs index 67e9ac4..3044ce7 100644 --- a/src/Load.hs +++ b/src/Load.hs @@ -40,7 +40,7 @@ loadLoad = do (nano ud) future progress - SDL.glMakeCurrent (fromJust $ window ud) (glContext ad) + SDL.glMakeCurrent (fromJust $ window ud) (snd $ head $ glContext ad) putAffection ud { stateMVar = future , stateProgress = progress diff --git a/src/Main.hs b/src/Main.hs index 5fb265b..1763d0d 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -32,13 +32,17 @@ main = do let config = AffectionConfig { initComponents = All , windowTitle = "Tracer" - , windowConfig = SDL.defaultWindow - { SDL.windowInitialSize = V2 1280 720 - , SDL.windowResizable = True - , SDL.windowOpenGL = Just SDL.defaultOpenGL - { SDL.glProfile = SDL.Core SDL.Normal 3 3 + , windowConfigs = [ + ( 0 + , SDL.defaultWindow + { SDL.windowInitialSize = V2 1280 720 + , SDL.windowResizable = True + , SDL.windowOpenGL = Just SDL.defaultOpenGL + { SDL.glProfile = SDL.Core SDL.Normal 3 3 + } } - } + ) + ] , canvasSize = Nothing , preLoop = pre >> smLoad Load , eventLoop = handle @@ -54,8 +58,8 @@ pre :: Affection UserData () pre = do ad <- A.get ud <- getAffection - threadCtx <- SDL.glCreateContext (drawWindow ad) - SDL.glMakeCurrent (drawWindow ad) (glContext ad) + threadCtx <- SDL.glCreateContext (snd $ head $ drawWindows ad) + SDL.glMakeCurrent (snd $ head $ drawWindows ad) (snd $ head $ glContext ad) let Subsystems w m k j t = subsystems ud _ <- partSubscribe w (fitViewport (1280/720)) _ <- partSubscribe w exitOnWindowClose @@ -65,7 +69,7 @@ pre = do (ws, _) <- yieldSystemT (0, defStorage) (return ()) putAffection ud { threadContext = Just threadCtx - , window = Just (drawWindow ad) + , window = Just (snd $ head $ drawWindows ad) , worldState = ws , joyUUID = u } @@ -83,7 +87,7 @@ quitGame (MsgKeyboardEvent _ _ SDL.Pressed False sym) mapM_ (partUnSubscribe k) (uuid ud) mapM_ (partUnSubscribe j) (uuid ud) mapM_ (partUnSubscribe t) (uuid ud) - SDL.glMakeCurrent (drawWindow ad) (glContext ad) + SDL.glMakeCurrent (snd $ head $ drawWindows ad) (snd $ head $ glContext ad) (ws, _) <- yieldSystemT (0, defStorage) (return ()) putAffection ud { worldState = ws