thanks @dodo. Now it works more smoothly

This commit is contained in:
nek0 2017-02-22 18:02:34 +01:00
parent 1846ae051a
commit a028bb4204

View file

@ -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