From 33323700123f2e8a571cb5beeb5c5d91fcdffd5d Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 15 Oct 2020 18:49:04 +0200 Subject: [PATCH] add sync and GL infos --- src/Affection.hs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Affection.hs b/src/Affection.hs index 2b1f908..48ea606 100644 --- a/src/Affection.hs +++ b/src/Affection.hs @@ -17,11 +17,21 @@ import qualified SDL import qualified SDL.Raw.Video as SDL (glSetAttribute) import qualified SDL.Raw.Enum as SDL +import qualified Graphics.Rendering.OpenGL as GL (clear, flush, ClearBuffer(..)) +import qualified Graphics.GL as GLRaw + +import Foreign.Marshal.Array + +import qualified Data.ByteString as B +import qualified Data.ByteString.Char8 as B8 + import System.Clock import Control.Monad.Loops import Control.Monad.State.Strict +-- internal imports + import Affection.Types as A import Affection.Class as A import Affection.StateMachine as A @@ -31,9 +41,6 @@ import Affection.Subsystems as A import Affection.Logging as A -import qualified Graphics.Rendering.OpenGL as GL (clear, flush, ClearBuffer(..)) - - -- | Main function which bootstraps everything else. withAffection :: forall us. (Affectionate us) @@ -50,6 +57,8 @@ withAffection AffectionConfig{..} = do SDL.initialize is -- give SDL render quality SDL.HintRenderScaleQuality SDL.$= SDL.ScaleLinear + -- sync updates with monitor + SDL.swapInterval $= SDL.SynchronizedUpdates -- just checking… do renderQuality <- SDL.get SDL.HintRenderScaleQuality @@ -70,6 +79,9 @@ withAffection AffectionConfig{..} = do mapM_ (\w -> flip SDL.setWindowMode ((\(_,_,z) -> z) w) ((\(_,y,_) -> y) w)) windows -- SDL.swapInterval $= SDL.SynchronizedUpdates -- <- causes Problems with windows liftIO $ logIO Debug "Getting Time" + -- print current used GL Version + version <- peerArray0 (0 :: Word8) =<< GLRaw.glGetString GLRaw.GL_VERSION + print (B.pack version) -- get current time execTime <- getTime Monotonic liftIO $ logIO Debug "Loading initial data container"