Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Check sdl returned bools. Avoid warnings

  • Loading branch information...
commit 665b7440deb52b48f55f304e5e0f0be4d594ea3e 1 parent 1ba0b2a
@Peaker authored
Showing with 23 additions and 10 deletions.
  1. +23 −10 src/Graphics/UI/HaskGame.hs
View
33 src/Graphics/UI/HaskGame.hs
@@ -35,23 +35,36 @@ createRGBSurface (Vector2 w h) = do
w h 32 0xFF 0xFF00 0xFF0000 0x00000000
SDL.displayFormatAlpha surface
+sdlCall :: String -> IO Bool -> IO ()
+sdlCall name act = do
+ res <- act
+ if not res
+ then
+ fail ("SDL " ++ name ++ " failed")
+ else
+ return ()
+
+sdlBlitSurface :: SDL.Surface
+ -> Maybe Rect
+ -> SDL.Surface
+ -> Maybe Rect
+ -> IO ()
+sdlBlitSurface src srcRect dest destRect =
+ sdlCall "blitSurface" $ SDL.blitSurface src srcRect dest destRect
+
blit :: Surface -> Vector2 Int -> Surface -> IO ()
-blit dest pos src = do
- SDL.blitSurface src Nothing dest (Just . Rect.makeFromPos $ pos)
- return ()
+blit dest pos src = sdlBlitSurface src Nothing dest (Just . Rect.makeFromPos $ pos)
blitPart :: Surface -> Vector2 Int -> Surface -> Rect -> IO ()
-blitPart dest destPos src srcRect = do
- SDL.blitSurface
- src (Just . Rect.trunc $ srcRect)
- dest (Just . Rect.makeFromPos $ destPos)
- return ()
+blitPart dest destPos src srcRect =
+ sdlBlitSurface
+ src (Just . Rect.trunc $ srcRect)
+ dest (Just . Rect.makeFromPos $ destPos)
sdlFillRect :: Surface -> Maybe Rect -> Color -> IO ()
sdlFillRect surface mRect color = do
fillerPixel <- pixel surface color
- SDL.fillRect surface mRect fillerPixel
- return ()
+ sdlCall "fillRect" $ SDL.fillRect surface mRect fillerPixel
fillSurface :: Surface -> Color -> IO ()
fillSurface surface color = sdlFillRect surface Nothing color
Please sign in to comment.
Something went wrong with that request. Please try again.