Skip to content

Commit

Permalink
Wrap 'SDL_MapRGB'
Browse files Browse the repository at this point in the history
  • Loading branch information
ocharles committed Sep 22, 2013
1 parent b606dc7 commit 5d8c8a3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Graphics/UI/SDL/Video.hsc
Expand Up @@ -710,9 +710,6 @@ foreign import ccall unsafe "SDL_GetWindowPixelFormat"
foreign import ccall unsafe "SDL_AllocFormat"
sdlAllocFormat :: Word32 -> IO (Ptr PixelFormatStruct)

foreign import ccall unsafe "SDL_MapRGBA"
sdlMapRGBA :: Ptr PixelFormatStruct -> Word8 -> Word8 -> Word8 -> Word8 -> IO Word32

getWindowPixelFormat :: Window -> IO Word32
getWindowPixelFormat w = withForeignPtr w sdlGetWindowPixelFormat

Expand All @@ -722,6 +719,15 @@ allocFormat pf = sdlAllocFormat pf >>= newForeignPtr sdlFreeFormat_finalizer
foreign import ccall unsafe "&SDL_FreeFormat"
sdlFreeFormat_finalizer :: FunPtr (Ptr PixelFormatStruct -> IO ())

foreign import ccall unsafe "SDL_MapRGB"
sdlMapRGB :: Ptr PixelFormatStruct -> Word8 -> Word8 -> Word8 -> IO Word32

mapRGB :: PixelFormat -> Word8 -> Word8 -> Word8 -> IO Word32
mapRGB p r g b = withForeignPtr p $ \cp -> sdlMapRGB cp r g b

foreign import ccall unsafe "SDL_MapRGBA"
sdlMapRGBA :: Ptr PixelFormatStruct -> Word8 -> Word8 -> Word8 -> Word8 -> IO Word32

mapRGBA :: PixelFormat -> Word8 -> Word8 -> Word8 -> Word8 -> IO Word32
mapRGBA p r g b a = withForeignPtr p $ \cp -> sdlMapRGBA cp r g b a

Expand Down

0 comments on commit 5d8c8a3

Please sign in to comment.