From a028bb420450a6ef06d3943124f17186dab9f135 Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 22 Feb 2017 18:02:34 +0100 Subject: [PATCH] thanks @dodo. Now it works more smoothly --- src/Affection.hs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Affection.hs b/src/Affection.hs index 95407df..00a2837 100644 --- a/src/Affection.hs +++ b/src/Affection.hs @@ -131,6 +131,7 @@ getSurfaces window = do let surface = (flip SDL.Surface Nothing) rawSurfacePtr return (oldSurf, surface) +-- Prehandle SDL events in case any window events occur preHandleEvents :: [SDL.Event] -> Affection us [SDL.Event] preHandleEvents evs = mapM handle evs @@ -145,20 +146,9 @@ preHandleEvents evs = return e putNewSurface = do ad <- get - (oldSurf, surface) <- liftIO $ getSurfaces $ drawWindow ad - pixels <- SDL.surfacePixels $ surface - SDL.V2 (CInt rw) (CInt rh) <- liftIO $ SDL.surfaceDimensions surface - let (SDL.Surface ptr _) = surface - rawSurfacePtr <- Raw.convertSurfaceFormat ptr (SDL.toNumber SDL.ABGR8888) 0 - pixelFormat <- liftIO $ peek . Raw.surfaceFormat =<< peek rawSurfacePtr - let (w, h) = (fromIntegral rw, fromIntegral rh) - stride = fromIntegral (Raw.pixelFormatBytesPerPixel pixelFormat) * w + (oldSurf, _) <- liftIO $ getSurfaces $ drawWindow ad put ad { windowSurface = oldSurf - , drawSurface = surface - , drawPixels = pixels - , drawDimensions = (w, h) - , drawStride = stride } -- | Return the userstate to the user