1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include "SDL.h"
#ifdef main
#undef main
#endif
module Graphics.UI.SDL.Version
( compiledFor
, linkedWith
) where
import Data.Version (Version(Version))
import Foreign (Word8, Ptr, Storable(sizeOf, alignment, peekByteOff, peek))
data SDLVersion
= SDLVersion Word8 Word8 Word8
instance Storable SDLVersion where
sizeOf _ = #{size SDL_version}
alignment _ = 1
peek ptr = do major <- #{peek SDL_version, major} ptr
minor <- #{peek SDL_version, minor} ptr
patch <- #{peek SDL_version, patch} ptr
return (SDLVersion major minor patch)
compiledFor :: Version
compiledFor = Version [ #{const SDL_MAJOR_VERSION}
, #{const SDL_MINOR_VERSION}
, #{const SDL_PATCHLEVEL}
] []
-- const SDL_version * SDL_Linked_Version(void);
foreign import ccall unsafe "SDL_Linked_Version" sdlLinkedVersion :: IO (Ptr SDLVersion)
linkedWith :: IO Version
linkedWith = do versionPtr <- sdlLinkedVersion
SDLVersion major minor patch <- peek versionPtr
return (Version (map fromIntegral [major,minor,patch]) [])
|