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 _ = (3)
alignment _ = 1
peek ptr = do major <- (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
minor <- (\hsc_ptr -> peekByteOff hsc_ptr 1) ptr
patch <- (\hsc_ptr -> peekByteOff hsc_ptr 2) ptr
return (SDLVersion major minor patch)
compiledFor :: Version
compiledFor = Version [ 1
, 2
, 15
] []
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]) [])