@@ -306,31 +306,31 @@ queryTexture (Texture tex) = liftIO $
306306-- | Allocate a new RGB surface.
307307--
308308-- See @<https://wiki.libsdl.org/SDL_CreateRGBSurface SDL_CreateRGBSurface>@ for C documentation.
309- createRGBSurface :: (Functor m ,MonadIO m )
309+ createRGBSurface :: (Functor m , MonadIO m )
310310 => V2 CInt -- ^ The size of the surface
311- -> CInt -- ^ The bit-depth of the surface
312- -> V4 Word32 -- ^ The red, green, blue and alpha mask for the pixels
311+ -> PixelFormat -- ^ The bit depth, red, green, blue and alpha mask for the pixels
313312 -> m Surface
314- createRGBSurface (V2 w h) d ( V4 r g b a) =
313+ createRGBSurface (V2 w h) pf =
315314 fmap unmanagedSurface $
316- throwIfNull " SDL.Video.createRGBSurface" " SDL_CreateRGBSurface" $
317- Raw. createRGBSurface 0 w h d r g b a
315+ throwIfNull " SDL.Video.createRGBSurface" " SDL_CreateRGBSurface" $ do
316+ (bpp, V4 r g b a) <- pixelFormatToMasks pf
317+ Raw. createRGBSurface 0 w h bpp r g b a
318318
319319-- | Allocate a new RGB surface with existing pixel data.
320320--
321321-- See @<https://wiki.libsdl.org/SDL_CreateRGBSurfaceFrom SDL_CreateRGBSurfaceFrom>@ for C documentation.
322- createRGBSurfaceFrom :: (Functor m ,MonadIO m )
322+ createRGBSurfaceFrom :: (Functor m , MonadIO m )
323323 => MSV. IOVector Word8 -- ^ The existing pixel data
324324 -> V2 CInt -- ^ The size of the surface
325- -> CInt -- ^ The bit-depth of the surface
326325 -> CInt -- ^ The pitch - the length of a row of pixels in bytes
327- -> V4 Word32 -- ^ The red, green blue and alpha mask for the pixels
326+ -> PixelFormat -- ^ The bit depth, red, green, blue and alpha mask for the pixels
328327 -> m Surface
329- createRGBSurfaceFrom pixels (V2 w h) d p ( V4 r g b a) = liftIO $
328+ createRGBSurfaceFrom pixels (V2 w h) p pf = liftIO $
330329 fmap (managedSurface pixels) $
331- throwIfNull " SDL.Video.createRGBSurfaceFrom" " SDL_CreateRGBSurfaceFrom" $
332- MSV. unsafeWith pixels $ \ pixelPtr ->
333- Raw. createRGBSurfaceFrom (castPtr pixelPtr) w h d p r g b a
330+ throwIfNull " SDL.Video.createRGBSurfaceFrom" " SDL_CreateRGBSurfaceFrom" $ do
331+ (bpp, V4 r g b a) <- pixelFormatToMasks pf
332+ MSV. unsafeWith pixels $ \ pixelPtr ->
333+ Raw. createRGBSurfaceFrom (castPtr pixelPtr) w h bpp p r g b a
334334
335335-- | Perform a fast fill of a rectangle with a specific color.
336336--
0 commit comments