Description
Much of the API relies on PixelFormat
, which is a type unrelated to SurfacePixelFormat
, except that they both encapsulate data of type Raw.PixelFormat
. This suggests to me that maybe we need to rework things so that something close to Raw.PixelFormat
is exposed in much of the API, maybe my reworking PixelFormat
to be something like
data PixelFormat = current definitions ... | RawPixFmt (Raw.PixelFormat)
.
Then it would be easy to have a function that converts SurfacePixelFormat
into RawPixelFormat
. Alternatively, and maybe more simply, just add SurfacePixelFormat
as a data constructor to the existing PixelFormat
.
My suggestions may not be great as I'm new with Haskell. But to demonstrate the problem I'm having, I can't use createRGBSurface
on the value retrieved from surfaceFormat . getWindowSurface
, which, from what I've read, is quite a useful thing to do for performance reasons (keeping ones surfaces in the same pixel format as the surface eventually being rendered). Here is my example code, which may have other issues, but demonstrates the idea:
createScreenSurface :: Integral a => SDL.V2 a -> HicoProgram state SDL.Surface
createScreenSurface size = do
window <- _window <$> getSDLGameState
screen <- SDL.getWindowSurface window
sPixFmt <- SDL.surfaceFormat screen
SDL.createRGBSurface sizeCInt sPixFmt
where sizeCInt = fmap fromIntegral size