Skip to content

Commit d469768

Browse files
authored
Put copyExF under a package flag (#250)
1 parent 5284288 commit d469768

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

sdl2.cabal

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,23 @@ source-repository head
4545
flag examples
4646
description: Build examples (except opengl-example)
4747
default: False
48+
manual: True
4849

4950
flag opengl-example
5051
description: Build opengl-example
5152
default: False
53+
manual: True
5254

5355
flag no-linear
5456
description: Do not depend on 'linear' library
5557
default: False
5658
manual: True
5759

60+
flag recent-ish
61+
description: Use features from a more recent libsdl2 release.
62+
default: True
63+
manual: False
64+
5865
library
5966
-- ghc-options: -Wall
6067

@@ -120,8 +127,14 @@ library
120127
extra-libraries:
121128
SDL2
122129

123-
pkgconfig-depends:
124-
sdl2 >= 2.0.6
130+
if flag(recent-ish)
131+
cpp-options:
132+
-D RECENT_ISH
133+
pkgconfig-depends:
134+
sdl2 >= 2.0.10
135+
else
136+
pkgconfig-depends:
137+
sdl2 >= 2.0.6
125138

126139
build-depends:
127140
base >= 4.7 && < 5,

src/SDL/Raw/Video.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
13
module SDL.Raw.Video (
24
-- * Display and Window Management
35
createWindow,
@@ -106,7 +108,9 @@ module SDL.Raw.Video (
106108
renderClear,
107109
renderCopy,
108110
renderCopyEx,
111+
#ifdef RECENT_ISH
109112
renderCopyExF,
113+
#endif
110114
renderDrawLine,
111115
renderDrawLines,
112116
renderDrawPoint,
@@ -324,7 +328,9 @@ foreign import ccall "SDL.h SDL_QueryTexture" queryTextureFFI :: Texture -> Ptr
324328
foreign import ccall "SDL.h SDL_RenderClear" renderClearFFI :: Renderer -> IO CInt
325329
foreign import ccall "SDL.h SDL_RenderCopy" renderCopyFFI :: Renderer -> Texture -> Ptr Rect -> Ptr Rect -> IO CInt
326330
foreign import ccall "SDL.h SDL_RenderCopyEx" renderCopyExFFI :: Renderer -> Texture -> Ptr Rect -> Ptr Rect -> CDouble -> Ptr Point -> RendererFlip -> IO CInt
331+
#ifdef RECENT_ISH
327332
foreign import ccall "SDL.h SDL_RenderCopyExF" renderCopyExFFFI :: Renderer -> Texture -> Ptr Rect -> Ptr FRect -> CDouble -> Ptr FPoint -> RendererFlip -> IO CInt
333+
#endif
328334
foreign import ccall "SDL.h SDL_RenderDrawLine" renderDrawLineFFI :: Renderer -> CInt -> CInt -> CInt -> CInt -> IO CInt
329335
foreign import ccall "SDL.h SDL_RenderDrawLines" renderDrawLinesFFI :: Renderer -> Ptr Point -> CInt -> IO CInt
330336
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
835841
renderCopyEx v1 v2 v3 v4 v5 v6 v7 = liftIO $ renderCopyExFFI v1 v2 v3 v4 v5 v6 v7
836842
{-# INLINE renderCopyEx #-}
837843

844+
#ifdef RECENT_ISH
838845
renderCopyExF :: MonadIO m => Renderer -> Texture -> Ptr Rect -> Ptr FRect -> CDouble -> Ptr FPoint -> RendererFlip -> m CInt
839846
renderCopyExF v1 v2 v3 v4 v5 v6 v7 = liftIO $ renderCopyExFFFI v1 v2 v3 v4 v5 v6 v7
840847
{-# INLINE renderCopyExF #-}
848+
#endif
841849

842850
renderDrawLine :: MonadIO m => Renderer -> CInt -> CInt -> CInt -> CInt -> m CInt
843851
renderDrawLine v1 v2 v3 v4 v5 = liftIO $ renderDrawLineFFI v1 v2 v3 v4 v5

src/SDL/Video/Renderer.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ module SDL.Video.Renderer
2323
, clear
2424
, copy
2525
, copyEx
26+
#ifdef RECENT_ISH
2627
, copyExF
28+
#endif
2729
, drawLine
2830
, drawLines
2931
, drawPoint
@@ -765,6 +767,7 @@ copyEx (Renderer r) (Texture t) srcRect dstRect theta center flips =
765767
V2 x y -> (if x then Raw.SDL_FLIP_HORIZONTAL else 0) .|.
766768
(if y then Raw.SDL_FLIP_VERTICAL else 0))
767769

770+
#ifdef RECENT_ISH
768771
-- | 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.
769772
copyExF :: MonadIO m
770773
=> Renderer -- ^ The rendering context
@@ -785,6 +788,7 @@ copyExF (Renderer r) (Texture t) srcRect dstRect theta center flips =
785788
(case flips of
786789
V2 x y -> (if x then Raw.SDL_FLIP_HORIZONTAL else 0) .|.
787790
(if y then Raw.SDL_FLIP_VERTICAL else 0))
791+
#endif
788792

789793
-- | Draw a line on the current rendering target.
790794
--

0 commit comments

Comments
 (0)