diff --git a/sdl2.cabal b/sdl2.cabal index ddc6ca9..9e9f766 100644 --- a/sdl2.cabal +++ b/sdl2.cabal @@ -45,16 +45,23 @@ source-repository head flag examples description: Build examples (except opengl-example) default: False + manual: True flag opengl-example description: Build opengl-example default: False + manual: True flag no-linear description: Do not depend on 'linear' library default: False manual: True +flag recent-ish + description: Use features from a more recent libsdl2 release. + default: True + manual: False + library -- ghc-options: -Wall @@ -120,8 +127,14 @@ library extra-libraries: SDL2 - pkgconfig-depends: - sdl2 >= 2.0.6 + if flag(recent-ish) + cpp-options: + -D RECENT_ISH + pkgconfig-depends: + sdl2 >= 2.0.10 + else + pkgconfig-depends: + sdl2 >= 2.0.6 build-depends: base >= 4.7 && < 5, diff --git a/src/SDL/Raw/Video.hs b/src/SDL/Raw/Video.hs index 396e2c9..9782f4a 100644 --- a/src/SDL/Raw/Video.hs +++ b/src/SDL/Raw/Video.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + module SDL.Raw.Video ( -- * Display and Window Management createWindow, @@ -106,7 +108,9 @@ module SDL.Raw.Video ( renderClear, renderCopy, renderCopyEx, +#ifdef RECENT_ISH renderCopyExF, +#endif renderDrawLine, renderDrawLines, renderDrawPoint, @@ -324,7 +328,9 @@ foreign import ccall "SDL.h SDL_QueryTexture" queryTextureFFI :: Texture -> Ptr foreign import ccall "SDL.h SDL_RenderClear" renderClearFFI :: Renderer -> IO CInt foreign import ccall "SDL.h SDL_RenderCopy" renderCopyFFI :: Renderer -> Texture -> Ptr Rect -> Ptr Rect -> IO CInt foreign import ccall "SDL.h SDL_RenderCopyEx" renderCopyExFFI :: Renderer -> Texture -> Ptr Rect -> Ptr Rect -> CDouble -> Ptr Point -> RendererFlip -> IO CInt +#ifdef RECENT_ISH foreign import ccall "SDL.h SDL_RenderCopyExF" renderCopyExFFFI :: Renderer -> Texture -> Ptr Rect -> Ptr FRect -> CDouble -> Ptr FPoint -> RendererFlip -> IO CInt +#endif foreign import ccall "SDL.h SDL_RenderDrawLine" renderDrawLineFFI :: Renderer -> CInt -> CInt -> CInt -> CInt -> IO CInt foreign import ccall "SDL.h SDL_RenderDrawLines" renderDrawLinesFFI :: Renderer -> Ptr Point -> CInt -> IO CInt foreign import ccall "SDL.h SDL_RenderDrawPoint" renderDrawPointFFI :: Renderer -> CInt -> CInt -> IO CInt @@ -835,9 +841,11 @@ renderCopyEx :: MonadIO m => Renderer -> Texture -> Ptr Rect -> Ptr Rect -> CDou renderCopyEx v1 v2 v3 v4 v5 v6 v7 = liftIO $ renderCopyExFFI v1 v2 v3 v4 v5 v6 v7 {-# INLINE renderCopyEx #-} +#ifdef RECENT_ISH renderCopyExF :: MonadIO m => Renderer -> Texture -> Ptr Rect -> Ptr FRect -> CDouble -> Ptr FPoint -> RendererFlip -> m CInt renderCopyExF v1 v2 v3 v4 v5 v6 v7 = liftIO $ renderCopyExFFFI v1 v2 v3 v4 v5 v6 v7 {-# INLINE renderCopyExF #-} +#endif renderDrawLine :: MonadIO m => Renderer -> CInt -> CInt -> CInt -> CInt -> m CInt renderDrawLine v1 v2 v3 v4 v5 = liftIO $ renderDrawLineFFI v1 v2 v3 v4 v5 diff --git a/src/SDL/Video/Renderer.hs b/src/SDL/Video/Renderer.hs index 78e1c24..1ca7739 100644 --- a/src/SDL/Video/Renderer.hs +++ b/src/SDL/Video/Renderer.hs @@ -23,7 +23,9 @@ module SDL.Video.Renderer , clear , copy , copyEx +#ifdef RECENT_ISH , copyExF +#endif , drawLine , drawLines , drawPoint @@ -765,6 +767,7 @@ copyEx (Renderer r) (Texture t) srcRect dstRect theta center flips = V2 x y -> (if x then Raw.SDL_FLIP_HORIZONTAL else 0) .|. (if y then Raw.SDL_FLIP_VERTICAL else 0)) +#ifdef RECENT_ISH -- | Copy a portion of the texture to the current rendering target, optionally rotating it by angle around the given center and also flipping it top-bottom and/or left-right. copyExF :: MonadIO m => Renderer -- ^ The rendering context @@ -785,6 +788,7 @@ copyExF (Renderer r) (Texture t) srcRect dstRect theta center flips = (case flips of V2 x y -> (if x then Raw.SDL_FLIP_HORIZONTAL else 0) .|. (if y then Raw.SDL_FLIP_VERTICAL else 0)) +#endif -- | Draw a line on the current rendering target. --