From 678c830e33948f71565f83ae45d5d441ac39dc47 Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 8 Nov 2016 04:31:51 +0100 Subject: [PATCH] example now working with the right colours This was an issue with the default surface created by sdl, which had the wrong color format. For the future it is advised to use the RGBA CFu8 format from babl, or things may break again. --- examples/example00.hs | 2 +- src/Affection.hs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/example00.hs b/examples/example00.hs index f9438f6..993b805 100644 --- a/examples/example00.hs +++ b/examples/example00.hs @@ -51,7 +51,7 @@ load _ = do traceM "over" text <- G.gegl_node_new_child root $ G.textOperation [ G.Property "string" $ G.PropertyString "Hello world!" - -- , G.Property "color" $ G.PropertyColor $ G.RGBA 0 0 1 0.1 + , G.Property "color" $ G.PropertyColor $ G.RGBA 0 0 1 0.1 , G.Property "size" $ G.PropertyDouble 40 ] traceM "text" diff --git a/src/Affection.hs b/src/Affection.hs index 3fe9a85..f40438f 100644 --- a/src/Affection.hs +++ b/src/Affection.hs @@ -11,6 +11,7 @@ module Affection ) where import qualified SDL +import qualified SDL.Raw as Raw import qualified GEGL as G import qualified Data.Text as T @@ -39,7 +40,8 @@ withAffection conf@AffectionConfig{..} = do G.gegl_init execTime <- newMVar =<< getTime Monotonic window <- SDL.createWindow windowTitle windowConfig - surface <- SDL.getWindowSurface window + oldSurf@(SDL.Surface ptr vect) <- SDL.getWindowSurface window + surface <- (\x -> return $ SDL.Surface x Nothing) =<< Raw.convertSurfaceFormat ptr Raw.SDL_PIXELFORMAT_ABGR8888 0 initContainer <- return . (\x -> AffectionData { quitEvent = False , userState = x @@ -52,6 +54,7 @@ withAffection conf@AffectionConfig{..} = do return $ not $ Types.quitEvent current ) (do + liftIO $ SDL.surfaceBlit surface Nothing oldSurf Nothing now <- liftIO $ getTime Monotonic lastTime <- liftIO $ fromMaybe now <$> tryReadMVar execTime drawLoop