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