{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
module SDL.Video.Renderer
( Renderer
, RendererConfig(..)
, defaultRenderer
, RendererType(..)
, clear
, copy
, copyEx
#ifdef RECENT_ISH
, copyExF
#endif
, drawLine
, drawLines
, drawPoint
, drawPoints
, drawRect
, drawRects
, fillRect
, fillRects
, present
, rendererDrawBlendMode
, rendererDrawColor
, rendererRenderTarget
, rendererClipRect
, rendererLogicalSize
, rendererScale
, rendererViewport
, renderTargetSupported
, Surface(..)
, updateWindowSurface
, surfaceBlit
, surfaceBlitScaled
, surfaceFillRect
, surfaceFillRects
, convertSurface
, createRGBSurface
, createRGBSurfaceFrom
, freeSurface
, getWindowSurface
, loadBMP
, surfaceColorKey
, surfaceBlendMode
, surfaceDimensions
, surfaceFormat
, surfacePixels
, lockSurface
, unlockSurface
, Palette
, paletteNColors
, paletteColors
, paletteColor
, PixelFormat(..)
, SurfacePixelFormat(..)
, formatPalette
, setPaletteColors
, pixelFormatToMasks
, masksToPixelFormat
, Texture
, createTexture
, TextureAccess(..)
, createTextureFromSurface
, updateTexture
, destroyTexture
, glBindTexture
, glUnbindTexture
, textureAlphaMod
, textureBlendMode
, BlendMode(..)
, textureColorMod
, lockTexture
, unlockTexture
, queryTexture
, TextureInfo(..)
, Rectangle(..)
, getRendererInfo
, RendererInfo(..)
, getRenderDriverInfo
) where
import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.Bits
import Data.Data (Data)
import Data.Foldable
import Data.StateVar
import Data.Text (Text)
import Data.Typeable
import Data.Word
import Foreign.C.String
import Foreign.C.Types
import Foreign.ForeignPtr
import Foreign.Marshal.Alloc
import Foreign.Marshal.Utils
import Foreign.Ptr
import Foreign.Storable
import GHC.Generics (Generic)
import Prelude hiding (foldr)
import SDL.Vect
import SDL.Internal.Exception
import SDL.Internal.Numbered
import SDL.Internal.Types
import qualified Data.ByteString as BS
import qualified Data.ByteString.Internal as BSI
import qualified Data.Text.Encoding as Text
import qualified Data.Vector.Storable as SV
import qualified Data.Vector.Storable.Mutable as MSV
import qualified SDL.Raw as Raw
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
import Data.Traversable
#endif
surfaceBlit :: MonadIO m
=> Surface
-> Maybe (Rectangle CInt)
-> Surface
-> Maybe (Point V2 CInt)
-> m (Maybe (Rectangle CInt))
surfaceBlit :: Surface
-> Maybe (Rectangle CInt)
-> Surface
-> Maybe (Point V2 CInt)
-> m (Maybe (Rectangle CInt))
surfaceBlit (Surface Ptr Surface
src Maybe (IOVector Word8)
_) Maybe (Rectangle CInt)
srcRect (Surface Ptr Surface
dst Maybe (IOVector Word8)
_) Maybe (Point V2 CInt)
dstLoc = IO (Maybe (Rectangle CInt)) -> m (Maybe (Rectangle CInt))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (Rectangle CInt)) -> m (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)) -> m (Maybe (Rectangle CInt))
forall a b. (a -> b) -> a -> b
$
(Rectangle CInt
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)))
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
srcRect ((Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)))
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
srcPtr ->
(Rectangle CInt
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)))
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ((Point V2 CInt -> Rectangle CInt)
-> Maybe (Point V2 CInt) -> Maybe (Rectangle CInt)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Point V2 CInt -> V2 CInt -> Rectangle CInt)
-> V2 CInt -> Point V2 CInt -> Rectangle CInt
forall a b c. (a -> b -> c) -> b -> a -> c
flip Point V2 CInt -> V2 CInt -> Rectangle CInt
forall a. Point V2 a -> V2 a -> Rectangle a
Rectangle V2 CInt
0) Maybe (Point V2 CInt)
dstLoc) ((Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)))
-> (Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
dstPtr -> do
CInt
_ <- Text -> Text -> IO CInt -> IO CInt
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m a
throwIfNeg Text
"SDL.Video.blitSurface" Text
"SDL_BlitSurface" (IO CInt -> IO CInt) -> IO CInt -> IO CInt
forall a b. (a -> b) -> a -> b
$
Ptr Surface -> Ptr Rect -> Ptr Surface -> Ptr Rect -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr Rect -> Ptr Surface -> Ptr Rect -> m CInt
Raw.blitSurface Ptr Surface
src (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
srcPtr) Ptr Surface
dst (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
dstPtr)
IO (Maybe (Rectangle CInt))
-> (Point V2 CInt -> IO (Maybe (Rectangle CInt)))
-> Maybe (Point V2 CInt)
-> IO (Maybe (Rectangle CInt))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe (Rectangle CInt) -> IO (Maybe (Rectangle CInt))
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Maybe (Rectangle CInt)
forall a. Maybe a
Nothing) (\Point V2 CInt
_ -> Rectangle CInt -> Maybe (Rectangle CInt)
forall a. a -> Maybe a
Just (Rectangle CInt -> Maybe (Rectangle CInt))
-> IO (Rectangle CInt) -> IO (Maybe (Rectangle CInt))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr (Rectangle CInt) -> IO (Rectangle CInt)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Rectangle CInt)
dstPtr) Maybe (Point V2 CInt)
dstLoc
createTexture :: (Functor m,MonadIO m)
=> Renderer
-> PixelFormat
-> TextureAccess
-> V2 CInt
-> m Texture
createTexture :: Renderer -> PixelFormat -> TextureAccess -> V2 CInt -> m Texture
createTexture (Renderer Renderer
r) PixelFormat
fmt TextureAccess
access (V2 CInt
w CInt
h) =
(Renderer -> Texture) -> m Renderer -> m Texture
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Renderer -> Texture
Texture (m Renderer -> m Texture) -> m Renderer -> m Texture
forall a b. (a -> b) -> a -> b
$
Text -> Text -> m Renderer -> m Renderer
forall (m :: Type -> Type) a.
MonadIO m =>
Text -> Text -> m (Ptr a) -> m (Ptr a)
throwIfNull Text
"SDL.Video.Renderer.createTexture" Text
"SDL_CreateTexture" (m Renderer -> m Renderer) -> m Renderer -> m Renderer
forall a b. (a -> b) -> a -> b
$
Renderer -> Word32 -> CInt -> CInt -> CInt -> m Renderer
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Word32 -> CInt -> CInt -> CInt -> m Renderer
Raw.createTexture Renderer
r (PixelFormat -> Word32
forall a b. ToNumber a b => a -> b
toNumber PixelFormat
fmt) (TextureAccess -> CInt
forall a b. ToNumber a b => a -> b
toNumber TextureAccess
access) CInt
w CInt
h
createTextureFromSurface :: (Functor m,MonadIO m)
=> Renderer
-> Surface
-> m Texture
createTextureFromSurface :: Renderer -> Surface -> m Texture
createTextureFromSurface (Renderer Renderer
r) (Surface Ptr Surface
s Maybe (IOVector Word8)
_) =
(Renderer -> Texture) -> m Renderer -> m Texture
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Renderer -> Texture
Texture (m Renderer -> m Texture) -> m Renderer -> m Texture
forall a b. (a -> b) -> a -> b
$
Text -> Text -> m Renderer -> m Renderer
forall (m :: Type -> Type) a.
MonadIO m =>
Text -> Text -> m (Ptr a) -> m (Ptr a)
throwIfNull Text
"SDL.Video.createTextureFromSurface" Text
"SDL_CreateTextureFromSurface" (m Renderer -> m Renderer) -> m Renderer -> m Renderer
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr Surface -> m Renderer
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Surface -> m Renderer
Raw.createTextureFromSurface Renderer
r Ptr Surface
s
glBindTexture :: (Functor m,MonadIO m)
=> Texture
-> m ()
glBindTexture :: Texture -> m ()
glBindTexture (Texture Renderer
t) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.glBindTexture" Text
"SDL_GL_BindTexture" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr CFloat -> Ptr CFloat -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr CFloat -> Ptr CFloat -> m CInt
Raw.glBindTexture Renderer
t Ptr CFloat
forall a. Ptr a
nullPtr Ptr CFloat
forall a. Ptr a
nullPtr
glUnbindTexture :: (Functor m,MonadIO m)
=> Texture
-> m ()
glUnbindTexture :: Texture -> m ()
glUnbindTexture (Texture Renderer
t) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.glUnindTexture" Text
"SDL_GL_UnbindTexture" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> m CInt
forall (m :: Type -> Type). MonadIO m => Renderer -> m CInt
Raw.glUnbindTexture Renderer
t
updateTexture :: (Functor m, MonadIO m)
=> Texture
-> Maybe (Rectangle CInt)
-> BS.ByteString
-> CInt
-> m ()
updateTexture :: Texture -> Maybe (Rectangle CInt) -> ByteString -> CInt -> m ()
updateTexture (Texture Renderer
t) Maybe (Rectangle CInt)
rect ByteString
pixels CInt
pitch = do
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.updateTexture" Text
"SDL_UpdateTexture" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
rect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
rectPtr ->
let (ForeignPtr Word8
pixelForeign, Int
_, Int
_) = ByteString -> (ForeignPtr Word8, Int, Int)
BSI.toForeignPtr ByteString
pixels
in ForeignPtr Word8 -> (Ptr Word8 -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Word8
pixelForeign ((Ptr Word8 -> IO CInt) -> IO CInt)
-> (Ptr Word8 -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
pixelsPtr ->
Renderer -> Ptr Rect -> Renderer -> CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> Renderer -> CInt -> m CInt
Raw.updateTexture Renderer
t (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
rectPtr) (Ptr Word8 -> Renderer
forall a b. Ptr a -> Ptr b
castPtr Ptr Word8
pixelsPtr) CInt
pitch
destroyTexture :: MonadIO m => Texture -> m ()
destroyTexture :: Texture -> m ()
destroyTexture (Texture Renderer
t) = Renderer -> m ()
forall (m :: Type -> Type). MonadIO m => Renderer -> m ()
Raw.destroyTexture Renderer
t
lockTexture :: MonadIO m
=> Texture
-> Maybe (Rectangle CInt)
-> m (Ptr (),CInt)
lockTexture :: Texture -> Maybe (Rectangle CInt) -> m (Renderer, CInt)
lockTexture (Texture Renderer
t) Maybe (Rectangle CInt)
rect = IO (Renderer, CInt) -> m (Renderer, CInt)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Renderer, CInt) -> m (Renderer, CInt))
-> IO (Renderer, CInt) -> m (Renderer, CInt)
forall a b. (a -> b) -> a -> b
$
(Ptr Renderer -> IO (Renderer, CInt)) -> IO (Renderer, CInt)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Renderer -> IO (Renderer, CInt)) -> IO (Renderer, CInt))
-> (Ptr Renderer -> IO (Renderer, CInt)) -> IO (Renderer, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr Renderer
pixelsPtr ->
(Ptr CInt -> IO (Renderer, CInt)) -> IO (Renderer, CInt)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Renderer, CInt)) -> IO (Renderer, CInt))
-> (Ptr CInt -> IO (Renderer, CInt)) -> IO (Renderer, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
pitchPtr ->
(Rectangle CInt
-> (Ptr (Rectangle CInt) -> IO (Renderer, CInt))
-> IO (Renderer, CInt))
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO (Renderer, CInt))
-> IO (Renderer, CInt)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt
-> (Ptr (Rectangle CInt) -> IO (Renderer, CInt))
-> IO (Renderer, CInt)
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
rect ((Ptr (Rectangle CInt) -> IO (Renderer, CInt))
-> IO (Renderer, CInt))
-> (Ptr (Rectangle CInt) -> IO (Renderer, CInt))
-> IO (Renderer, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
rectPtr -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"lockTexture" Text
"SDL_LockTexture" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr Rect -> Ptr Renderer -> Ptr CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> Ptr Renderer -> Ptr CInt -> m CInt
Raw.lockTexture Renderer
t (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
rectPtr) Ptr Renderer
pixelsPtr Ptr CInt
pitchPtr
Renderer
pixels <- Ptr Renderer -> IO Renderer
forall a. Storable a => Ptr a -> IO a
peek Ptr Renderer
pixelsPtr
CInt
pitch <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
pitchPtr
(Renderer, CInt) -> IO (Renderer, CInt)
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Renderer
pixels, CInt
pitch)
unlockTexture :: MonadIO m => Texture -> m ()
unlockTexture :: Texture -> m ()
unlockTexture (Texture Renderer
t) = Renderer -> m ()
forall (m :: Type -> Type). MonadIO m => Renderer -> m ()
Raw.unlockTexture Renderer
t
lockSurface :: MonadIO m => Surface -> m ()
lockSurface :: Surface -> m ()
lockSurface (Surface Ptr Surface
s Maybe (IOVector Word8)
_) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"lockSurface" Text
"SDL_LockSurface" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Ptr Surface -> m CInt
forall (m :: Type -> Type). MonadIO m => Ptr Surface -> m CInt
Raw.lockSurface Ptr Surface
s
unlockSurface :: MonadIO m => Surface -> m ()
unlockSurface :: Surface -> m ()
unlockSurface (Surface Ptr Surface
s Maybe (IOVector Word8)
_) = Ptr Surface -> m ()
forall (m :: Type -> Type). MonadIO m => Ptr Surface -> m ()
Raw.unlockSurface Ptr Surface
s
data TextureAccess
= TextureAccessStatic
| TextureAccessStreaming
| TextureAccessTarget
deriving (TextureAccess
TextureAccess -> TextureAccess -> Bounded TextureAccess
forall a. a -> a -> Bounded a
maxBound :: TextureAccess
$cmaxBound :: TextureAccess
minBound :: TextureAccess
$cminBound :: TextureAccess
Bounded, Typeable TextureAccess
DataType
Constr
Typeable TextureAccess
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TextureAccess -> c TextureAccess)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TextureAccess)
-> (TextureAccess -> Constr)
-> (TextureAccess -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TextureAccess))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TextureAccess))
-> ((forall b. Data b => b -> b) -> TextureAccess -> TextureAccess)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r)
-> (forall u. (forall d. Data d => d -> u) -> TextureAccess -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> TextureAccess -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess)
-> Data TextureAccess
TextureAccess -> DataType
TextureAccess -> Constr
(forall b. Data b => b -> b) -> TextureAccess -> TextureAccess
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TextureAccess -> c TextureAccess
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TextureAccess
forall a.
Typeable a
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TextureAccess -> u
forall u. (forall d. Data d => d -> u) -> TextureAccess -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r
forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TextureAccess
forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TextureAccess -> c TextureAccess
forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TextureAccess)
forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TextureAccess)
$cTextureAccessTarget :: Constr
$cTextureAccessStreaming :: Constr
$cTextureAccessStatic :: Constr
$tTextureAccess :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
$cgmapMo :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
gmapMp :: (forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
$cgmapMp :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
gmapM :: (forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> TextureAccess -> m TextureAccess
gmapQi :: Int -> (forall d. Data d => d -> u) -> TextureAccess -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TextureAccess -> u
gmapQ :: (forall d. Data d => d -> u) -> TextureAccess -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TextureAccess -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TextureAccess -> r
gmapT :: (forall b. Data b => b -> b) -> TextureAccess -> TextureAccess
$cgmapT :: (forall b. Data b => b -> b) -> TextureAccess -> TextureAccess
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TextureAccess)
$cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TextureAccess)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c TextureAccess)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TextureAccess)
dataTypeOf :: TextureAccess -> DataType
$cdataTypeOf :: TextureAccess -> DataType
toConstr :: TextureAccess -> Constr
$ctoConstr :: TextureAccess -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TextureAccess
$cgunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TextureAccess
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TextureAccess -> c TextureAccess
$cgfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TextureAccess -> c TextureAccess
$cp1Data :: Typeable TextureAccess
Data, Int -> TextureAccess
TextureAccess -> Int
TextureAccess -> [TextureAccess]
TextureAccess -> TextureAccess
TextureAccess -> TextureAccess -> [TextureAccess]
TextureAccess -> TextureAccess -> TextureAccess -> [TextureAccess]
(TextureAccess -> TextureAccess)
-> (TextureAccess -> TextureAccess)
-> (Int -> TextureAccess)
-> (TextureAccess -> Int)
-> (TextureAccess -> [TextureAccess])
-> (TextureAccess -> TextureAccess -> [TextureAccess])
-> (TextureAccess -> TextureAccess -> [TextureAccess])
-> (TextureAccess
-> TextureAccess -> TextureAccess -> [TextureAccess])
-> Enum TextureAccess
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: TextureAccess -> TextureAccess -> TextureAccess -> [TextureAccess]
$cenumFromThenTo :: TextureAccess -> TextureAccess -> TextureAccess -> [TextureAccess]
enumFromTo :: TextureAccess -> TextureAccess -> [TextureAccess]
$cenumFromTo :: TextureAccess -> TextureAccess -> [TextureAccess]
enumFromThen :: TextureAccess -> TextureAccess -> [TextureAccess]
$cenumFromThen :: TextureAccess -> TextureAccess -> [TextureAccess]
enumFrom :: TextureAccess -> [TextureAccess]
$cenumFrom :: TextureAccess -> [TextureAccess]
fromEnum :: TextureAccess -> Int
$cfromEnum :: TextureAccess -> Int
toEnum :: Int -> TextureAccess
$ctoEnum :: Int -> TextureAccess
pred :: TextureAccess -> TextureAccess
$cpred :: TextureAccess -> TextureAccess
succ :: TextureAccess -> TextureAccess
$csucc :: TextureAccess -> TextureAccess
Enum, TextureAccess -> TextureAccess -> Bool
(TextureAccess -> TextureAccess -> Bool)
-> (TextureAccess -> TextureAccess -> Bool) -> Eq TextureAccess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextureAccess -> TextureAccess -> Bool
$c/= :: TextureAccess -> TextureAccess -> Bool
== :: TextureAccess -> TextureAccess -> Bool
$c== :: TextureAccess -> TextureAccess -> Bool
Eq, (forall x. TextureAccess -> Rep TextureAccess x)
-> (forall x. Rep TextureAccess x -> TextureAccess)
-> Generic TextureAccess
forall x. Rep TextureAccess x -> TextureAccess
forall x. TextureAccess -> Rep TextureAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TextureAccess x -> TextureAccess
$cfrom :: forall x. TextureAccess -> Rep TextureAccess x
Generic, Eq TextureAccess
Eq TextureAccess
-> (TextureAccess -> TextureAccess -> Ordering)
-> (TextureAccess -> TextureAccess -> Bool)
-> (TextureAccess -> TextureAccess -> Bool)
-> (TextureAccess -> TextureAccess -> Bool)
-> (TextureAccess -> TextureAccess -> Bool)
-> (TextureAccess -> TextureAccess -> TextureAccess)
-> (TextureAccess -> TextureAccess -> TextureAccess)
-> Ord TextureAccess
TextureAccess -> TextureAccess -> Bool
TextureAccess -> TextureAccess -> Ordering
TextureAccess -> TextureAccess -> TextureAccess
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TextureAccess -> TextureAccess -> TextureAccess
$cmin :: TextureAccess -> TextureAccess -> TextureAccess
max :: TextureAccess -> TextureAccess -> TextureAccess
$cmax :: TextureAccess -> TextureAccess -> TextureAccess
>= :: TextureAccess -> TextureAccess -> Bool
$c>= :: TextureAccess -> TextureAccess -> Bool
> :: TextureAccess -> TextureAccess -> Bool
$c> :: TextureAccess -> TextureAccess -> Bool
<= :: TextureAccess -> TextureAccess -> Bool
$c<= :: TextureAccess -> TextureAccess -> Bool
< :: TextureAccess -> TextureAccess -> Bool
$c< :: TextureAccess -> TextureAccess -> Bool
compare :: TextureAccess -> TextureAccess -> Ordering
$ccompare :: TextureAccess -> TextureAccess -> Ordering
$cp1Ord :: Eq TextureAccess
Ord, ReadPrec [TextureAccess]
ReadPrec TextureAccess
Int -> ReadS TextureAccess
ReadS [TextureAccess]
(Int -> ReadS TextureAccess)
-> ReadS [TextureAccess]
-> ReadPrec TextureAccess
-> ReadPrec [TextureAccess]
-> Read TextureAccess
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextureAccess]
$creadListPrec :: ReadPrec [TextureAccess]
readPrec :: ReadPrec TextureAccess
$creadPrec :: ReadPrec TextureAccess
readList :: ReadS [TextureAccess]
$creadList :: ReadS [TextureAccess]
readsPrec :: Int -> ReadS TextureAccess
$creadsPrec :: Int -> ReadS TextureAccess
Read, Int -> TextureAccess -> ShowS
[TextureAccess] -> ShowS
TextureAccess -> String
(Int -> TextureAccess -> ShowS)
-> (TextureAccess -> String)
-> ([TextureAccess] -> ShowS)
-> Show TextureAccess
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextureAccess] -> ShowS
$cshowList :: [TextureAccess] -> ShowS
show :: TextureAccess -> String
$cshow :: TextureAccess -> String
showsPrec :: Int -> TextureAccess -> ShowS
$cshowsPrec :: Int -> TextureAccess -> ShowS
Show, Typeable)
instance FromNumber TextureAccess CInt where
fromNumber :: CInt -> TextureAccess
fromNumber CInt
n' = case CInt
n' of
CInt
Raw.SDL_TEXTUREACCESS_STATIC -> TextureAccess
TextureAccessStatic
CInt
Raw.SDL_TEXTUREACCESS_STREAMING -> TextureAccess
TextureAccessStreaming
CInt
Raw.SDL_TEXTUREACCESS_TARGET -> TextureAccess
TextureAccessTarget
CInt
_ -> String -> TextureAccess
forall a. HasCallStack => String -> a
error String
"Unknown value"
instance ToNumber TextureAccess CInt where
toNumber :: TextureAccess -> CInt
toNumber TextureAccess
t = case TextureAccess
t of
TextureAccess
TextureAccessStatic -> CInt
forall a. (Eq a, Num a) => a
Raw.SDL_TEXTUREACCESS_STATIC
TextureAccess
TextureAccessStreaming -> CInt
forall a. (Eq a, Num a) => a
Raw.SDL_TEXTUREACCESS_STREAMING
TextureAccess
TextureAccessTarget -> CInt
forall a. (Eq a, Num a) => a
Raw.SDL_TEXTUREACCESS_TARGET
data TextureInfo = TextureInfo
{ TextureInfo -> PixelFormat
texturePixelFormat :: PixelFormat
, TextureInfo -> TextureAccess
textureAccess :: TextureAccess
, TextureInfo -> CInt
textureWidth :: CInt
, TextureInfo -> CInt
textureHeight :: CInt
} deriving (TextureInfo -> TextureInfo -> Bool
(TextureInfo -> TextureInfo -> Bool)
-> (TextureInfo -> TextureInfo -> Bool) -> Eq TextureInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextureInfo -> TextureInfo -> Bool
$c/= :: TextureInfo -> TextureInfo -> Bool
== :: TextureInfo -> TextureInfo -> Bool
$c== :: TextureInfo -> TextureInfo -> Bool
Eq, (forall x. TextureInfo -> Rep TextureInfo x)
-> (forall x. Rep TextureInfo x -> TextureInfo)
-> Generic TextureInfo
forall x. Rep TextureInfo x -> TextureInfo
forall x. TextureInfo -> Rep TextureInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TextureInfo x -> TextureInfo
$cfrom :: forall x. TextureInfo -> Rep TextureInfo x
Generic, Eq TextureInfo
Eq TextureInfo
-> (TextureInfo -> TextureInfo -> Ordering)
-> (TextureInfo -> TextureInfo -> Bool)
-> (TextureInfo -> TextureInfo -> Bool)
-> (TextureInfo -> TextureInfo -> Bool)
-> (TextureInfo -> TextureInfo -> Bool)
-> (TextureInfo -> TextureInfo -> TextureInfo)
-> (TextureInfo -> TextureInfo -> TextureInfo)
-> Ord TextureInfo
TextureInfo -> TextureInfo -> Bool
TextureInfo -> TextureInfo -> Ordering
TextureInfo -> TextureInfo -> TextureInfo
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TextureInfo -> TextureInfo -> TextureInfo
$cmin :: TextureInfo -> TextureInfo -> TextureInfo
max :: TextureInfo -> TextureInfo -> TextureInfo
$cmax :: TextureInfo -> TextureInfo -> TextureInfo
>= :: TextureInfo -> TextureInfo -> Bool
$c>= :: TextureInfo -> TextureInfo -> Bool
> :: TextureInfo -> TextureInfo -> Bool
$c> :: TextureInfo -> TextureInfo -> Bool
<= :: TextureInfo -> TextureInfo -> Bool
$c<= :: TextureInfo -> TextureInfo -> Bool
< :: TextureInfo -> TextureInfo -> Bool
$c< :: TextureInfo -> TextureInfo -> Bool
compare :: TextureInfo -> TextureInfo -> Ordering
$ccompare :: TextureInfo -> TextureInfo -> Ordering
$cp1Ord :: Eq TextureInfo
Ord, ReadPrec [TextureInfo]
ReadPrec TextureInfo
Int -> ReadS TextureInfo
ReadS [TextureInfo]
(Int -> ReadS TextureInfo)
-> ReadS [TextureInfo]
-> ReadPrec TextureInfo
-> ReadPrec [TextureInfo]
-> Read TextureInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextureInfo]
$creadListPrec :: ReadPrec [TextureInfo]
readPrec :: ReadPrec TextureInfo
$creadPrec :: ReadPrec TextureInfo
readList :: ReadS [TextureInfo]
$creadList :: ReadS [TextureInfo]
readsPrec :: Int -> ReadS TextureInfo
$creadsPrec :: Int -> ReadS TextureInfo
Read, Int -> TextureInfo -> ShowS
[TextureInfo] -> ShowS
TextureInfo -> String
(Int -> TextureInfo -> ShowS)
-> (TextureInfo -> String)
-> ([TextureInfo] -> ShowS)
-> Show TextureInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextureInfo] -> ShowS
$cshowList :: [TextureInfo] -> ShowS
show :: TextureInfo -> String
$cshow :: TextureInfo -> String
showsPrec :: Int -> TextureInfo -> ShowS
$cshowsPrec :: Int -> TextureInfo -> ShowS
Show, Typeable)
queryTexture :: MonadIO m => Texture -> m TextureInfo
queryTexture :: Texture -> m TextureInfo
queryTexture (Texture Renderer
tex) = IO TextureInfo -> m TextureInfo
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO TextureInfo -> m TextureInfo)
-> IO TextureInfo -> m TextureInfo
forall a b. (a -> b) -> a -> b
$
(Ptr Word32 -> IO TextureInfo) -> IO TextureInfo
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO TextureInfo) -> IO TextureInfo)
-> (Ptr Word32 -> IO TextureInfo) -> IO TextureInfo
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
pfPtr ->
(Ptr CInt -> IO TextureInfo) -> IO TextureInfo
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO TextureInfo) -> IO TextureInfo)
-> (Ptr CInt -> IO TextureInfo) -> IO TextureInfo
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
acPtr ->
(Ptr CInt -> IO TextureInfo) -> IO TextureInfo
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO TextureInfo) -> IO TextureInfo)
-> (Ptr CInt -> IO TextureInfo) -> IO TextureInfo
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
wPtr ->
(Ptr CInt -> IO TextureInfo) -> IO TextureInfo
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO TextureInfo) -> IO TextureInfo)
-> (Ptr CInt -> IO TextureInfo) -> IO TextureInfo
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
hPtr -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.queryTexture" Text
"SDL_QueryTexture" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer
-> Ptr Word32 -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer
-> Ptr Word32 -> Ptr CInt -> Ptr CInt -> Ptr CInt -> m CInt
Raw.queryTexture Renderer
tex Ptr Word32
pfPtr Ptr CInt
acPtr Ptr CInt
wPtr Ptr CInt
hPtr
PixelFormat -> TextureAccess -> CInt -> CInt -> TextureInfo
TextureInfo (PixelFormat -> TextureAccess -> CInt -> CInt -> TextureInfo)
-> IO PixelFormat
-> IO (TextureAccess -> CInt -> CInt -> TextureInfo)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$>
(Word32 -> PixelFormat) -> IO Word32 -> IO PixelFormat
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Word32 -> PixelFormat
forall a b. FromNumber a b => b -> a
fromNumber (Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
pfPtr) IO (TextureAccess -> CInt -> CInt -> TextureInfo)
-> IO TextureAccess -> IO (CInt -> CInt -> TextureInfo)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*>
(CInt -> TextureAccess) -> IO CInt -> IO TextureAccess
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap CInt -> TextureAccess
forall a b. FromNumber a b => b -> a
fromNumber (Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
acPtr) IO (CInt -> CInt -> TextureInfo)
-> IO CInt -> IO (CInt -> TextureInfo)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*>
Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
wPtr IO (CInt -> TextureInfo) -> IO CInt -> IO TextureInfo
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*>
Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
hPtr
createRGBSurface :: (Functor m, MonadIO m)
=> V2 CInt
-> PixelFormat
-> m Surface
createRGBSurface :: V2 CInt -> PixelFormat -> m Surface
createRGBSurface (V2 CInt
w CInt
h) PixelFormat
pf =
(Ptr Surface -> Surface) -> m (Ptr Surface) -> m Surface
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr Surface -> Surface
unmanagedSurface (m (Ptr Surface) -> m Surface) -> m (Ptr Surface) -> m Surface
forall a b. (a -> b) -> a -> b
$
Text -> Text -> m (Ptr Surface) -> m (Ptr Surface)
forall (m :: Type -> Type) a.
MonadIO m =>
Text -> Text -> m (Ptr a) -> m (Ptr a)
throwIfNull Text
"SDL.Video.createRGBSurface" Text
"SDL_CreateRGBSurface" (m (Ptr Surface) -> m (Ptr Surface))
-> m (Ptr Surface) -> m (Ptr Surface)
forall a b. (a -> b) -> a -> b
$ do
(CInt
bpp, V4 Word32
r Word32
g Word32
b Word32
a) <- PixelFormat -> m (CInt, V4 Word32)
forall (m :: Type -> Type).
MonadIO m =>
PixelFormat -> m (CInt, V4 Word32)
pixelFormatToMasks PixelFormat
pf
Word32
-> CInt
-> CInt
-> CInt
-> Word32
-> Word32
-> Word32
-> Word32
-> m (Ptr Surface)
forall (m :: Type -> Type).
MonadIO m =>
Word32
-> CInt
-> CInt
-> CInt
-> Word32
-> Word32
-> Word32
-> Word32
-> m (Ptr Surface)
Raw.createRGBSurface Word32
0 CInt
w CInt
h CInt
bpp Word32
r Word32
g Word32
b Word32
a
createRGBSurfaceFrom :: (Functor m, MonadIO m)
=> MSV.IOVector Word8
-> V2 CInt
-> CInt
-> PixelFormat
-> m Surface
createRGBSurfaceFrom :: IOVector Word8 -> V2 CInt -> CInt -> PixelFormat -> m Surface
createRGBSurfaceFrom IOVector Word8
pixels (V2 CInt
w CInt
h) CInt
p PixelFormat
pf = IO Surface -> m Surface
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Surface -> m Surface) -> IO Surface -> m Surface
forall a b. (a -> b) -> a -> b
$
(Ptr Surface -> Surface) -> IO (Ptr Surface) -> IO Surface
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap (IOVector Word8 -> Ptr Surface -> Surface
managedSurface IOVector Word8
pixels) (IO (Ptr Surface) -> IO Surface) -> IO (Ptr Surface) -> IO Surface
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO (Ptr Surface) -> IO (Ptr Surface)
forall (m :: Type -> Type) a.
MonadIO m =>
Text -> Text -> m (Ptr a) -> m (Ptr a)
throwIfNull Text
"SDL.Video.createRGBSurfaceFrom" Text
"SDL_CreateRGBSurfaceFrom" (IO (Ptr Surface) -> IO (Ptr Surface))
-> IO (Ptr Surface) -> IO (Ptr Surface)
forall a b. (a -> b) -> a -> b
$ do
(CInt
bpp, V4 Word32
r Word32
g Word32
b Word32
a) <- PixelFormat -> IO (CInt, V4 Word32)
forall (m :: Type -> Type).
MonadIO m =>
PixelFormat -> m (CInt, V4 Word32)
pixelFormatToMasks PixelFormat
pf
IOVector Word8
-> (Ptr Word8 -> IO (Ptr Surface)) -> IO (Ptr Surface)
forall a b. Storable a => IOVector a -> (Ptr a -> IO b) -> IO b
MSV.unsafeWith IOVector Word8
pixels ((Ptr Word8 -> IO (Ptr Surface)) -> IO (Ptr Surface))
-> (Ptr Word8 -> IO (Ptr Surface)) -> IO (Ptr Surface)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
pixelPtr ->
Renderer
-> CInt
-> CInt
-> CInt
-> CInt
-> Word32
-> Word32
-> Word32
-> Word32
-> IO (Ptr Surface)
forall (m :: Type -> Type).
MonadIO m =>
Renderer
-> CInt
-> CInt
-> CInt
-> CInt
-> Word32
-> Word32
-> Word32
-> Word32
-> m (Ptr Surface)
Raw.createRGBSurfaceFrom (Ptr Word8 -> Renderer
forall a b. Ptr a -> Ptr b
castPtr Ptr Word8
pixelPtr) CInt
w CInt
h CInt
bpp CInt
p Word32
r Word32
g Word32
b Word32
a
surfaceFillRect :: MonadIO m
=> Surface
-> Maybe (Rectangle CInt)
-> V4 Word8
-> m ()
surfaceFillRect :: Surface -> Maybe (Rectangle CInt) -> V4 Word8 -> m ()
surfaceFillRect (Surface Ptr Surface
s Maybe (IOVector Word8)
_) Maybe (Rectangle CInt)
rect (V4 Word8
r Word8
g Word8
b Word8
a) = IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.fillRect" Text
"SDL_FillRect" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
rect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
rectPtr -> do
Ptr PixelFormat
format <- Surface -> Ptr PixelFormat
Raw.surfaceFormat (Surface -> Ptr PixelFormat) -> IO Surface -> IO (Ptr PixelFormat)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Surface -> IO Surface
forall a. Storable a => Ptr a -> IO a
peek Ptr Surface
s
Ptr PixelFormat -> Word8 -> Word8 -> Word8 -> Word8 -> IO Word32
forall (m :: Type -> Type).
MonadIO m =>
Ptr PixelFormat -> Word8 -> Word8 -> Word8 -> Word8 -> m Word32
Raw.mapRGBA Ptr PixelFormat
format Word8
r Word8
g Word8
b Word8
a IO Word32 -> (Word32 -> IO CInt) -> IO CInt
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr Surface -> Ptr Rect -> Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr Rect -> Word32 -> m CInt
Raw.fillRect Ptr Surface
s (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
rectPtr)
surfaceFillRects :: MonadIO m
=> Surface
-> SV.Vector (Rectangle CInt)
-> V4 Word8
-> m ()
surfaceFillRects :: Surface -> Vector (Rectangle CInt) -> V4 Word8 -> m ()
surfaceFillRects (Surface Ptr Surface
s Maybe (IOVector Word8)
_) Vector (Rectangle CInt)
rects (V4 Word8
r Word8
g Word8
b Word8
a) = IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.fillRects" Text
"SDL_FillRects" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Vector (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => Vector a -> (Ptr a -> IO b) -> IO b
SV.unsafeWith Vector (Rectangle CInt)
rects ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
rp -> do
Ptr PixelFormat
format <- Surface -> Ptr PixelFormat
Raw.surfaceFormat (Surface -> Ptr PixelFormat) -> IO Surface -> IO (Ptr PixelFormat)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Surface -> IO Surface
forall a. Storable a => Ptr a -> IO a
peek Ptr Surface
s
Ptr Surface -> Ptr Rect -> CInt -> Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr Rect -> CInt -> Word32 -> m CInt
Raw.fillRects Ptr Surface
s
(Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
rp)
(Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector (Rectangle CInt) -> Int
forall a. Storable a => Vector a -> Int
SV.length Vector (Rectangle CInt)
rects))
(Word32 -> IO CInt) -> IO Word32 -> IO CInt
forall (m :: Type -> Type) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr PixelFormat -> Word8 -> Word8 -> Word8 -> Word8 -> IO Word32
forall (m :: Type -> Type).
MonadIO m =>
Ptr PixelFormat -> Word8 -> Word8 -> Word8 -> Word8 -> m Word32
Raw.mapRGBA Ptr PixelFormat
format Word8
r Word8
g Word8
b Word8
a
freeSurface :: MonadIO m => Surface -> m ()
freeSurface :: Surface -> m ()
freeSurface (Surface Ptr Surface
s Maybe (IOVector Word8)
_) = Ptr Surface -> m ()
forall (m :: Type -> Type). MonadIO m => Ptr Surface -> m ()
Raw.freeSurface Ptr Surface
s
loadBMP :: MonadIO m => FilePath -> m Surface
loadBMP :: String -> m Surface
loadBMP String
filePath = IO Surface -> m Surface
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Surface -> m Surface) -> IO Surface -> m Surface
forall a b. (a -> b) -> a -> b
$
(Ptr Surface -> Surface) -> IO (Ptr Surface) -> IO Surface
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr Surface -> Surface
unmanagedSurface (IO (Ptr Surface) -> IO Surface) -> IO (Ptr Surface) -> IO Surface
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO (Ptr Surface) -> IO (Ptr Surface)
forall (m :: Type -> Type) a.
MonadIO m =>
Text -> Text -> m (Ptr a) -> m (Ptr a)
throwIfNull Text
"SDL.Video.loadBMP" Text
"SDL_LoadBMP" (IO (Ptr Surface) -> IO (Ptr Surface))
-> IO (Ptr Surface) -> IO (Ptr Surface)
forall a b. (a -> b) -> a -> b
$
String -> (CString -> IO (Ptr Surface)) -> IO (Ptr Surface)
forall a. String -> (CString -> IO a) -> IO a
withCString String
filePath ((CString -> IO (Ptr Surface)) -> IO (Ptr Surface))
-> (CString -> IO (Ptr Surface)) -> IO (Ptr Surface)
forall a b. (a -> b) -> a -> b
$ CString -> IO (Ptr Surface)
forall (m :: Type -> Type). MonadIO m => CString -> m (Ptr Surface)
Raw.loadBMP
newtype SurfacePixelFormat = SurfacePixelFormat (Ptr Raw.PixelFormat)
deriving (SurfacePixelFormat -> SurfacePixelFormat -> Bool
(SurfacePixelFormat -> SurfacePixelFormat -> Bool)
-> (SurfacePixelFormat -> SurfacePixelFormat -> Bool)
-> Eq SurfacePixelFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SurfacePixelFormat -> SurfacePixelFormat -> Bool
$c/= :: SurfacePixelFormat -> SurfacePixelFormat -> Bool
== :: SurfacePixelFormat -> SurfacePixelFormat -> Bool
$c== :: SurfacePixelFormat -> SurfacePixelFormat -> Bool
Eq, Typeable)
surfaceDimensions :: MonadIO m => Surface -> m (V2 CInt)
surfaceDimensions :: Surface -> m (V2 CInt)
surfaceDimensions (Surface Ptr Surface
s Maybe (IOVector Word8)
_) = IO (V2 CInt) -> m (V2 CInt)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (V2 CInt) -> m (V2 CInt)) -> IO (V2 CInt) -> m (V2 CInt)
forall a b. (a -> b) -> a -> b
$ (CInt -> CInt -> V2 CInt
forall a. a -> a -> V2 a
V2 (CInt -> CInt -> V2 CInt)
-> (Surface -> CInt) -> Surface -> CInt -> V2 CInt
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Surface -> CInt
Raw.surfaceW (Surface -> CInt -> V2 CInt)
-> (Surface -> CInt) -> Surface -> V2 CInt
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Surface -> CInt
Raw.surfaceH) (Surface -> V2 CInt) -> IO Surface -> IO (V2 CInt)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Surface -> IO Surface
forall a. Storable a => Ptr a -> IO a
peek Ptr Surface
s
surfacePixels :: MonadIO m => Surface -> m (Ptr ())
surfacePixels :: Surface -> m Renderer
surfacePixels (Surface Ptr Surface
s Maybe (IOVector Word8)
_) = IO Renderer -> m Renderer
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Renderer -> m Renderer) -> IO Renderer -> m Renderer
forall a b. (a -> b) -> a -> b
$ Surface -> Renderer
Raw.surfacePixels (Surface -> Renderer) -> IO Surface -> IO Renderer
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Surface -> IO Surface
forall a. Storable a => Ptr a -> IO a
peek Ptr Surface
s
surfaceFormat :: MonadIO m => Surface -> m SurfacePixelFormat
surfaceFormat :: Surface -> m SurfacePixelFormat
surfaceFormat (Surface Ptr Surface
s Maybe (IOVector Word8)
_) = IO SurfacePixelFormat -> m SurfacePixelFormat
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO SurfacePixelFormat -> m SurfacePixelFormat)
-> IO SurfacePixelFormat -> m SurfacePixelFormat
forall a b. (a -> b) -> a -> b
$ Ptr PixelFormat -> SurfacePixelFormat
SurfacePixelFormat (Ptr PixelFormat -> SurfacePixelFormat)
-> (Surface -> Ptr PixelFormat) -> Surface -> SurfacePixelFormat
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Surface -> Ptr PixelFormat
Raw.surfaceFormat (Surface -> SurfacePixelFormat)
-> IO Surface -> IO SurfacePixelFormat
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Surface -> IO Surface
forall a. Storable a => Ptr a -> IO a
peek Ptr Surface
s
newtype Palette = Palette (Ptr Raw.Palette)
deriving (Palette -> Palette -> Bool
(Palette -> Palette -> Bool)
-> (Palette -> Palette -> Bool) -> Eq Palette
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Palette -> Palette -> Bool
$c/= :: Palette -> Palette -> Bool
== :: Palette -> Palette -> Bool
$c== :: Palette -> Palette -> Bool
Eq, Typeable)
formatPalette :: MonadIO m => SurfacePixelFormat -> m (Maybe Palette)
formatPalette :: SurfacePixelFormat -> m (Maybe Palette)
formatPalette (SurfacePixelFormat Ptr PixelFormat
f) = IO (Maybe Palette) -> m (Maybe Palette)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Palette) -> m (Maybe Palette))
-> IO (Maybe Palette) -> m (Maybe Palette)
forall a b. (a -> b) -> a -> b
$ Ptr Palette -> Maybe Palette
wrap (Ptr Palette -> Maybe Palette)
-> (PixelFormat -> Ptr Palette) -> PixelFormat -> Maybe Palette
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PixelFormat -> Ptr Palette
Raw.pixelFormatPalette (PixelFormat -> Maybe Palette)
-> IO PixelFormat -> IO (Maybe Palette)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr PixelFormat -> IO PixelFormat
forall a. Storable a => Ptr a -> IO a
peek Ptr PixelFormat
f
where wrap :: Ptr Palette -> Maybe Palette
wrap Ptr Palette
p
| Ptr Palette
p Ptr Palette -> Ptr Palette -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr Palette
forall a. Ptr a
nullPtr = Maybe Palette
forall a. Maybe a
Nothing
| Bool
otherwise = Palette -> Maybe Palette
forall a. a -> Maybe a
Just (Ptr Palette -> Palette
Palette Ptr Palette
p)
paletteNColors :: MonadIO m => Palette -> m CInt
paletteNColors :: Palette -> m CInt
paletteNColors (Palette Ptr Palette
p) = IO CInt -> m CInt
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO CInt -> m CInt) -> IO CInt -> m CInt
forall a b. (a -> b) -> a -> b
$ Palette -> CInt
Raw.paletteNColors (Palette -> CInt) -> IO Palette -> IO CInt
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Palette -> IO Palette
forall a. Storable a => Ptr a -> IO a
peek Ptr Palette
p
paletteColors :: MonadIO m => Palette -> m (Maybe (SV.Vector (V4 Word8)))
paletteColors :: Palette -> m (Maybe (Vector (V4 Word8)))
paletteColors q :: Palette
q@(Palette Ptr Palette
p) = do
Int
n <- IO Int -> m Int
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Int -> m Int) -> IO Int -> m Int
forall a b. (a -> b) -> a -> b
$ CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> IO CInt -> IO Int
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Palette -> IO CInt
forall (m :: Type -> Type). MonadIO m => Palette -> m CInt
paletteNColors Palette
q
let wrap :: Ptr a -> Maybe (Ptr a)
wrap Ptr a
p' | Ptr a
p' Ptr a -> Ptr a -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr a
forall a. Ptr a
nullPtr = Maybe (Ptr a)
forall a. Maybe a
Nothing
| Bool
otherwise = Ptr a -> Maybe (Ptr a)
forall (m :: Type -> Type) a. Monad m => a -> m a
return Ptr a
p'
Maybe (Ptr (V4 Word8))
mv <- IO (Maybe (Ptr (V4 Word8))) -> m (Maybe (Ptr (V4 Word8)))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (Ptr (V4 Word8))) -> m (Maybe (Ptr (V4 Word8))))
-> IO (Maybe (Ptr (V4 Word8))) -> m (Maybe (Ptr (V4 Word8)))
forall a b. (a -> b) -> a -> b
$ Ptr (V4 Word8) -> Maybe (Ptr (V4 Word8))
forall a. Ptr a -> Maybe (Ptr a)
wrap (Ptr (V4 Word8) -> Maybe (Ptr (V4 Word8)))
-> (Palette -> Ptr (V4 Word8)) -> Palette -> Maybe (Ptr (V4 Word8))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr Color -> Ptr (V4 Word8)
forall a b. Ptr a -> Ptr b
castPtr (Ptr Color -> Ptr (V4 Word8))
-> (Palette -> Ptr Color) -> Palette -> Ptr (V4 Word8)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Palette -> Ptr Color
Raw.paletteColors (Palette -> Maybe (Ptr (V4 Word8)))
-> IO Palette -> IO (Maybe (Ptr (V4 Word8)))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Palette -> IO Palette
forall a. Storable a => Ptr a -> IO a
peek Ptr Palette
p
Maybe (ForeignPtr (V4 Word8))
mColor <- IO (Maybe (ForeignPtr (V4 Word8)))
-> m (Maybe (ForeignPtr (V4 Word8)))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (ForeignPtr (V4 Word8)))
-> m (Maybe (ForeignPtr (V4 Word8))))
-> IO (Maybe (ForeignPtr (V4 Word8)))
-> m (Maybe (ForeignPtr (V4 Word8)))
forall a b. (a -> b) -> a -> b
$ (Ptr (V4 Word8) -> IO (ForeignPtr (V4 Word8)))
-> Maybe (Ptr (V4 Word8)) -> IO (Maybe (ForeignPtr (V4 Word8)))
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Ptr (V4 Word8) -> IO (ForeignPtr (V4 Word8))
forall a. Ptr a -> IO (ForeignPtr a)
newForeignPtr_ Maybe (Ptr (V4 Word8))
mv
Maybe (Vector (V4 Word8)) -> m (Maybe (Vector (V4 Word8)))
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Maybe (Vector (V4 Word8)) -> m (Maybe (Vector (V4 Word8))))
-> Maybe (Vector (V4 Word8)) -> m (Maybe (Vector (V4 Word8)))
forall a b. (a -> b) -> a -> b
$ (ForeignPtr (V4 Word8) -> Int -> Vector (V4 Word8))
-> Int -> ForeignPtr (V4 Word8) -> Vector (V4 Word8)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ForeignPtr (V4 Word8) -> Int -> Vector (V4 Word8)
forall a. Storable a => ForeignPtr a -> Int -> Vector a
SV.unsafeFromForeignPtr0 Int
n (ForeignPtr (V4 Word8) -> Vector (V4 Word8))
-> Maybe (ForeignPtr (V4 Word8)) -> Maybe (Vector (V4 Word8))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (ForeignPtr (V4 Word8))
mColor
paletteColor :: MonadIO m => Palette -> CInt -> m (Maybe (V4 Word8))
paletteColor :: Palette -> CInt -> m (Maybe (V4 Word8))
paletteColor q :: Palette
q@(Palette Ptr Palette
p) CInt
i = do
Palette
rp <- IO Palette -> m Palette
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Palette -> m Palette) -> IO Palette -> m Palette
forall a b. (a -> b) -> a -> b
$ Ptr Palette -> IO Palette
forall a. Storable a => Ptr a -> IO a
peek Ptr Palette
p
CInt
m <- Palette -> m CInt
forall (m :: Type -> Type). MonadIO m => Palette -> m CInt
paletteNColors Palette
q
if CInt
m CInt -> CInt -> Bool
forall a. Ord a => a -> a -> Bool
> CInt
i Bool -> Bool -> Bool
&& CInt
i CInt -> CInt -> Bool
forall a. Ord a => a -> a -> Bool
>= CInt
0 then
IO (Maybe (V4 Word8)) -> m (Maybe (V4 Word8))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (V4 Word8)) -> m (Maybe (V4 Word8)))
-> IO (Maybe (V4 Word8)) -> m (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$ (V4 Word8 -> Maybe (V4 Word8))
-> IO (V4 Word8) -> IO (Maybe (V4 Word8))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap V4 Word8 -> Maybe (V4 Word8)
forall (m :: Type -> Type) a. Monad m => a -> m a
return (IO (V4 Word8) -> IO (Maybe (V4 Word8)))
-> (Palette -> IO (V4 Word8)) -> Palette -> IO (Maybe (V4 Word8))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Ptr (V4 Word8) -> Int -> IO (V4 Word8))
-> Int -> Ptr (V4 Word8) -> IO (V4 Word8)
forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr (V4 Word8) -> Int -> IO (V4 Word8)
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
i) (Ptr (V4 Word8) -> IO (V4 Word8))
-> (Palette -> Ptr (V4 Word8)) -> Palette -> IO (V4 Word8)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr Color -> Ptr (V4 Word8)
forall a b. Ptr a -> Ptr b
castPtr (Ptr Color -> Ptr (V4 Word8))
-> (Palette -> Ptr Color) -> Palette -> Ptr (V4 Word8)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Palette -> Ptr Color
Raw.paletteColors (Palette -> IO (Maybe (V4 Word8)))
-> Palette -> IO (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$ Palette
rp
else
Maybe (V4 Word8) -> m (Maybe (V4 Word8))
forall (m :: Type -> Type) a. Monad m => a -> m a
return Maybe (V4 Word8)
forall a. Maybe a
Nothing
setPaletteColors :: MonadIO m
=> Palette
-> (SV.Vector (V4 Word8))
-> CInt
-> m ()
setPaletteColors :: Palette -> Vector (V4 Word8) -> CInt -> m ()
setPaletteColors (Palette Ptr Palette
p) Vector (V4 Word8)
colors CInt
first = IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.setPaletteColors" Text
"SDL_SetPaletteColors" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Vector (V4 Word8) -> (Ptr (V4 Word8) -> IO CInt) -> IO CInt
forall a b. Storable a => Vector a -> (Ptr a -> IO b) -> IO b
SV.unsafeWith Vector (V4 Word8)
colors ((Ptr (V4 Word8) -> IO CInt) -> IO CInt)
-> (Ptr (V4 Word8) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (V4 Word8)
cp ->
Ptr Palette -> Ptr Color -> CInt -> CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Palette -> Ptr Color -> CInt -> CInt -> m CInt
Raw.setPaletteColors Ptr Palette
p (Ptr (V4 Word8) -> Ptr Color
forall a b. Ptr a -> Ptr b
castPtr Ptr (V4 Word8)
cp) CInt
first CInt
n
where
n :: CInt
n = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> Int -> CInt
forall a b. (a -> b) -> a -> b
$ Vector (V4 Word8) -> Int
forall a. Storable a => Vector a -> Int
SV.length Vector (V4 Word8)
colors
getWindowSurface :: (Functor m, MonadIO m) => Window -> m Surface
getWindowSurface :: Window -> m Surface
getWindowSurface (Window Renderer
w) =
(Ptr Surface -> Surface) -> m (Ptr Surface) -> m Surface
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr Surface -> Surface
unmanagedSurface (m (Ptr Surface) -> m Surface) -> m (Ptr Surface) -> m Surface
forall a b. (a -> b) -> a -> b
$
Text -> Text -> m (Ptr Surface) -> m (Ptr Surface)
forall (m :: Type -> Type) a.
MonadIO m =>
Text -> Text -> m (Ptr a) -> m (Ptr a)
throwIfNull Text
"SDL.Video.getWindowSurface" Text
"SDL_GetWindowSurface" (m (Ptr Surface) -> m (Ptr Surface))
-> m (Ptr Surface) -> m (Ptr Surface)
forall a b. (a -> b) -> a -> b
$
Renderer -> m (Ptr Surface)
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> m (Ptr Surface)
Raw.getWindowSurface Renderer
w
rendererDrawBlendMode :: Renderer -> StateVar BlendMode
rendererDrawBlendMode :: Renderer -> StateVar BlendMode
rendererDrawBlendMode (Renderer Renderer
r) = IO BlendMode -> (BlendMode -> IO ()) -> StateVar BlendMode
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO BlendMode
getRenderDrawBlendMode BlendMode -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, ToNumber a Word32) =>
a -> m ()
setRenderDrawBlendMode
where
getRenderDrawBlendMode :: IO BlendMode
getRenderDrawBlendMode = IO BlendMode -> IO BlendMode
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO BlendMode -> IO BlendMode) -> IO BlendMode -> IO BlendMode
forall a b. (a -> b) -> a -> b
$
(Ptr Word32 -> IO BlendMode) -> IO BlendMode
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO BlendMode) -> IO BlendMode)
-> (Ptr Word32 -> IO BlendMode) -> IO BlendMode
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
bmPtr -> do
Text -> Text -> IO Int -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.getRenderDrawBlendMode" Text
"SDL_GetRenderDrawBlendMode" (IO Int -> IO ()) -> IO Int -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr Word32 -> IO Int
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Word32 -> m Int
Raw.getRenderDrawBlendMode Renderer
r Ptr Word32
bmPtr
Word32 -> BlendMode
forall a b. FromNumber a b => b -> a
fromNumber (Word32 -> BlendMode) -> IO Word32 -> IO BlendMode
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
bmPtr
setRenderDrawBlendMode :: a -> m ()
setRenderDrawBlendMode a
bm =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.setRenderDrawBlendMode" Text
"SDL_SetRenderDrawBlendMode" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Word32 -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Word32 -> m CInt
Raw.setRenderDrawBlendMode Renderer
r (a -> Word32
forall a b. ToNumber a b => a -> b
toNumber a
bm)
rendererDrawColor :: Renderer -> StateVar (V4 Word8)
rendererDrawColor :: Renderer -> StateVar (V4 Word8)
rendererDrawColor (Renderer Renderer
re) = IO (V4 Word8) -> (V4 Word8 -> IO ()) -> StateVar (V4 Word8)
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (V4 Word8)
getRenderDrawColor V4 Word8 -> IO ()
forall (m :: Type -> Type). MonadIO m => V4 Word8 -> m ()
setRenderDrawColor
where
getRenderDrawColor :: IO (V4 Word8)
getRenderDrawColor = IO (V4 Word8) -> IO (V4 Word8)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (V4 Word8) -> IO (V4 Word8)) -> IO (V4 Word8) -> IO (V4 Word8)
forall a b. (a -> b) -> a -> b
$
(Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8))
-> (Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
r ->
(Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8))
-> (Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
g ->
(Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8))
-> (Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
b ->
(Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8))
-> (Ptr Word8 -> IO (V4 Word8)) -> IO (V4 Word8)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
a -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.getRenderDrawColor" Text
"SDL_GetRenderDrawColor" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer
-> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer
-> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> m CInt
Raw.getRenderDrawColor Renderer
re Ptr Word8
r Ptr Word8
g Ptr Word8
b Ptr Word8
a
Word8 -> Word8 -> Word8 -> Word8 -> V4 Word8
forall a. a -> a -> a -> a -> V4 a
V4 (Word8 -> Word8 -> Word8 -> Word8 -> V4 Word8)
-> IO Word8 -> IO (Word8 -> Word8 -> Word8 -> V4 Word8)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
r IO (Word8 -> Word8 -> Word8 -> V4 Word8)
-> IO Word8 -> IO (Word8 -> Word8 -> V4 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
g IO (Word8 -> Word8 -> V4 Word8)
-> IO Word8 -> IO (Word8 -> V4 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
b IO (Word8 -> V4 Word8) -> IO Word8 -> IO (V4 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
a
setRenderDrawColor :: V4 Word8 -> m ()
setRenderDrawColor (V4 Word8
r Word8
g Word8
b Word8
a) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.setRenderDrawColor" Text
"SDL_SetRenderDrawColor" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Word8 -> Word8 -> Word8 -> Word8 -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Word8 -> Word8 -> Word8 -> Word8 -> m CInt
Raw.setRenderDrawColor Renderer
re Word8
r Word8
g Word8
b Word8
a
updateWindowSurface :: (Functor m, MonadIO m) => Window -> m ()
updateWindowSurface :: Window -> m ()
updateWindowSurface (Window Renderer
w) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.updateWindowSurface" Text
"SDL_UpdateWindowSurface" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> m CInt
forall (m :: Type -> Type). MonadIO m => Renderer -> m CInt
Raw.updateWindowSurface Renderer
w
data BlendMode
= BlendNone
| BlendAlphaBlend
| BlendAdditive
| BlendMod
deriving (BlendMode
BlendMode -> BlendMode -> Bounded BlendMode
forall a. a -> a -> Bounded a
maxBound :: BlendMode
$cmaxBound :: BlendMode
minBound :: BlendMode
$cminBound :: BlendMode
Bounded, Typeable BlendMode
DataType
Constr
Typeable BlendMode
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlendMode -> c BlendMode)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlendMode)
-> (BlendMode -> Constr)
-> (BlendMode -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BlendMode))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlendMode))
-> ((forall b. Data b => b -> b) -> BlendMode -> BlendMode)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r)
-> (forall u. (forall d. Data d => d -> u) -> BlendMode -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> BlendMode -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode)
-> Data BlendMode
BlendMode -> DataType
BlendMode -> Constr
(forall b. Data b => b -> b) -> BlendMode -> BlendMode
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlendMode -> c BlendMode
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlendMode
forall a.
Typeable a
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BlendMode -> u
forall u. (forall d. Data d => d -> u) -> BlendMode -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r
forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlendMode
forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlendMode -> c BlendMode
forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BlendMode)
forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlendMode)
$cBlendMod :: Constr
$cBlendAdditive :: Constr
$cBlendAlphaBlend :: Constr
$cBlendNone :: Constr
$tBlendMode :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
$cgmapMo :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
gmapMp :: (forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
$cgmapMp :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
gmapM :: (forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> BlendMode -> m BlendMode
gmapQi :: Int -> (forall d. Data d => d -> u) -> BlendMode -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BlendMode -> u
gmapQ :: (forall d. Data d => d -> u) -> BlendMode -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BlendMode -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BlendMode -> r
gmapT :: (forall b. Data b => b -> b) -> BlendMode -> BlendMode
$cgmapT :: (forall b. Data b => b -> b) -> BlendMode -> BlendMode
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlendMode)
$cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlendMode)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BlendMode)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BlendMode)
dataTypeOf :: BlendMode -> DataType
$cdataTypeOf :: BlendMode -> DataType
toConstr :: BlendMode -> Constr
$ctoConstr :: BlendMode -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlendMode
$cgunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlendMode
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlendMode -> c BlendMode
$cgfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlendMode -> c BlendMode
$cp1Data :: Typeable BlendMode
Data, Int -> BlendMode
BlendMode -> Int
BlendMode -> [BlendMode]
BlendMode -> BlendMode
BlendMode -> BlendMode -> [BlendMode]
BlendMode -> BlendMode -> BlendMode -> [BlendMode]
(BlendMode -> BlendMode)
-> (BlendMode -> BlendMode)
-> (Int -> BlendMode)
-> (BlendMode -> Int)
-> (BlendMode -> [BlendMode])
-> (BlendMode -> BlendMode -> [BlendMode])
-> (BlendMode -> BlendMode -> [BlendMode])
-> (BlendMode -> BlendMode -> BlendMode -> [BlendMode])
-> Enum BlendMode
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: BlendMode -> BlendMode -> BlendMode -> [BlendMode]
$cenumFromThenTo :: BlendMode -> BlendMode -> BlendMode -> [BlendMode]
enumFromTo :: BlendMode -> BlendMode -> [BlendMode]
$cenumFromTo :: BlendMode -> BlendMode -> [BlendMode]
enumFromThen :: BlendMode -> BlendMode -> [BlendMode]
$cenumFromThen :: BlendMode -> BlendMode -> [BlendMode]
enumFrom :: BlendMode -> [BlendMode]
$cenumFrom :: BlendMode -> [BlendMode]
fromEnum :: BlendMode -> Int
$cfromEnum :: BlendMode -> Int
toEnum :: Int -> BlendMode
$ctoEnum :: Int -> BlendMode
pred :: BlendMode -> BlendMode
$cpred :: BlendMode -> BlendMode
succ :: BlendMode -> BlendMode
$csucc :: BlendMode -> BlendMode
Enum, BlendMode -> BlendMode -> Bool
(BlendMode -> BlendMode -> Bool)
-> (BlendMode -> BlendMode -> Bool) -> Eq BlendMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BlendMode -> BlendMode -> Bool
$c/= :: BlendMode -> BlendMode -> Bool
== :: BlendMode -> BlendMode -> Bool
$c== :: BlendMode -> BlendMode -> Bool
Eq, (forall x. BlendMode -> Rep BlendMode x)
-> (forall x. Rep BlendMode x -> BlendMode) -> Generic BlendMode
forall x. Rep BlendMode x -> BlendMode
forall x. BlendMode -> Rep BlendMode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BlendMode x -> BlendMode
$cfrom :: forall x. BlendMode -> Rep BlendMode x
Generic, Eq BlendMode
Eq BlendMode
-> (BlendMode -> BlendMode -> Ordering)
-> (BlendMode -> BlendMode -> Bool)
-> (BlendMode -> BlendMode -> Bool)
-> (BlendMode -> BlendMode -> Bool)
-> (BlendMode -> BlendMode -> Bool)
-> (BlendMode -> BlendMode -> BlendMode)
-> (BlendMode -> BlendMode -> BlendMode)
-> Ord BlendMode
BlendMode -> BlendMode -> Bool
BlendMode -> BlendMode -> Ordering
BlendMode -> BlendMode -> BlendMode
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: BlendMode -> BlendMode -> BlendMode
$cmin :: BlendMode -> BlendMode -> BlendMode
max :: BlendMode -> BlendMode -> BlendMode
$cmax :: BlendMode -> BlendMode -> BlendMode
>= :: BlendMode -> BlendMode -> Bool
$c>= :: BlendMode -> BlendMode -> Bool
> :: BlendMode -> BlendMode -> Bool
$c> :: BlendMode -> BlendMode -> Bool
<= :: BlendMode -> BlendMode -> Bool
$c<= :: BlendMode -> BlendMode -> Bool
< :: BlendMode -> BlendMode -> Bool
$c< :: BlendMode -> BlendMode -> Bool
compare :: BlendMode -> BlendMode -> Ordering
$ccompare :: BlendMode -> BlendMode -> Ordering
$cp1Ord :: Eq BlendMode
Ord, ReadPrec [BlendMode]
ReadPrec BlendMode
Int -> ReadS BlendMode
ReadS [BlendMode]
(Int -> ReadS BlendMode)
-> ReadS [BlendMode]
-> ReadPrec BlendMode
-> ReadPrec [BlendMode]
-> Read BlendMode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BlendMode]
$creadListPrec :: ReadPrec [BlendMode]
readPrec :: ReadPrec BlendMode
$creadPrec :: ReadPrec BlendMode
readList :: ReadS [BlendMode]
$creadList :: ReadS [BlendMode]
readsPrec :: Int -> ReadS BlendMode
$creadsPrec :: Int -> ReadS BlendMode
Read, Int -> BlendMode -> ShowS
[BlendMode] -> ShowS
BlendMode -> String
(Int -> BlendMode -> ShowS)
-> (BlendMode -> String)
-> ([BlendMode] -> ShowS)
-> Show BlendMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BlendMode] -> ShowS
$cshowList :: [BlendMode] -> ShowS
show :: BlendMode -> String
$cshow :: BlendMode -> String
showsPrec :: Int -> BlendMode -> ShowS
$cshowsPrec :: Int -> BlendMode -> ShowS
Show, Typeable)
instance FromNumber BlendMode Word32 where
fromNumber :: Word32 -> BlendMode
fromNumber Word32
n = case Word32
n of
Word32
Raw.SDL_BLENDMODE_ADD -> BlendMode
BlendAdditive
Word32
Raw.SDL_BLENDMODE_BLEND -> BlendMode
BlendAlphaBlend
Word32
Raw.SDL_BLENDMODE_NONE -> BlendMode
BlendNone
Word32
Raw.SDL_BLENDMODE_MOD -> BlendMode
BlendMod
Word32
_ -> String -> BlendMode
forall a. HasCallStack => String -> a
error (String -> BlendMode) -> String -> BlendMode
forall a b. (a -> b) -> a -> b
$ String
"fromNumber<BlendMode>: unknown blend mode: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word32 -> String
forall a. Show a => a -> String
show Word32
n
instance ToNumber BlendMode Word32 where
toNumber :: BlendMode -> Word32
toNumber BlendMode
BlendNone = Word32
Raw.SDL_BLENDMODE_NONE
toNumber BlendMode
BlendAlphaBlend = Word32
Raw.SDL_BLENDMODE_BLEND
toNumber BlendMode
BlendAdditive = Word32
Raw.SDL_BLENDMODE_ADD
toNumber BlendMode
BlendMod = Word32
Raw.SDL_BLENDMODE_MOD
data Rectangle a = Rectangle (Point V2 a) (V2 a)
deriving (Rectangle a -> Rectangle a -> Bool
(Rectangle a -> Rectangle a -> Bool)
-> (Rectangle a -> Rectangle a -> Bool) -> Eq (Rectangle a)
forall a. Eq a => Rectangle a -> Rectangle a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rectangle a -> Rectangle a -> Bool
$c/= :: forall a. Eq a => Rectangle a -> Rectangle a -> Bool
== :: Rectangle a -> Rectangle a -> Bool
$c== :: forall a. Eq a => Rectangle a -> Rectangle a -> Bool
Eq, a -> Rectangle b -> Rectangle a
(a -> b) -> Rectangle a -> Rectangle b
(forall a b. (a -> b) -> Rectangle a -> Rectangle b)
-> (forall a b. a -> Rectangle b -> Rectangle a)
-> Functor Rectangle
forall a b. a -> Rectangle b -> Rectangle a
forall a b. (a -> b) -> Rectangle a -> Rectangle b
forall (f :: Type -> Type).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Rectangle b -> Rectangle a
$c<$ :: forall a b. a -> Rectangle b -> Rectangle a
fmap :: (a -> b) -> Rectangle a -> Rectangle b
$cfmap :: forall a b. (a -> b) -> Rectangle a -> Rectangle b
Functor, (forall x. Rectangle a -> Rep (Rectangle a) x)
-> (forall x. Rep (Rectangle a) x -> Rectangle a)
-> Generic (Rectangle a)
forall x. Rep (Rectangle a) x -> Rectangle a
forall x. Rectangle a -> Rep (Rectangle a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Rectangle a) x -> Rectangle a
forall a x. Rectangle a -> Rep (Rectangle a) x
$cto :: forall a x. Rep (Rectangle a) x -> Rectangle a
$cfrom :: forall a x. Rectangle a -> Rep (Rectangle a) x
Generic, Eq (Rectangle a)
Eq (Rectangle a)
-> (Rectangle a -> Rectangle a -> Ordering)
-> (Rectangle a -> Rectangle a -> Bool)
-> (Rectangle a -> Rectangle a -> Bool)
-> (Rectangle a -> Rectangle a -> Bool)
-> (Rectangle a -> Rectangle a -> Bool)
-> (Rectangle a -> Rectangle a -> Rectangle a)
-> (Rectangle a -> Rectangle a -> Rectangle a)
-> Ord (Rectangle a)
Rectangle a -> Rectangle a -> Bool
Rectangle a -> Rectangle a -> Ordering
Rectangle a -> Rectangle a -> Rectangle a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Rectangle a)
forall a. Ord a => Rectangle a -> Rectangle a -> Bool
forall a. Ord a => Rectangle a -> Rectangle a -> Ordering
forall a. Ord a => Rectangle a -> Rectangle a -> Rectangle a
min :: Rectangle a -> Rectangle a -> Rectangle a
$cmin :: forall a. Ord a => Rectangle a -> Rectangle a -> Rectangle a
max :: Rectangle a -> Rectangle a -> Rectangle a
$cmax :: forall a. Ord a => Rectangle a -> Rectangle a -> Rectangle a
>= :: Rectangle a -> Rectangle a -> Bool
$c>= :: forall a. Ord a => Rectangle a -> Rectangle a -> Bool
> :: Rectangle a -> Rectangle a -> Bool
$c> :: forall a. Ord a => Rectangle a -> Rectangle a -> Bool
<= :: Rectangle a -> Rectangle a -> Bool
$c<= :: forall a. Ord a => Rectangle a -> Rectangle a -> Bool
< :: Rectangle a -> Rectangle a -> Bool
$c< :: forall a. Ord a => Rectangle a -> Rectangle a -> Bool
compare :: Rectangle a -> Rectangle a -> Ordering
$ccompare :: forall a. Ord a => Rectangle a -> Rectangle a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Rectangle a)
Ord, ReadPrec [Rectangle a]
ReadPrec (Rectangle a)
Int -> ReadS (Rectangle a)
ReadS [Rectangle a]
(Int -> ReadS (Rectangle a))
-> ReadS [Rectangle a]
-> ReadPrec (Rectangle a)
-> ReadPrec [Rectangle a]
-> Read (Rectangle a)
forall a. Read a => ReadPrec [Rectangle a]
forall a. Read a => ReadPrec (Rectangle a)
forall a. Read a => Int -> ReadS (Rectangle a)
forall a. Read a => ReadS [Rectangle a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rectangle a]
$creadListPrec :: forall a. Read a => ReadPrec [Rectangle a]
readPrec :: ReadPrec (Rectangle a)
$creadPrec :: forall a. Read a => ReadPrec (Rectangle a)
readList :: ReadS [Rectangle a]
$creadList :: forall a. Read a => ReadS [Rectangle a]
readsPrec :: Int -> ReadS (Rectangle a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Rectangle a)
Read, Int -> Rectangle a -> ShowS
[Rectangle a] -> ShowS
Rectangle a -> String
(Int -> Rectangle a -> ShowS)
-> (Rectangle a -> String)
-> ([Rectangle a] -> ShowS)
-> Show (Rectangle a)
forall a. Show a => Int -> Rectangle a -> ShowS
forall a. Show a => [Rectangle a] -> ShowS
forall a. Show a => Rectangle a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rectangle a] -> ShowS
$cshowList :: forall a. Show a => [Rectangle a] -> ShowS
show :: Rectangle a -> String
$cshow :: forall a. Show a => Rectangle a -> String
showsPrec :: Int -> Rectangle a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Rectangle a -> ShowS
Show, Typeable)
instance Storable a => Storable (Rectangle a) where
sizeOf :: Rectangle a -> Int
sizeOf ~(Rectangle Point V2 a
o V2 a
s) = Point V2 a -> Int
forall a. Storable a => a -> Int
sizeOf Point V2 a
o Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V2 a -> Int
forall a. Storable a => a -> Int
sizeOf V2 a
s
alignment :: Rectangle a -> Int
alignment Rectangle a
_ = a -> Int
forall a. Storable a => a -> Int
alignment (a
forall a. HasCallStack => a
undefined :: a)
peek :: Ptr (Rectangle a) -> IO (Rectangle a)
peek Ptr (Rectangle a)
ptr = do
Point V2 a
o <- Ptr (Point V2 a) -> IO (Point V2 a)
forall a. Storable a => Ptr a -> IO a
peek (Ptr (Rectangle a) -> Ptr (Point V2 a)
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle a)
ptr)
V2 a
s <- Ptr (V2 a) -> IO (V2 a)
forall a. Storable a => Ptr a -> IO a
peek (Ptr Any -> Ptr (V2 a)
forall a b. Ptr a -> Ptr b
castPtr (Ptr (Rectangle a)
ptr Ptr (Rectangle a) -> Int -> Ptr Any
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Point V2 a -> Int
forall a. Storable a => a -> Int
sizeOf Point V2 a
o))
Rectangle a -> IO (Rectangle a)
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Point V2 a -> V2 a -> Rectangle a
forall a. Point V2 a -> V2 a -> Rectangle a
Rectangle Point V2 a
o V2 a
s)
poke :: Ptr (Rectangle a) -> Rectangle a -> IO ()
poke Ptr (Rectangle a)
ptr (Rectangle Point V2 a
o V2 a
s) = do
Ptr (Point V2 a) -> Point V2 a -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr (Rectangle a) -> Ptr (Point V2 a)
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle a)
ptr) Point V2 a
o
Ptr (V2 a) -> V2 a -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Any -> Ptr (V2 a)
forall a b. Ptr a -> Ptr b
castPtr (Ptr (Rectangle a)
ptr Ptr (Rectangle a) -> Int -> Ptr Any
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Point V2 a -> Int
forall a. Storable a => a -> Int
sizeOf Point V2 a
o)) V2 a
s
data Surface = Surface (Ptr Raw.Surface) (Maybe (MSV.IOVector Word8))
deriving (Typeable)
unmanagedSurface :: Ptr Raw.Surface -> Surface
unmanagedSurface :: Ptr Surface -> Surface
unmanagedSurface Ptr Surface
s = Ptr Surface -> Maybe (IOVector Word8) -> Surface
Surface Ptr Surface
s Maybe (IOVector Word8)
forall a. Maybe a
Nothing
managedSurface :: MSV.IOVector Word8 -> Ptr Raw.Surface -> Surface
managedSurface :: IOVector Word8 -> Ptr Surface -> Surface
managedSurface IOVector Word8
p Ptr Surface
s = Ptr Surface -> Maybe (IOVector Word8) -> Surface
Surface Ptr Surface
s (IOVector Word8 -> Maybe (IOVector Word8)
forall a. a -> Maybe a
Just IOVector Word8
p)
newtype Texture = Texture Raw.Texture
deriving (Texture -> Texture -> Bool
(Texture -> Texture -> Bool)
-> (Texture -> Texture -> Bool) -> Eq Texture
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Texture -> Texture -> Bool
$c/= :: Texture -> Texture -> Bool
== :: Texture -> Texture -> Bool
$c== :: Texture -> Texture -> Bool
Eq, Typeable)
drawRect :: MonadIO m
=> Renderer
-> Maybe (Rectangle CInt)
-> m ()
drawRect :: Renderer -> Maybe (Rectangle CInt) -> m ()
drawRect (Renderer Renderer
r) Maybe (Rectangle CInt)
rect = IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.drawRect" Text
"SDL_RenderDrawRect" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
rect (Renderer -> Ptr Rect -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> m CInt
Raw.renderDrawRect Renderer
r (Ptr Rect -> IO CInt)
-> (Ptr (Rectangle CInt) -> Ptr Rect)
-> Ptr (Rectangle CInt)
-> IO CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr)
drawRects :: MonadIO m => Renderer -> SV.Vector (Rectangle CInt) -> m ()
drawRects :: Renderer -> Vector (Rectangle CInt) -> m ()
drawRects (Renderer Renderer
r) Vector (Rectangle CInt)
rects = IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.drawRects" Text
"SDL_RenderDrawRects" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Vector (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => Vector a -> (Ptr a -> IO b) -> IO b
SV.unsafeWith Vector (Rectangle CInt)
rects ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
rp ->
Renderer -> Ptr Rect -> CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> CInt -> m CInt
Raw.renderDrawRects Renderer
r
(Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
rp)
(Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector (Rectangle CInt) -> Int
forall a. Storable a => Vector a -> Int
SV.length Vector (Rectangle CInt)
rects))
fillRect ::
MonadIO m
=> Renderer
-> Maybe (Rectangle CInt)
-> m ()
fillRect :: Renderer -> Maybe (Rectangle CInt) -> m ()
fillRect (Renderer Renderer
r) Maybe (Rectangle CInt)
rect =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.fillRect" Text
"SDL_RenderFillRect" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
case Maybe (Rectangle CInt)
rect of
Maybe (Rectangle CInt)
Nothing -> Renderer -> Ptr Rect -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> m CInt
Raw.renderFillRect Renderer
r Ptr Rect
forall a. Ptr a
nullPtr
Just (Rectangle (P (V2 CInt
x CInt
y)) (V2 CInt
w CInt
h)) -> Renderer -> CInt -> CInt -> CInt -> CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> CInt -> CInt -> CInt -> CInt -> m CInt
Raw.renderFillRectEx Renderer
r CInt
x CInt
y CInt
w CInt
h
{-# INLINE fillRect #-}
fillRects :: MonadIO m => Renderer -> SV.Vector (Rectangle CInt) -> m ()
fillRects :: Renderer -> Vector (Rectangle CInt) -> m ()
fillRects (Renderer Renderer
r) Vector (Rectangle CInt)
rects = IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.fillRects" Text
"SDL_RenderFillRects" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Vector (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => Vector a -> (Ptr a -> IO b) -> IO b
SV.unsafeWith Vector (Rectangle CInt)
rects ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
rp ->
Renderer -> Ptr Rect -> CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> CInt -> m CInt
Raw.renderFillRects Renderer
r
(Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
rp)
(Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector (Rectangle CInt) -> Int
forall a. Storable a => Vector a -> Int
SV.length Vector (Rectangle CInt)
rects))
clear :: (Functor m, MonadIO m) => Renderer -> m ()
clear :: Renderer -> m ()
clear (Renderer Renderer
r) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.clear" Text
"SDL_RenderClear" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> m CInt
forall (m :: Type -> Type). MonadIO m => Renderer -> m CInt
Raw.renderClear Renderer
r
{-# INLINE clear #-}
rendererScale :: Renderer -> StateVar (V2 CFloat)
rendererScale :: Renderer -> StateVar (V2 CFloat)
rendererScale (Renderer Renderer
r) = IO (V2 CFloat) -> (V2 CFloat -> IO ()) -> StateVar (V2 CFloat)
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (V2 CFloat)
renderGetScale V2 CFloat -> IO ()
forall (m :: Type -> Type). MonadIO m => V2 CFloat -> m ()
renderSetScale
where
renderSetScale :: V2 CFloat -> m ()
renderSetScale (V2 CFloat
x CFloat
y) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.renderSetScale" Text
"SDL_RenderSetScale" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> CFloat -> CFloat -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> CFloat -> CFloat -> m CInt
Raw.renderSetScale Renderer
r CFloat
x CFloat
y
renderGetScale :: IO (V2 CFloat)
renderGetScale = IO (V2 CFloat) -> IO (V2 CFloat)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (V2 CFloat) -> IO (V2 CFloat))
-> IO (V2 CFloat) -> IO (V2 CFloat)
forall a b. (a -> b) -> a -> b
$
(Ptr CFloat -> IO (V2 CFloat)) -> IO (V2 CFloat)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CFloat -> IO (V2 CFloat)) -> IO (V2 CFloat))
-> (Ptr CFloat -> IO (V2 CFloat)) -> IO (V2 CFloat)
forall a b. (a -> b) -> a -> b
$ \Ptr CFloat
w ->
(Ptr CFloat -> IO (V2 CFloat)) -> IO (V2 CFloat)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CFloat -> IO (V2 CFloat)) -> IO (V2 CFloat))
-> (Ptr CFloat -> IO (V2 CFloat)) -> IO (V2 CFloat)
forall a b. (a -> b) -> a -> b
$ \Ptr CFloat
h -> do
Renderer -> Ptr CFloat -> Ptr CFloat -> IO ()
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr CFloat -> Ptr CFloat -> m ()
Raw.renderGetScale Renderer
r Ptr CFloat
w Ptr CFloat
h
CFloat -> CFloat -> V2 CFloat
forall a. a -> a -> V2 a
V2 (CFloat -> CFloat -> V2 CFloat)
-> IO CFloat -> IO (CFloat -> V2 CFloat)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek Ptr CFloat
w IO (CFloat -> V2 CFloat) -> IO CFloat -> IO (V2 CFloat)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek Ptr CFloat
h
rendererClipRect :: Renderer -> StateVar (Maybe (Rectangle CInt))
rendererClipRect :: Renderer -> StateVar (Maybe (Rectangle CInt))
rendererClipRect (Renderer Renderer
r) = IO (Maybe (Rectangle CInt))
-> (Maybe (Rectangle CInt) -> IO ())
-> StateVar (Maybe (Rectangle CInt))
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (Maybe (Rectangle CInt))
renderGetClipRect Maybe (Rectangle CInt) -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Storable a) =>
Maybe a -> m ()
renderSetClipRect
where
renderGetClipRect :: IO (Maybe (Rectangle CInt))
renderGetClipRect = IO (Maybe (Rectangle CInt)) -> IO (Maybe (Rectangle CInt))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (Rectangle CInt)) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)) -> IO (Maybe (Rectangle CInt))
forall a b. (a -> b) -> a -> b
$
(Ptr Rect -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Rect -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)))
-> (Ptr Rect -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. (a -> b) -> a -> b
$ \Ptr Rect
rPtr -> do
Renderer -> Ptr Rect -> IO ()
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> m ()
Raw.renderGetClipRect Renderer
r Ptr Rect
rPtr
(Ptr (Rectangle CInt) -> IO (Rectangle CInt))
-> Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt))
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek Ptr (Rectangle CInt) -> IO (Rectangle CInt)
forall a. Storable a => Ptr a -> IO a
peek (Ptr Rect -> Ptr (Rectangle CInt)
forall a b. Ptr a -> Ptr b
castPtr Ptr Rect
rPtr)
renderSetClipRect :: Maybe a -> m ()
renderSetClipRect Maybe a
rect =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.renderSetClipRect" Text
"SDL_RenderSetClipRect" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(a -> (Ptr a -> IO CInt) -> IO CInt)
-> Maybe a -> (Ptr a -> IO CInt) -> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith a -> (Ptr a -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe a
rect ((Ptr a -> IO CInt) -> IO CInt) -> (Ptr a -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Renderer -> Ptr Rect -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> m CInt
Raw.renderSetClipRect Renderer
r (Ptr Rect -> IO CInt) -> (Ptr a -> Ptr Rect) -> Ptr a -> IO CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr
rendererViewport :: Renderer -> StateVar (Maybe (Rectangle CInt))
rendererViewport :: Renderer -> StateVar (Maybe (Rectangle CInt))
rendererViewport (Renderer Renderer
r) = IO (Maybe (Rectangle CInt))
-> (Maybe (Rectangle CInt) -> IO ())
-> StateVar (Maybe (Rectangle CInt))
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (Maybe (Rectangle CInt))
renderGetViewport Maybe (Rectangle CInt) -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Storable a) =>
Maybe a -> m ()
renderSetViewport
where
renderGetViewport :: IO (Maybe (Rectangle CInt))
renderGetViewport = IO (Maybe (Rectangle CInt)) -> IO (Maybe (Rectangle CInt))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (Rectangle CInt)) -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)) -> IO (Maybe (Rectangle CInt))
forall a b. (a -> b) -> a -> b
$
(Ptr Rect -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Rect -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt)))
-> (Ptr Rect -> IO (Maybe (Rectangle CInt)))
-> IO (Maybe (Rectangle CInt))
forall a b. (a -> b) -> a -> b
$ \Ptr Rect
rect -> do
Renderer -> Ptr Rect -> IO ()
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> m ()
Raw.renderGetViewport Renderer
r Ptr Rect
rect
(Ptr (Rectangle CInt) -> IO (Rectangle CInt))
-> Ptr (Rectangle CInt) -> IO (Maybe (Rectangle CInt))
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek Ptr (Rectangle CInt) -> IO (Rectangle CInt)
forall a. Storable a => Ptr a -> IO a
peek (Ptr Rect -> Ptr (Rectangle CInt)
forall a b. Ptr a -> Ptr b
castPtr Ptr Rect
rect)
renderSetViewport :: Maybe a -> m ()
renderSetViewport Maybe a
rect =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.renderSetViewport" Text
"SDL_RenderSetViewport" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(a -> (Ptr a -> IO CInt) -> IO CInt)
-> Maybe a -> (Ptr a -> IO CInt) -> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith a -> (Ptr a -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe a
rect ((Ptr a -> IO CInt) -> IO CInt) -> (Ptr a -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Renderer -> Ptr Rect -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Rect -> m CInt
Raw.renderSetViewport Renderer
r (Ptr Rect -> IO CInt) -> (Ptr a -> Ptr Rect) -> Ptr a -> IO CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr
present :: MonadIO m => Renderer -> m ()
present :: Renderer -> m ()
present (Renderer Renderer
r) = Renderer -> m ()
forall (m :: Type -> Type). MonadIO m => Renderer -> m ()
Raw.renderPresent Renderer
r
copy :: MonadIO m
=> Renderer
-> Texture
-> Maybe (Rectangle CInt)
-> Maybe (Rectangle CInt)
-> m ()
copy :: Renderer
-> Texture
-> Maybe (Rectangle CInt)
-> Maybe (Rectangle CInt)
-> m ()
copy (Renderer Renderer
r) (Texture Renderer
t) Maybe (Rectangle CInt)
srcRect Maybe (Rectangle CInt)
dstRect =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.copy" Text
"SDL_RenderCopy" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
srcRect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
src ->
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
dstRect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
dst ->
Renderer -> Renderer -> Ptr Rect -> Ptr Rect -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Renderer -> Ptr Rect -> Ptr Rect -> m CInt
Raw.renderCopy Renderer
r Renderer
t (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
src) (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
dst)
copyEx :: MonadIO m
=> Renderer
-> Texture
-> Maybe (Rectangle CInt)
-> Maybe (Rectangle CInt)
-> CDouble
-> Maybe (Point V2 CInt)
-> V2 Bool
-> m ()
copyEx :: Renderer
-> Texture
-> Maybe (Rectangle CInt)
-> Maybe (Rectangle CInt)
-> CDouble
-> Maybe (Point V2 CInt)
-> V2 Bool
-> m ()
copyEx (Renderer Renderer
r) (Texture Renderer
t) Maybe (Rectangle CInt)
srcRect Maybe (Rectangle CInt)
dstRect CDouble
theta Maybe (Point V2 CInt)
center V2 Bool
flips =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.copyEx" Text
"SDL_RenderCopyEx" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
srcRect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
src ->
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
dstRect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
dst ->
(Point V2 CInt -> (Ptr (Point V2 CInt) -> IO CInt) -> IO CInt)
-> Maybe (Point V2 CInt)
-> (Ptr (Point V2 CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Point V2 CInt -> (Ptr (Point V2 CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Point V2 CInt)
center ((Ptr (Point V2 CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Point V2 CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Point V2 CInt)
c ->
Renderer
-> Renderer
-> Ptr Rect
-> Ptr Rect
-> CDouble
-> Ptr Point
-> Word32
-> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer
-> Renderer
-> Ptr Rect
-> Ptr Rect
-> CDouble
-> Ptr Point
-> Word32
-> m CInt
Raw.renderCopyEx Renderer
r Renderer
t (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
src) (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
dst) CDouble
theta (Ptr (Point V2 CInt) -> Ptr Point
forall a b. Ptr a -> Ptr b
castPtr Ptr (Point V2 CInt)
c)
(case V2 Bool
flips of
V2 Bool
x Bool
y -> (if Bool
x then Word32
Raw.SDL_FLIP_HORIZONTAL else Word32
0) Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.|.
(if Bool
y then Word32
Raw.SDL_FLIP_VERTICAL else Word32
0))
#ifdef RECENT_ISH
copyExF :: MonadIO m
=> Renderer
-> Texture
-> Maybe (Rectangle CInt)
-> Maybe (Rectangle CFloat)
-> CDouble
-> Maybe (Point V2 CFloat)
-> V2 Bool
-> m ()
copyExF (Renderer r) (Texture t) srcRect dstRect theta center flips =
liftIO $
throwIfNeg_ "SDL.Video.copyExF" "SDL_RenderCopyExF" $
maybeWith with srcRect $ \src ->
maybeWith with dstRect $ \dst ->
maybeWith with center $ \c ->
Raw.renderCopyExF r t (castPtr src) (castPtr dst) theta (castPtr c)
(case flips of
V2 x y -> (if x then Raw.SDL_FLIP_HORIZONTAL else 0) .|.
(if y then Raw.SDL_FLIP_VERTICAL else 0))
#endif
drawLine :: (Functor m,MonadIO m)
=> Renderer
-> Point V2 CInt
-> Point V2 CInt
-> m ()
drawLine :: Renderer -> Point V2 CInt -> Point V2 CInt -> m ()
drawLine (Renderer Renderer
r) (P (V2 CInt
x CInt
y)) (P (V2 CInt
x' CInt
y')) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.drawLine" Text
"SDL_RenderDrawLine" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> CInt -> CInt -> CInt -> CInt -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> CInt -> CInt -> CInt -> CInt -> m CInt
Raw.renderDrawLine Renderer
r CInt
x CInt
y CInt
x' CInt
y'
drawLines :: MonadIO m
=> Renderer
-> SV.Vector (Point V2 CInt)
-> m ()
drawLines :: Renderer -> Vector (Point V2 CInt) -> m ()
drawLines (Renderer Renderer
r) Vector (Point V2 CInt)
points =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.drawLines" Text
"SDL_RenderDrawLines" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Vector (Point V2 CInt)
-> (Ptr (Point V2 CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => Vector a -> (Ptr a -> IO b) -> IO b
SV.unsafeWith Vector (Point V2 CInt)
points ((Ptr (Point V2 CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Point V2 CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Point V2 CInt)
cp ->
Renderer -> Ptr Point -> CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Point -> CInt -> m CInt
Raw.renderDrawLines Renderer
r
(Ptr (Point V2 CInt) -> Ptr Point
forall a b. Ptr a -> Ptr b
castPtr Ptr (Point V2 CInt)
cp)
(Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector (Point V2 CInt) -> Int
forall a. Storable a => Vector a -> Int
SV.length Vector (Point V2 CInt)
points))
drawPoint :: (Functor m, MonadIO m) => Renderer -> Point V2 CInt -> m ()
drawPoint :: Renderer -> Point V2 CInt -> m ()
drawPoint (Renderer Renderer
r) (P (V2 CInt
x CInt
y)) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.drawPoint" Text
"SDL_RenderDrawPoint" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> CInt -> CInt -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> CInt -> CInt -> m CInt
Raw.renderDrawPoint Renderer
r CInt
x CInt
y
drawPoints :: MonadIO m => Renderer -> SV.Vector (Point V2 CInt) -> m ()
drawPoints :: Renderer -> Vector (Point V2 CInt) -> m ()
drawPoints (Renderer Renderer
r) Vector (Point V2 CInt)
points =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.drawPoints" Text
"SDL_RenderDrawPoints" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Vector (Point V2 CInt)
-> (Ptr (Point V2 CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => Vector a -> (Ptr a -> IO b) -> IO b
SV.unsafeWith Vector (Point V2 CInt)
points ((Ptr (Point V2 CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Point V2 CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Point V2 CInt)
cp ->
Renderer -> Ptr Point -> CInt -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Point -> CInt -> m CInt
Raw.renderDrawPoints Renderer
r
(Ptr (Point V2 CInt) -> Ptr Point
forall a b. Ptr a -> Ptr b
castPtr Ptr (Point V2 CInt)
cp)
(Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector (Point V2 CInt) -> Int
forall a. Storable a => Vector a -> Int
SV.length Vector (Point V2 CInt)
points))
convertSurface :: (Functor m,MonadIO m)
=> Surface
-> SurfacePixelFormat
-> m Surface
convertSurface :: Surface -> SurfacePixelFormat -> m Surface
convertSurface (Surface Ptr Surface
s Maybe (IOVector Word8)
_) (SurfacePixelFormat Ptr PixelFormat
fmt) =
(Ptr Surface -> Surface) -> m (Ptr Surface) -> m Surface
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr Surface -> Surface
unmanagedSurface (m (Ptr Surface) -> m Surface) -> m (Ptr Surface) -> m Surface
forall a b. (a -> b) -> a -> b
$
Text -> Text -> m (Ptr Surface) -> m (Ptr Surface)
forall (m :: Type -> Type) a.
MonadIO m =>
Text -> Text -> m (Ptr a) -> m (Ptr a)
throwIfNull Text
"SDL.Video.Renderer.convertSurface" Text
"SDL_ConvertSurface" (m (Ptr Surface) -> m (Ptr Surface))
-> m (Ptr Surface) -> m (Ptr Surface)
forall a b. (a -> b) -> a -> b
$
Ptr Surface -> Ptr PixelFormat -> Word32 -> m (Ptr Surface)
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr PixelFormat -> Word32 -> m (Ptr Surface)
Raw.convertSurface Ptr Surface
s Ptr PixelFormat
fmt Word32
0
surfaceBlitScaled :: MonadIO m
=> Surface
-> Maybe (Rectangle CInt)
-> Surface
-> Maybe (Rectangle CInt)
-> m ()
surfaceBlitScaled :: Surface
-> Maybe (Rectangle CInt)
-> Surface
-> Maybe (Rectangle CInt)
-> m ()
surfaceBlitScaled (Surface Ptr Surface
src Maybe (IOVector Word8)
_) Maybe (Rectangle CInt)
srcRect (Surface Ptr Surface
dst Maybe (IOVector Word8)
_) Maybe (Rectangle CInt)
dstRect =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.blitSurface" Text
"SDL_BlitSurface" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
srcRect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
srcPtr ->
(Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> Maybe (Rectangle CInt)
-> (Ptr (Rectangle CInt) -> IO CInt)
-> IO CInt
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith Rectangle CInt -> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe (Rectangle CInt)
dstRect ((Ptr (Rectangle CInt) -> IO CInt) -> IO CInt)
-> (Ptr (Rectangle CInt) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr (Rectangle CInt)
dstPtr ->
Ptr Surface -> Ptr Rect -> Ptr Surface -> Ptr Rect -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr Rect -> Ptr Surface -> Ptr Rect -> m CInt
Raw.blitScaled Ptr Surface
src (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
srcPtr) Ptr Surface
dst (Ptr (Rectangle CInt) -> Ptr Rect
forall a b. Ptr a -> Ptr b
castPtr Ptr (Rectangle CInt)
dstPtr)
surfaceColorKey :: Surface -> StateVar (Maybe (V4 Word8))
surfaceColorKey :: Surface -> StateVar (Maybe (V4 Word8))
surfaceColorKey (Surface Ptr Surface
s Maybe (IOVector Word8)
_) = IO (Maybe (V4 Word8))
-> (Maybe (V4 Word8) -> IO ()) -> StateVar (Maybe (V4 Word8))
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (Maybe (V4 Word8))
getColorKey Maybe (V4 Word8) -> IO ()
forall (m :: Type -> Type). MonadIO m => Maybe (V4 Word8) -> m ()
setColorKey
where
getColorKey :: IO (Maybe (V4 Word8))
getColorKey =
IO (Maybe (V4 Word8)) -> IO (Maybe (V4 Word8))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (V4 Word8)) -> IO (Maybe (V4 Word8)))
-> IO (Maybe (V4 Word8)) -> IO (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$
(Ptr Word32 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8)))
-> (Ptr Word32 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
keyPtr -> do
CInt
ret <- Ptr Surface -> Ptr Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr Word32 -> m CInt
Raw.getColorKey Ptr Surface
s Ptr Word32
keyPtr
if CInt
ret CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== -CInt
1
then Maybe (V4 Word8) -> IO (Maybe (V4 Word8))
forall (m :: Type -> Type) a. Monad m => a -> m a
return Maybe (V4 Word8)
forall a. Maybe a
Nothing
else do Ptr PixelFormat
format <- IO (Ptr PixelFormat) -> IO (Ptr PixelFormat)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Surface -> Ptr PixelFormat
Raw.surfaceFormat (Surface -> Ptr PixelFormat) -> IO Surface -> IO (Ptr PixelFormat)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Surface -> IO Surface
forall a. Storable a => Ptr a -> IO a
peek Ptr Surface
s)
Word32
mapped <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
keyPtr
(Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8)))
-> (Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
r ->
(Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8)))
-> (Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
g ->
(Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8)))
-> (Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
b ->
(Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8)))
-> (Ptr Word8 -> IO (Maybe (V4 Word8))) -> IO (Maybe (V4 Word8))
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
a ->
do Word32
-> Ptr PixelFormat
-> Ptr Word8
-> Ptr Word8
-> Ptr Word8
-> Ptr Word8
-> IO ()
forall (m :: Type -> Type).
MonadIO m =>
Word32
-> Ptr PixelFormat
-> Ptr Word8
-> Ptr Word8
-> Ptr Word8
-> Ptr Word8
-> m ()
Raw.getRGBA Word32
mapped Ptr PixelFormat
format Ptr Word8
r Ptr Word8
g Ptr Word8
b Ptr Word8
a
V4 Word8 -> Maybe (V4 Word8)
forall a. a -> Maybe a
Just (V4 Word8 -> Maybe (V4 Word8))
-> IO (V4 Word8) -> IO (Maybe (V4 Word8))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (Word8 -> Word8 -> Word8 -> Word8 -> V4 Word8
forall a. a -> a -> a -> a -> V4 a
V4 (Word8 -> Word8 -> Word8 -> Word8 -> V4 Word8)
-> IO Word8 -> IO (Word8 -> Word8 -> Word8 -> V4 Word8)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
r IO (Word8 -> Word8 -> Word8 -> V4 Word8)
-> IO Word8 -> IO (Word8 -> Word8 -> V4 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
g IO (Word8 -> Word8 -> V4 Word8)
-> IO Word8 -> IO (Word8 -> V4 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
b IO (Word8 -> V4 Word8) -> IO Word8 -> IO (V4 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
a)
setColorKey :: Maybe (V4 Word8) -> m ()
setColorKey Maybe (V4 Word8)
key =
IO () -> m ()
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.setColorKey" Text
"SDL_SetColorKey" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
case Maybe (V4 Word8)
key of
Maybe (V4 Word8)
Nothing ->
(Ptr Word32 -> IO CInt) -> IO CInt
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO CInt) -> IO CInt)
-> (Ptr Word32 -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
keyPtr -> do
CInt
ret <- Ptr Surface -> Ptr Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr Word32 -> m CInt
Raw.getColorKey Ptr Surface
s Ptr Word32
keyPtr
if CInt
ret CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== -CInt
1
then CInt -> IO CInt
forall (m :: Type -> Type) a. Monad m => a -> m a
return CInt
0
else do Word32
key' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
keyPtr
Ptr Surface -> CInt -> Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> CInt -> Word32 -> m CInt
Raw.setColorKey Ptr Surface
s CInt
0 Word32
key'
Just (V4 Word8
r Word8
g Word8
b Word8
a) -> do
Ptr PixelFormat
format <- IO (Ptr PixelFormat) -> IO (Ptr PixelFormat)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Surface -> Ptr PixelFormat
Raw.surfaceFormat (Surface -> Ptr PixelFormat) -> IO Surface -> IO (Ptr PixelFormat)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Surface -> IO Surface
forall a. Storable a => Ptr a -> IO a
peek Ptr Surface
s)
Ptr PixelFormat -> Word8 -> Word8 -> Word8 -> Word8 -> IO Word32
forall (m :: Type -> Type).
MonadIO m =>
Ptr PixelFormat -> Word8 -> Word8 -> Word8 -> Word8 -> m Word32
Raw.mapRGBA Ptr PixelFormat
format Word8
r Word8
g Word8
b Word8
a IO Word32 -> (Word32 -> IO CInt) -> IO CInt
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr Surface -> CInt -> Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> CInt -> Word32 -> m CInt
Raw.setColorKey Ptr Surface
s CInt
1
textureColorMod :: Texture -> StateVar (V3 Word8)
textureColorMod :: Texture -> StateVar (V3 Word8)
textureColorMod (Texture Renderer
t) = IO (V3 Word8) -> (V3 Word8 -> IO ()) -> StateVar (V3 Word8)
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (V3 Word8)
getTextureColorMod V3 Word8 -> IO ()
forall (m :: Type -> Type). MonadIO m => V3 Word8 -> m ()
setTextureColorMod
where
getTextureColorMod :: IO (V3 Word8)
getTextureColorMod = IO (V3 Word8) -> IO (V3 Word8)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (V3 Word8) -> IO (V3 Word8)) -> IO (V3 Word8) -> IO (V3 Word8)
forall a b. (a -> b) -> a -> b
$
(Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8))
-> (Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
r ->
(Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8))
-> (Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
g ->
(Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8))
-> (Ptr Word8 -> IO (V3 Word8)) -> IO (V3 Word8)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
b -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.getTextureColorMod" Text
"SDL_GetTextureColorMod" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> m CInt
Raw.getTextureColorMod Renderer
t Ptr Word8
r Ptr Word8
g Ptr Word8
b
Word8 -> Word8 -> Word8 -> V3 Word8
forall a. a -> a -> a -> V3 a
V3 (Word8 -> Word8 -> Word8 -> V3 Word8)
-> IO Word8 -> IO (Word8 -> Word8 -> V3 Word8)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
r IO (Word8 -> Word8 -> V3 Word8)
-> IO Word8 -> IO (Word8 -> V3 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
g IO (Word8 -> V3 Word8) -> IO Word8 -> IO (V3 Word8)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
b
setTextureColorMod :: V3 Word8 -> m ()
setTextureColorMod (V3 Word8
r Word8
g Word8
b) =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.setTextureColorMod" Text
"SDL_SetTextureColorMod" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Word8 -> Word8 -> Word8 -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Word8 -> Word8 -> Word8 -> m CInt
Raw.setTextureColorMod Renderer
t Word8
r Word8
g Word8
b
data PixelFormat
= Unknown !Word32
| Index1LSB
| Index1MSB
| Index4LSB
| Index4MSB
| Index8
| RGB332
| RGB444
| RGB555
| BGR555
| ARGB4444
| RGBA4444
| ABGR4444
| BGRA4444
| ARGB1555
| RGBA5551
| ABGR1555
| BGRA5551
| RGB565
| BGR565
| RGB24
| BGR24
| RGB888
| RGBX8888
| BGR888
| BGRX8888
| ARGB8888
| RGBA8888
| ABGR8888
| BGRA8888
| ARGB2101010
| YV12
| IYUV
| YUY2
| UYVY
| YVYU
deriving (Typeable PixelFormat
DataType
Constr
Typeable PixelFormat
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PixelFormat -> c PixelFormat)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PixelFormat)
-> (PixelFormat -> Constr)
-> (PixelFormat -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PixelFormat))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PixelFormat))
-> ((forall b. Data b => b -> b) -> PixelFormat -> PixelFormat)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r)
-> (forall u. (forall d. Data d => d -> u) -> PixelFormat -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> PixelFormat -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat)
-> Data PixelFormat
PixelFormat -> DataType
PixelFormat -> Constr
(forall b. Data b => b -> b) -> PixelFormat -> PixelFormat
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PixelFormat -> c PixelFormat
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PixelFormat
forall a.
Typeable a
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PixelFormat -> u
forall u. (forall d. Data d => d -> u) -> PixelFormat -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r
forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PixelFormat
forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PixelFormat -> c PixelFormat
forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PixelFormat)
forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PixelFormat)
$cYVYU :: Constr
$cUYVY :: Constr
$cYUY2 :: Constr
$cIYUV :: Constr
$cYV12 :: Constr
$cARGB2101010 :: Constr
$cBGRA8888 :: Constr
$cABGR8888 :: Constr
$cRGBA8888 :: Constr
$cARGB8888 :: Constr
$cBGRX8888 :: Constr
$cBGR888 :: Constr
$cRGBX8888 :: Constr
$cRGB888 :: Constr
$cBGR24 :: Constr
$cRGB24 :: Constr
$cBGR565 :: Constr
$cRGB565 :: Constr
$cBGRA5551 :: Constr
$cABGR1555 :: Constr
$cRGBA5551 :: Constr
$cARGB1555 :: Constr
$cBGRA4444 :: Constr
$cABGR4444 :: Constr
$cRGBA4444 :: Constr
$cARGB4444 :: Constr
$cBGR555 :: Constr
$cRGB555 :: Constr
$cRGB444 :: Constr
$cRGB332 :: Constr
$cIndex8 :: Constr
$cIndex4MSB :: Constr
$cIndex4LSB :: Constr
$cIndex1MSB :: Constr
$cIndex1LSB :: Constr
$cUnknown :: Constr
$tPixelFormat :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
$cgmapMo :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
gmapMp :: (forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
$cgmapMp :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
gmapM :: (forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat
gmapQi :: Int -> (forall d. Data d => d -> u) -> PixelFormat -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PixelFormat -> u
gmapQ :: (forall d. Data d => d -> u) -> PixelFormat -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PixelFormat -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PixelFormat -> r
gmapT :: (forall b. Data b => b -> b) -> PixelFormat -> PixelFormat
$cgmapT :: (forall b. Data b => b -> b) -> PixelFormat -> PixelFormat
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PixelFormat)
$cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PixelFormat)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c PixelFormat)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PixelFormat)
dataTypeOf :: PixelFormat -> DataType
$cdataTypeOf :: PixelFormat -> DataType
toConstr :: PixelFormat -> Constr
$ctoConstr :: PixelFormat -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PixelFormat
$cgunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PixelFormat
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PixelFormat -> c PixelFormat
$cgfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PixelFormat -> c PixelFormat
$cp1Data :: Typeable PixelFormat
Data, PixelFormat -> PixelFormat -> Bool
(PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool) -> Eq PixelFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PixelFormat -> PixelFormat -> Bool
$c/= :: PixelFormat -> PixelFormat -> Bool
== :: PixelFormat -> PixelFormat -> Bool
$c== :: PixelFormat -> PixelFormat -> Bool
Eq, (forall x. PixelFormat -> Rep PixelFormat x)
-> (forall x. Rep PixelFormat x -> PixelFormat)
-> Generic PixelFormat
forall x. Rep PixelFormat x -> PixelFormat
forall x. PixelFormat -> Rep PixelFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PixelFormat x -> PixelFormat
$cfrom :: forall x. PixelFormat -> Rep PixelFormat x
Generic, Eq PixelFormat
Eq PixelFormat
-> (PixelFormat -> PixelFormat -> Ordering)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> PixelFormat)
-> (PixelFormat -> PixelFormat -> PixelFormat)
-> Ord PixelFormat
PixelFormat -> PixelFormat -> Bool
PixelFormat -> PixelFormat -> Ordering
PixelFormat -> PixelFormat -> PixelFormat
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PixelFormat -> PixelFormat -> PixelFormat
$cmin :: PixelFormat -> PixelFormat -> PixelFormat
max :: PixelFormat -> PixelFormat -> PixelFormat
$cmax :: PixelFormat -> PixelFormat -> PixelFormat
>= :: PixelFormat -> PixelFormat -> Bool
$c>= :: PixelFormat -> PixelFormat -> Bool
> :: PixelFormat -> PixelFormat -> Bool
$c> :: PixelFormat -> PixelFormat -> Bool
<= :: PixelFormat -> PixelFormat -> Bool
$c<= :: PixelFormat -> PixelFormat -> Bool
< :: PixelFormat -> PixelFormat -> Bool
$c< :: PixelFormat -> PixelFormat -> Bool
compare :: PixelFormat -> PixelFormat -> Ordering
$ccompare :: PixelFormat -> PixelFormat -> Ordering
$cp1Ord :: Eq PixelFormat
Ord, ReadPrec [PixelFormat]
ReadPrec PixelFormat
Int -> ReadS PixelFormat
ReadS [PixelFormat]
(Int -> ReadS PixelFormat)
-> ReadS [PixelFormat]
-> ReadPrec PixelFormat
-> ReadPrec [PixelFormat]
-> Read PixelFormat
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PixelFormat]
$creadListPrec :: ReadPrec [PixelFormat]
readPrec :: ReadPrec PixelFormat
$creadPrec :: ReadPrec PixelFormat
readList :: ReadS [PixelFormat]
$creadList :: ReadS [PixelFormat]
readsPrec :: Int -> ReadS PixelFormat
$creadsPrec :: Int -> ReadS PixelFormat
Read, Int -> PixelFormat -> ShowS
[PixelFormat] -> ShowS
PixelFormat -> String
(Int -> PixelFormat -> ShowS)
-> (PixelFormat -> String)
-> ([PixelFormat] -> ShowS)
-> Show PixelFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PixelFormat] -> ShowS
$cshowList :: [PixelFormat] -> ShowS
show :: PixelFormat -> String
$cshow :: PixelFormat -> String
showsPrec :: Int -> PixelFormat -> ShowS
$cshowsPrec :: Int -> PixelFormat -> ShowS
Show, Typeable)
instance FromNumber PixelFormat Word32 where
fromNumber :: Word32 -> PixelFormat
fromNumber Word32
n' = case Word32
n' of
Word32
Raw.SDL_PIXELFORMAT_INDEX1LSB -> PixelFormat
Index1LSB
Word32
Raw.SDL_PIXELFORMAT_INDEX1MSB -> PixelFormat
Index1MSB
Word32
Raw.SDL_PIXELFORMAT_INDEX4LSB -> PixelFormat
Index4LSB
Word32
Raw.SDL_PIXELFORMAT_INDEX4MSB -> PixelFormat
Index4MSB
Word32
Raw.SDL_PIXELFORMAT_INDEX8 -> PixelFormat
Index8
Word32
Raw.SDL_PIXELFORMAT_RGB332 -> PixelFormat
RGB332
Word32
Raw.SDL_PIXELFORMAT_RGB444 -> PixelFormat
RGB444
Word32
Raw.SDL_PIXELFORMAT_RGB555 -> PixelFormat
RGB555
Word32
Raw.SDL_PIXELFORMAT_BGR555 -> PixelFormat
BGR555
Word32
Raw.SDL_PIXELFORMAT_ARGB4444 -> PixelFormat
ARGB4444
Word32
Raw.SDL_PIXELFORMAT_RGBA4444 -> PixelFormat
RGBA4444
Word32
Raw.SDL_PIXELFORMAT_ABGR4444 -> PixelFormat
ABGR4444
Word32
Raw.SDL_PIXELFORMAT_BGRA4444 -> PixelFormat
BGRA4444
Word32
Raw.SDL_PIXELFORMAT_ARGB1555 -> PixelFormat
ARGB1555
Word32
Raw.SDL_PIXELFORMAT_RGBA5551 -> PixelFormat
RGBA5551
Word32
Raw.SDL_PIXELFORMAT_ABGR1555 -> PixelFormat
ABGR1555
Word32
Raw.SDL_PIXELFORMAT_BGRA5551 -> PixelFormat
BGRA5551
Word32
Raw.SDL_PIXELFORMAT_RGB565 -> PixelFormat
RGB565
Word32
Raw.SDL_PIXELFORMAT_BGR565 -> PixelFormat
BGR565
Word32
Raw.SDL_PIXELFORMAT_RGB24 -> PixelFormat
RGB24
Word32
Raw.SDL_PIXELFORMAT_BGR24 -> PixelFormat
BGR24
Word32
Raw.SDL_PIXELFORMAT_RGB888 -> PixelFormat
RGB888
Word32
Raw.SDL_PIXELFORMAT_RGBX8888 -> PixelFormat
RGBX8888
Word32
Raw.SDL_PIXELFORMAT_BGR888 -> PixelFormat
BGR888
Word32
Raw.SDL_PIXELFORMAT_BGRX8888 -> PixelFormat
BGRX8888
Word32
Raw.SDL_PIXELFORMAT_ARGB8888 -> PixelFormat
ARGB8888
Word32
Raw.SDL_PIXELFORMAT_RGBA8888 -> PixelFormat
RGBA8888
Word32
Raw.SDL_PIXELFORMAT_ABGR8888 -> PixelFormat
ABGR8888
Word32
Raw.SDL_PIXELFORMAT_BGRA8888 -> PixelFormat
BGRA8888
Word32
Raw.SDL_PIXELFORMAT_ARGB2101010 -> PixelFormat
ARGB2101010
Word32
Raw.SDL_PIXELFORMAT_YV12 -> PixelFormat
YV12
Word32
Raw.SDL_PIXELFORMAT_IYUV -> PixelFormat
IYUV
Word32
Raw.SDL_PIXELFORMAT_YUY2 -> PixelFormat
YUY2
Word32
Raw.SDL_PIXELFORMAT_UYVY -> PixelFormat
UYVY
Word32
Raw.SDL_PIXELFORMAT_YVYU -> PixelFormat
YVYU
Word32
Raw.SDL_PIXELFORMAT_UNKNOWN -> Word32 -> PixelFormat
Unknown Word32
n'
Word32
_ -> Word32 -> PixelFormat
Unknown Word32
n'
instance ToNumber PixelFormat Word32 where
toNumber :: PixelFormat -> Word32
toNumber PixelFormat
pf = case PixelFormat
pf of
Unknown Word32
_ -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_UNKNOWN
PixelFormat
Index1LSB -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_INDEX1LSB
PixelFormat
Index1MSB -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_INDEX1MSB
PixelFormat
Index4LSB -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_INDEX4LSB
PixelFormat
Index4MSB -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_INDEX4MSB
PixelFormat
Index8 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_INDEX8
PixelFormat
RGB332 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGB332
PixelFormat
RGB444 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGB444
PixelFormat
RGB555 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGB555
PixelFormat
BGR555 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGR555
PixelFormat
ARGB4444 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_ARGB4444
PixelFormat
RGBA4444 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGBA4444
PixelFormat
ABGR4444 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_ABGR4444
PixelFormat
BGRA4444 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGRA4444
PixelFormat
ARGB1555 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_ARGB1555
PixelFormat
RGBA5551 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGBA5551
PixelFormat
ABGR1555 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_ABGR1555
PixelFormat
BGRA5551 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGRA5551
PixelFormat
RGB565 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGB565
PixelFormat
BGR565 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGR565
PixelFormat
RGB24 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGB24
PixelFormat
BGR24 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGR24
PixelFormat
RGB888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGB888
PixelFormat
RGBX8888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGBX8888
PixelFormat
BGR888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGR888
PixelFormat
BGRX8888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGRX8888
PixelFormat
ARGB8888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_ARGB8888
PixelFormat
RGBA8888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_RGBA8888
PixelFormat
ABGR8888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_ABGR8888
PixelFormat
BGRA8888 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_BGRA8888
PixelFormat
ARGB2101010 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_ARGB2101010
PixelFormat
YV12 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_YV12
PixelFormat
IYUV -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_IYUV
PixelFormat
YUY2 -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_YUY2
PixelFormat
UYVY -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_UYVY
PixelFormat
YVYU -> Word32
forall a. (Eq a, Num a) => a
Raw.SDL_PIXELFORMAT_YVYU
data RendererType
= UnacceleratedRenderer
| AcceleratedRenderer
| AcceleratedVSyncRenderer
| SoftwareRenderer
deriving (RendererType
RendererType -> RendererType -> Bounded RendererType
forall a. a -> a -> Bounded a
maxBound :: RendererType
$cmaxBound :: RendererType
minBound :: RendererType
$cminBound :: RendererType
Bounded, Typeable RendererType
DataType
Constr
Typeable RendererType
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererType -> c RendererType)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererType)
-> (RendererType -> Constr)
-> (RendererType -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RendererType))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererType))
-> ((forall b. Data b => b -> b) -> RendererType -> RendererType)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r)
-> (forall u. (forall d. Data d => d -> u) -> RendererType -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> RendererType -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType)
-> Data RendererType
RendererType -> DataType
RendererType -> Constr
(forall b. Data b => b -> b) -> RendererType -> RendererType
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererType -> c RendererType
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererType
forall a.
Typeable a
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RendererType -> u
forall u. (forall d. Data d => d -> u) -> RendererType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r
forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType
forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType
forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererType
forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererType -> c RendererType
forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RendererType)
forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererType)
$cSoftwareRenderer :: Constr
$cAcceleratedVSyncRenderer :: Constr
$cAcceleratedRenderer :: Constr
$cUnacceleratedRenderer :: Constr
$tRendererType :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> RendererType -> m RendererType
$cgmapMo :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType
gmapMp :: (forall d. Data d => d -> m d) -> RendererType -> m RendererType
$cgmapMp :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType
gmapM :: (forall d. Data d => d -> m d) -> RendererType -> m RendererType
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> RendererType -> m RendererType
gmapQi :: Int -> (forall d. Data d => d -> u) -> RendererType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RendererType -> u
gmapQ :: (forall d. Data d => d -> u) -> RendererType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RendererType -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererType -> r
gmapT :: (forall b. Data b => b -> b) -> RendererType -> RendererType
$cgmapT :: (forall b. Data b => b -> b) -> RendererType -> RendererType
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererType)
$cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererType)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RendererType)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RendererType)
dataTypeOf :: RendererType -> DataType
$cdataTypeOf :: RendererType -> DataType
toConstr :: RendererType -> Constr
$ctoConstr :: RendererType -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererType
$cgunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererType
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererType -> c RendererType
$cgfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererType -> c RendererType
$cp1Data :: Typeable RendererType
Data, Int -> RendererType
RendererType -> Int
RendererType -> [RendererType]
RendererType -> RendererType
RendererType -> RendererType -> [RendererType]
RendererType -> RendererType -> RendererType -> [RendererType]
(RendererType -> RendererType)
-> (RendererType -> RendererType)
-> (Int -> RendererType)
-> (RendererType -> Int)
-> (RendererType -> [RendererType])
-> (RendererType -> RendererType -> [RendererType])
-> (RendererType -> RendererType -> [RendererType])
-> (RendererType -> RendererType -> RendererType -> [RendererType])
-> Enum RendererType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: RendererType -> RendererType -> RendererType -> [RendererType]
$cenumFromThenTo :: RendererType -> RendererType -> RendererType -> [RendererType]
enumFromTo :: RendererType -> RendererType -> [RendererType]
$cenumFromTo :: RendererType -> RendererType -> [RendererType]
enumFromThen :: RendererType -> RendererType -> [RendererType]
$cenumFromThen :: RendererType -> RendererType -> [RendererType]
enumFrom :: RendererType -> [RendererType]
$cenumFrom :: RendererType -> [RendererType]
fromEnum :: RendererType -> Int
$cfromEnum :: RendererType -> Int
toEnum :: Int -> RendererType
$ctoEnum :: Int -> RendererType
pred :: RendererType -> RendererType
$cpred :: RendererType -> RendererType
succ :: RendererType -> RendererType
$csucc :: RendererType -> RendererType
Enum, RendererType -> RendererType -> Bool
(RendererType -> RendererType -> Bool)
-> (RendererType -> RendererType -> Bool) -> Eq RendererType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RendererType -> RendererType -> Bool
$c/= :: RendererType -> RendererType -> Bool
== :: RendererType -> RendererType -> Bool
$c== :: RendererType -> RendererType -> Bool
Eq, (forall x. RendererType -> Rep RendererType x)
-> (forall x. Rep RendererType x -> RendererType)
-> Generic RendererType
forall x. Rep RendererType x -> RendererType
forall x. RendererType -> Rep RendererType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RendererType x -> RendererType
$cfrom :: forall x. RendererType -> Rep RendererType x
Generic, Eq RendererType
Eq RendererType
-> (RendererType -> RendererType -> Ordering)
-> (RendererType -> RendererType -> Bool)
-> (RendererType -> RendererType -> Bool)
-> (RendererType -> RendererType -> Bool)
-> (RendererType -> RendererType -> Bool)
-> (RendererType -> RendererType -> RendererType)
-> (RendererType -> RendererType -> RendererType)
-> Ord RendererType
RendererType -> RendererType -> Bool
RendererType -> RendererType -> Ordering
RendererType -> RendererType -> RendererType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RendererType -> RendererType -> RendererType
$cmin :: RendererType -> RendererType -> RendererType
max :: RendererType -> RendererType -> RendererType
$cmax :: RendererType -> RendererType -> RendererType
>= :: RendererType -> RendererType -> Bool
$c>= :: RendererType -> RendererType -> Bool
> :: RendererType -> RendererType -> Bool
$c> :: RendererType -> RendererType -> Bool
<= :: RendererType -> RendererType -> Bool
$c<= :: RendererType -> RendererType -> Bool
< :: RendererType -> RendererType -> Bool
$c< :: RendererType -> RendererType -> Bool
compare :: RendererType -> RendererType -> Ordering
$ccompare :: RendererType -> RendererType -> Ordering
$cp1Ord :: Eq RendererType
Ord, ReadPrec [RendererType]
ReadPrec RendererType
Int -> ReadS RendererType
ReadS [RendererType]
(Int -> ReadS RendererType)
-> ReadS [RendererType]
-> ReadPrec RendererType
-> ReadPrec [RendererType]
-> Read RendererType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RendererType]
$creadListPrec :: ReadPrec [RendererType]
readPrec :: ReadPrec RendererType
$creadPrec :: ReadPrec RendererType
readList :: ReadS [RendererType]
$creadList :: ReadS [RendererType]
readsPrec :: Int -> ReadS RendererType
$creadsPrec :: Int -> ReadS RendererType
Read, Int -> RendererType -> ShowS
[RendererType] -> ShowS
RendererType -> String
(Int -> RendererType -> ShowS)
-> (RendererType -> String)
-> ([RendererType] -> ShowS)
-> Show RendererType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RendererType] -> ShowS
$cshowList :: [RendererType] -> ShowS
show :: RendererType -> String
$cshow :: RendererType -> String
showsPrec :: Int -> RendererType -> ShowS
$cshowsPrec :: Int -> RendererType -> ShowS
Show, Typeable)
data RendererConfig = RendererConfig
{ RendererConfig -> RendererType
rendererType :: RendererType
, RendererConfig -> Bool
rendererTargetTexture :: Bool
} deriving (Typeable RendererConfig
DataType
Constr
Typeable RendererConfig
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererConfig -> c RendererConfig)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererConfig)
-> (RendererConfig -> Constr)
-> (RendererConfig -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RendererConfig))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererConfig))
-> ((forall b. Data b => b -> b)
-> RendererConfig -> RendererConfig)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r)
-> (forall u.
(forall d. Data d => d -> u) -> RendererConfig -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> RendererConfig -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig)
-> Data RendererConfig
RendererConfig -> DataType
RendererConfig -> Constr
(forall b. Data b => b -> b) -> RendererConfig -> RendererConfig
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererConfig -> c RendererConfig
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererConfig
forall a.
Typeable a
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> RendererConfig -> u
forall u. (forall d. Data d => d -> u) -> RendererConfig -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r
forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererConfig
forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererConfig -> c RendererConfig
forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RendererConfig)
forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererConfig)
$cRendererConfig :: Constr
$tRendererConfig :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
$cgmapMo :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
gmapMp :: (forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
$cgmapMp :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
gmapM :: (forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d)
-> RendererConfig -> m RendererConfig
gmapQi :: Int -> (forall d. Data d => d -> u) -> RendererConfig -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> RendererConfig -> u
gmapQ :: (forall d. Data d => d -> u) -> RendererConfig -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RendererConfig -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RendererConfig -> r
gmapT :: (forall b. Data b => b -> b) -> RendererConfig -> RendererConfig
$cgmapT :: (forall b. Data b => b -> b) -> RendererConfig -> RendererConfig
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererConfig)
$cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RendererConfig)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RendererConfig)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RendererConfig)
dataTypeOf :: RendererConfig -> DataType
$cdataTypeOf :: RendererConfig -> DataType
toConstr :: RendererConfig -> Constr
$ctoConstr :: RendererConfig -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererConfig
$cgunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RendererConfig
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererConfig -> c RendererConfig
$cgfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RendererConfig -> c RendererConfig
$cp1Data :: Typeable RendererConfig
Data, RendererConfig -> RendererConfig -> Bool
(RendererConfig -> RendererConfig -> Bool)
-> (RendererConfig -> RendererConfig -> Bool) -> Eq RendererConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RendererConfig -> RendererConfig -> Bool
$c/= :: RendererConfig -> RendererConfig -> Bool
== :: RendererConfig -> RendererConfig -> Bool
$c== :: RendererConfig -> RendererConfig -> Bool
Eq, (forall x. RendererConfig -> Rep RendererConfig x)
-> (forall x. Rep RendererConfig x -> RendererConfig)
-> Generic RendererConfig
forall x. Rep RendererConfig x -> RendererConfig
forall x. RendererConfig -> Rep RendererConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RendererConfig x -> RendererConfig
$cfrom :: forall x. RendererConfig -> Rep RendererConfig x
Generic, Eq RendererConfig
Eq RendererConfig
-> (RendererConfig -> RendererConfig -> Ordering)
-> (RendererConfig -> RendererConfig -> Bool)
-> (RendererConfig -> RendererConfig -> Bool)
-> (RendererConfig -> RendererConfig -> Bool)
-> (RendererConfig -> RendererConfig -> Bool)
-> (RendererConfig -> RendererConfig -> RendererConfig)
-> (RendererConfig -> RendererConfig -> RendererConfig)
-> Ord RendererConfig
RendererConfig -> RendererConfig -> Bool
RendererConfig -> RendererConfig -> Ordering
RendererConfig -> RendererConfig -> RendererConfig
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RendererConfig -> RendererConfig -> RendererConfig
$cmin :: RendererConfig -> RendererConfig -> RendererConfig
max :: RendererConfig -> RendererConfig -> RendererConfig
$cmax :: RendererConfig -> RendererConfig -> RendererConfig
>= :: RendererConfig -> RendererConfig -> Bool
$c>= :: RendererConfig -> RendererConfig -> Bool
> :: RendererConfig -> RendererConfig -> Bool
$c> :: RendererConfig -> RendererConfig -> Bool
<= :: RendererConfig -> RendererConfig -> Bool
$c<= :: RendererConfig -> RendererConfig -> Bool
< :: RendererConfig -> RendererConfig -> Bool
$c< :: RendererConfig -> RendererConfig -> Bool
compare :: RendererConfig -> RendererConfig -> Ordering
$ccompare :: RendererConfig -> RendererConfig -> Ordering
$cp1Ord :: Eq RendererConfig
Ord, ReadPrec [RendererConfig]
ReadPrec RendererConfig
Int -> ReadS RendererConfig
ReadS [RendererConfig]
(Int -> ReadS RendererConfig)
-> ReadS [RendererConfig]
-> ReadPrec RendererConfig
-> ReadPrec [RendererConfig]
-> Read RendererConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RendererConfig]
$creadListPrec :: ReadPrec [RendererConfig]
readPrec :: ReadPrec RendererConfig
$creadPrec :: ReadPrec RendererConfig
readList :: ReadS [RendererConfig]
$creadList :: ReadS [RendererConfig]
readsPrec :: Int -> ReadS RendererConfig
$creadsPrec :: Int -> ReadS RendererConfig
Read, Int -> RendererConfig -> ShowS
[RendererConfig] -> ShowS
RendererConfig -> String
(Int -> RendererConfig -> ShowS)
-> (RendererConfig -> String)
-> ([RendererConfig] -> ShowS)
-> Show RendererConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RendererConfig] -> ShowS
$cshowList :: [RendererConfig] -> ShowS
show :: RendererConfig -> String
$cshow :: RendererConfig -> String
showsPrec :: Int -> RendererConfig -> ShowS
$cshowsPrec :: Int -> RendererConfig -> ShowS
Show, Typeable)
instance FromNumber RendererConfig Word32 where
fromNumber :: Word32 -> RendererConfig
fromNumber Word32
n = RendererConfig :: RendererType -> Bool -> RendererConfig
RendererConfig
{ rendererType :: RendererType
rendererType = Bool -> Bool -> Bool -> RendererType
rendererType'
(Word32
n Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.&. Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_SOFTWARE Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word32
0)
(Word32
n Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.&. Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_ACCELERATED Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word32
0)
(Word32
n Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.&. Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_PRESENTVSYNC Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word32
0)
, rendererTargetTexture :: Bool
rendererTargetTexture = Word32
n Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.&. Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_TARGETTEXTURE Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word32
0
}
where
rendererType' :: Bool -> Bool -> Bool -> RendererType
rendererType' Bool
s Bool
a Bool
v | Bool
s = RendererType
SoftwareRenderer
| Bool
a Bool -> Bool -> Bool
&& Bool
v = RendererType
AcceleratedVSyncRenderer
| Bool
a = RendererType
AcceleratedRenderer
| Bool
otherwise = RendererType
UnacceleratedRenderer
instance ToNumber RendererConfig Word32 where
toNumber :: RendererConfig -> Word32
toNumber RendererConfig
config = (Word32 -> Word32 -> Word32) -> Word32 -> [Word32] -> Word32
forall (t :: Type -> Type) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
(.|.) Word32
0
[ if Bool
isSoftware then Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_SOFTWARE else Word32
0
, if Bool -> Bool
not Bool
isSoftware then Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_ACCELERATED else Word32
0
, if RendererConfig -> RendererType
rendererType RendererConfig
config RendererType -> RendererType -> Bool
forall a. Eq a => a -> a -> Bool
== RendererType
AcceleratedVSyncRenderer then Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_PRESENTVSYNC else Word32
0
, if RendererConfig -> Bool
rendererTargetTexture RendererConfig
config then Word32
forall a. (Eq a, Num a) => a
Raw.SDL_RENDERER_TARGETTEXTURE else Word32
0
]
where
isSoftware :: Bool
isSoftware = RendererConfig -> RendererType
rendererType RendererConfig
config RendererType -> RendererType -> Bool
forall a. Eq a => a -> a -> Bool
== RendererType
SoftwareRenderer
defaultRenderer :: RendererConfig
defaultRenderer :: RendererConfig
defaultRenderer = RendererConfig :: RendererType -> Bool -> RendererConfig
RendererConfig
{ rendererType :: RendererType
rendererType = RendererType
AcceleratedRenderer
, rendererTargetTexture :: Bool
rendererTargetTexture = Bool
False
}
data RendererInfo = RendererInfo
{ RendererInfo -> Text
rendererInfoName :: Text
, RendererInfo -> RendererConfig
rendererInfoFlags :: RendererConfig
, RendererInfo -> Word32
rendererInfoNumTextureFormats :: Word32
, RendererInfo -> [PixelFormat]
rendererInfoTextureFormats :: [PixelFormat]
, RendererInfo -> CInt
rendererInfoMaxTextureWidth :: CInt
, RendererInfo -> CInt
rendererInfoMaxTextureHeight :: CInt
} deriving (RendererInfo -> RendererInfo -> Bool
(RendererInfo -> RendererInfo -> Bool)
-> (RendererInfo -> RendererInfo -> Bool) -> Eq RendererInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RendererInfo -> RendererInfo -> Bool
$c/= :: RendererInfo -> RendererInfo -> Bool
== :: RendererInfo -> RendererInfo -> Bool
$c== :: RendererInfo -> RendererInfo -> Bool
Eq, (forall x. RendererInfo -> Rep RendererInfo x)
-> (forall x. Rep RendererInfo x -> RendererInfo)
-> Generic RendererInfo
forall x. Rep RendererInfo x -> RendererInfo
forall x. RendererInfo -> Rep RendererInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RendererInfo x -> RendererInfo
$cfrom :: forall x. RendererInfo -> Rep RendererInfo x
Generic, Eq RendererInfo
Eq RendererInfo
-> (RendererInfo -> RendererInfo -> Ordering)
-> (RendererInfo -> RendererInfo -> Bool)
-> (RendererInfo -> RendererInfo -> Bool)
-> (RendererInfo -> RendererInfo -> Bool)
-> (RendererInfo -> RendererInfo -> Bool)
-> (RendererInfo -> RendererInfo -> RendererInfo)
-> (RendererInfo -> RendererInfo -> RendererInfo)
-> Ord RendererInfo
RendererInfo -> RendererInfo -> Bool
RendererInfo -> RendererInfo -> Ordering
RendererInfo -> RendererInfo -> RendererInfo
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RendererInfo -> RendererInfo -> RendererInfo
$cmin :: RendererInfo -> RendererInfo -> RendererInfo
max :: RendererInfo -> RendererInfo -> RendererInfo
$cmax :: RendererInfo -> RendererInfo -> RendererInfo
>= :: RendererInfo -> RendererInfo -> Bool
$c>= :: RendererInfo -> RendererInfo -> Bool
> :: RendererInfo -> RendererInfo -> Bool
$c> :: RendererInfo -> RendererInfo -> Bool
<= :: RendererInfo -> RendererInfo -> Bool
$c<= :: RendererInfo -> RendererInfo -> Bool
< :: RendererInfo -> RendererInfo -> Bool
$c< :: RendererInfo -> RendererInfo -> Bool
compare :: RendererInfo -> RendererInfo -> Ordering
$ccompare :: RendererInfo -> RendererInfo -> Ordering
$cp1Ord :: Eq RendererInfo
Ord, ReadPrec [RendererInfo]
ReadPrec RendererInfo
Int -> ReadS RendererInfo
ReadS [RendererInfo]
(Int -> ReadS RendererInfo)
-> ReadS [RendererInfo]
-> ReadPrec RendererInfo
-> ReadPrec [RendererInfo]
-> Read RendererInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RendererInfo]
$creadListPrec :: ReadPrec [RendererInfo]
readPrec :: ReadPrec RendererInfo
$creadPrec :: ReadPrec RendererInfo
readList :: ReadS [RendererInfo]
$creadList :: ReadS [RendererInfo]
readsPrec :: Int -> ReadS RendererInfo
$creadsPrec :: Int -> ReadS RendererInfo
Read, Int -> RendererInfo -> ShowS
[RendererInfo] -> ShowS
RendererInfo -> String
(Int -> RendererInfo -> ShowS)
-> (RendererInfo -> String)
-> ([RendererInfo] -> ShowS)
-> Show RendererInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RendererInfo] -> ShowS
$cshowList :: [RendererInfo] -> ShowS
show :: RendererInfo -> String
$cshow :: RendererInfo -> String
showsPrec :: Int -> RendererInfo -> ShowS
$cshowsPrec :: Int -> RendererInfo -> ShowS
Show, Typeable)
fromRawRendererInfo :: MonadIO m => Raw.RendererInfo -> m RendererInfo
fromRawRendererInfo :: RendererInfo -> m RendererInfo
fromRawRendererInfo (Raw.RendererInfo CString
name Word32
flgs Word32
ntf [Word32]
tfs CInt
mtw CInt
mth) = IO RendererInfo -> m RendererInfo
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO RendererInfo -> m RendererInfo)
-> IO RendererInfo -> m RendererInfo
forall a b. (a -> b) -> a -> b
$ do
Text
name' <- ByteString -> Text
Text.decodeUtf8 (ByteString -> Text) -> IO ByteString -> IO Text
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> CString -> IO ByteString
BS.packCString CString
name
RendererInfo -> IO RendererInfo
forall (m :: Type -> Type) a. Monad m => a -> m a
return (RendererInfo -> IO RendererInfo)
-> RendererInfo -> IO RendererInfo
forall a b. (a -> b) -> a -> b
$ Text
-> RendererConfig
-> Word32
-> [PixelFormat]
-> CInt
-> CInt
-> RendererInfo
RendererInfo Text
name' (Word32 -> RendererConfig
forall a b. FromNumber a b => b -> a
fromNumber Word32
flgs) Word32
ntf ((Word32 -> PixelFormat) -> [Word32] -> [PixelFormat]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Word32 -> PixelFormat
forall a b. FromNumber a b => b -> a
fromNumber [Word32]
tfs) CInt
mtw CInt
mth
getRendererInfo :: MonadIO m => Renderer -> m RendererInfo
getRendererInfo :: Renderer -> m RendererInfo
getRendererInfo (Renderer Renderer
renderer) = IO RendererInfo -> m RendererInfo
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO RendererInfo -> m RendererInfo)
-> IO RendererInfo -> m RendererInfo
forall a b. (a -> b) -> a -> b
$
(Ptr RendererInfo -> IO RendererInfo) -> IO RendererInfo
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr RendererInfo -> IO RendererInfo) -> IO RendererInfo)
-> (Ptr RendererInfo -> IO RendererInfo) -> IO RendererInfo
forall a b. (a -> b) -> a -> b
$ \Ptr RendererInfo
rptr -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"getRendererInfo" Text
"SDL_GetRendererInfo" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr RendererInfo -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr RendererInfo -> m CInt
Raw.getRendererInfo Renderer
renderer Ptr RendererInfo
rptr
Ptr RendererInfo -> IO RendererInfo
forall a. Storable a => Ptr a -> IO a
peek Ptr RendererInfo
rptr IO RendererInfo
-> (RendererInfo -> IO RendererInfo) -> IO RendererInfo
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= RendererInfo -> IO RendererInfo
forall (m :: Type -> Type).
MonadIO m =>
RendererInfo -> m RendererInfo
fromRawRendererInfo
getRenderDriverInfo :: MonadIO m => m [RendererInfo]
getRenderDriverInfo :: m [RendererInfo]
getRenderDriverInfo = IO [RendererInfo] -> m [RendererInfo]
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO [RendererInfo] -> m [RendererInfo])
-> IO [RendererInfo] -> m [RendererInfo]
forall a b. (a -> b) -> a -> b
$ do
CInt
count <- IO CInt
forall (m :: Type -> Type). MonadIO m => m CInt
Raw.getNumRenderDrivers
(CInt -> IO RendererInfo) -> [CInt] -> IO [RendererInfo]
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse CInt -> IO RendererInfo
go [CInt
0..CInt
countCInt -> CInt -> CInt
forall a. Num a => a -> a -> a
-CInt
1]
where
go :: CInt -> IO RendererInfo
go CInt
idx = (Ptr RendererInfo -> IO RendererInfo) -> IO RendererInfo
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr RendererInfo -> IO RendererInfo) -> IO RendererInfo)
-> (Ptr RendererInfo -> IO RendererInfo) -> IO RendererInfo
forall a b. (a -> b) -> a -> b
$ \Ptr RendererInfo
rptr -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"getRenderDriverInfo" Text
"SDL_GetRenderDriverInfo" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
CInt -> Ptr RendererInfo -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
CInt -> Ptr RendererInfo -> m CInt
Raw.getRenderDriverInfo CInt
idx Ptr RendererInfo
rptr
Ptr RendererInfo -> IO RendererInfo
forall a. Storable a => Ptr a -> IO a
peek Ptr RendererInfo
rptr IO RendererInfo
-> (RendererInfo -> IO RendererInfo) -> IO RendererInfo
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= RendererInfo -> IO RendererInfo
forall (m :: Type -> Type).
MonadIO m =>
RendererInfo -> m RendererInfo
fromRawRendererInfo
textureAlphaMod :: Texture -> StateVar Word8
textureAlphaMod :: Texture -> StateVar Word8
textureAlphaMod (Texture Renderer
t) = IO Word8 -> (Word8 -> IO ()) -> StateVar Word8
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO Word8
getTextureAlphaMod Word8 -> IO ()
forall (m :: Type -> Type). MonadIO m => Word8 -> m ()
setTextureAlphaMod
where
getTextureAlphaMod :: IO Word8
getTextureAlphaMod = IO Word8 -> IO Word8
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Word8 -> IO Word8) -> IO Word8 -> IO Word8
forall a b. (a -> b) -> a -> b
$
(Ptr Word8 -> IO Word8) -> IO Word8
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO Word8) -> IO Word8)
-> (Ptr Word8 -> IO Word8) -> IO Word8
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
x -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.getTextureAlphaMod" Text
"SDL_GetTextureAlphaMod" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr Word8 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Word8 -> m CInt
Raw.getTextureAlphaMod Renderer
t Ptr Word8
x
Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
x
setTextureAlphaMod :: Word8 -> m ()
setTextureAlphaMod Word8
alpha =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.setTextureAlphaMod" Text
"SDL_SetTextureAlphaMod" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Word8 -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Word8 -> m CInt
Raw.setTextureAlphaMod Renderer
t Word8
alpha
textureBlendMode :: Texture -> StateVar BlendMode
textureBlendMode :: Texture -> StateVar BlendMode
textureBlendMode (Texture Renderer
t) = IO BlendMode -> (BlendMode -> IO ()) -> StateVar BlendMode
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO BlendMode
getTextureBlendMode BlendMode -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, ToNumber a Word32) =>
a -> m ()
setTextureBlendMode
where
getTextureBlendMode :: IO BlendMode
getTextureBlendMode = IO BlendMode -> IO BlendMode
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO BlendMode -> IO BlendMode) -> IO BlendMode -> IO BlendMode
forall a b. (a -> b) -> a -> b
$
(Ptr Word32 -> IO BlendMode) -> IO BlendMode
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO BlendMode) -> IO BlendMode)
-> (Ptr Word32 -> IO BlendMode) -> IO BlendMode
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
x -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.getTextureBlendMode" Text
"SDL_GetTextureBlendMode" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Ptr Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr Word32 -> m CInt
Raw.getTextureBlendMode Renderer
t Ptr Word32
x
Word32 -> BlendMode
forall a b. FromNumber a b => b -> a
fromNumber (Word32 -> BlendMode) -> IO Word32 -> IO BlendMode
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
x
setTextureBlendMode :: a -> m ()
setTextureBlendMode a
bm =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.setTextureBlendMode" Text
"SDL_SetTextureBlendMode" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Renderer -> Word32 -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Word32 -> m CInt
Raw.setTextureBlendMode Renderer
t (a -> Word32
forall a b. ToNumber a b => a -> b
toNumber a
bm)
surfaceBlendMode :: Surface -> StateVar BlendMode
surfaceBlendMode :: Surface -> StateVar BlendMode
surfaceBlendMode (Surface Ptr Surface
s Maybe (IOVector Word8)
_) = IO BlendMode -> (BlendMode -> IO ()) -> StateVar BlendMode
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO BlendMode
getSurfaceBlendMode BlendMode -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, ToNumber a Word32) =>
a -> m ()
setSurfaceBlendMode
where
getSurfaceBlendMode :: IO BlendMode
getSurfaceBlendMode = IO BlendMode -> IO BlendMode
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO BlendMode -> IO BlendMode) -> IO BlendMode -> IO BlendMode
forall a b. (a -> b) -> a -> b
$
(Ptr Word32 -> IO BlendMode) -> IO BlendMode
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO BlendMode) -> IO BlendMode)
-> (Ptr Word32 -> IO BlendMode) -> IO BlendMode
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
x -> do
Text -> Text -> IO CInt -> IO ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.getSurfaceBlendMode" Text
"SDL_GetSurfaceBlendMode" (IO CInt -> IO ()) -> IO CInt -> IO ()
forall a b. (a -> b) -> a -> b
$
Ptr Surface -> Ptr Word32 -> IO CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Ptr Word32 -> m CInt
Raw.getSurfaceBlendMode Ptr Surface
s Ptr Word32
x
Word32 -> BlendMode
forall a b. FromNumber a b => b -> a
fromNumber (Word32 -> BlendMode) -> IO Word32 -> IO BlendMode
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
x
setSurfaceBlendMode :: a -> m ()
setSurfaceBlendMode a
bm =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.setSurfaceBlendMode" Text
"SDL_SetSurfaceBlendMode" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
Ptr Surface -> Word32 -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Ptr Surface -> Word32 -> m CInt
Raw.setSurfaceBlendMode Ptr Surface
s (a -> Word32
forall a b. ToNumber a b => a -> b
toNumber a
bm)
rendererRenderTarget :: Renderer -> StateVar (Maybe Texture)
rendererRenderTarget :: Renderer -> StateVar (Maybe Texture)
rendererRenderTarget (Renderer Renderer
r) = IO (Maybe Texture)
-> (Maybe Texture -> IO ()) -> StateVar (Maybe Texture)
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (Maybe Texture)
getRenderTarget Maybe Texture -> IO ()
forall (m :: Type -> Type). MonadIO m => Maybe Texture -> m ()
setRenderTarget
where
getRenderTarget :: IO (Maybe Texture)
getRenderTarget = do
Renderer
t <- Renderer -> IO Renderer
forall (m :: Type -> Type). MonadIO m => Renderer -> m Renderer
Raw.getRenderTarget Renderer
r
Maybe Texture -> IO (Maybe Texture)
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Maybe Texture -> IO (Maybe Texture))
-> Maybe Texture -> IO (Maybe Texture)
forall a b. (a -> b) -> a -> b
$
if Renderer
t Renderer -> Renderer -> Bool
forall a. Eq a => a -> a -> Bool
== Renderer
forall a. Ptr a
nullPtr
then Maybe Texture
forall a. Maybe a
Nothing
else Texture -> Maybe Texture
forall a. a -> Maybe a
Just (Renderer -> Texture
Texture Renderer
t)
setRenderTarget :: Maybe Texture -> m ()
setRenderTarget Maybe Texture
texture =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.Renderer.setRenderTarget" Text
"SDL_SetRenderTarget" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$
case Maybe Texture
texture of
Maybe Texture
Nothing -> Renderer -> Renderer -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Renderer -> m CInt
Raw.setRenderTarget Renderer
r Renderer
forall a. Ptr a
nullPtr
Just (Texture Renderer
t) -> Renderer -> Renderer -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Renderer -> m CInt
Raw.setRenderTarget Renderer
r Renderer
t
rendererLogicalSize :: Renderer -> StateVar (Maybe (V2 CInt))
rendererLogicalSize :: Renderer -> StateVar (Maybe (V2 CInt))
rendererLogicalSize (Renderer Renderer
r) = IO (Maybe (V2 CInt))
-> (Maybe (V2 CInt) -> IO ()) -> StateVar (Maybe (V2 CInt))
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (Maybe (V2 CInt))
renderGetLogicalSize Maybe (V2 CInt) -> IO ()
forall (m :: Type -> Type). MonadIO m => Maybe (V2 CInt) -> m ()
renderSetLogicalSize
where
renderGetLogicalSize :: IO (Maybe (V2 CInt))
renderGetLogicalSize = IO (Maybe (V2 CInt)) -> IO (Maybe (V2 CInt))
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (V2 CInt)) -> IO (Maybe (V2 CInt)))
-> IO (Maybe (V2 CInt)) -> IO (Maybe (V2 CInt))
forall a b. (a -> b) -> a -> b
$
(Ptr CInt -> IO (Maybe (V2 CInt))) -> IO (Maybe (V2 CInt))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Maybe (V2 CInt))) -> IO (Maybe (V2 CInt)))
-> (Ptr CInt -> IO (Maybe (V2 CInt))) -> IO (Maybe (V2 CInt))
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
w -> do
(Ptr CInt -> IO (Maybe (V2 CInt))) -> IO (Maybe (V2 CInt))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Maybe (V2 CInt))) -> IO (Maybe (V2 CInt)))
-> (Ptr CInt -> IO (Maybe (V2 CInt))) -> IO (Maybe (V2 CInt))
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
h -> do
Renderer -> Ptr CInt -> Ptr CInt -> IO ()
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> Ptr CInt -> Ptr CInt -> m ()
Raw.renderGetLogicalSize Renderer
r Ptr CInt
w Ptr CInt
h
V2 CInt
v <- CInt -> CInt -> V2 CInt
forall a. a -> a -> V2 a
V2 (CInt -> CInt -> V2 CInt) -> IO CInt -> IO (CInt -> V2 CInt)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
w IO (CInt -> V2 CInt) -> IO CInt -> IO (V2 CInt)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
h
Maybe (V2 CInt) -> IO (Maybe (V2 CInt))
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Maybe (V2 CInt) -> IO (Maybe (V2 CInt)))
-> Maybe (V2 CInt) -> IO (Maybe (V2 CInt))
forall a b. (a -> b) -> a -> b
$ if V2 CInt
v V2 CInt -> V2 CInt -> Bool
forall a. Eq a => a -> a -> Bool
== V2 CInt
0 then Maybe (V2 CInt)
forall a. Maybe a
Nothing else V2 CInt -> Maybe (V2 CInt)
forall a. a -> Maybe a
Just V2 CInt
v
renderSetLogicalSize :: Maybe (V2 CInt) -> m ()
renderSetLogicalSize Maybe (V2 CInt)
v =
Text -> Text -> m CInt -> m ()
forall (m :: Type -> Type) a.
(MonadIO m, Num a, Ord a) =>
Text -> Text -> m a -> m ()
throwIfNeg_ Text
"SDL.Video.renderSetLogicalSize" Text
"SDL_RenderSetLogicalSize" (m CInt -> m ()) -> m CInt -> m ()
forall a b. (a -> b) -> a -> b
$ do
let (CInt
x,CInt
y) = case Maybe (V2 CInt)
v of Just (V2 vx vy) -> (CInt
vx, CInt
vy)
Maybe (V2 CInt)
Nothing -> (CInt
0,CInt
0)
Renderer -> CInt -> CInt -> m CInt
forall (m :: Type -> Type).
MonadIO m =>
Renderer -> CInt -> CInt -> m CInt
Raw.renderSetLogicalSize Renderer
r CInt
x CInt
y
renderTargetSupported :: (MonadIO m) => Renderer -> m Bool
renderTargetSupported :: Renderer -> m Bool
renderTargetSupported (Renderer Renderer
r) = Renderer -> m Bool
forall (m :: Type -> Type). MonadIO m => Renderer -> m Bool
Raw.renderTargetSupported Renderer
r
pixelFormatToMasks :: (MonadIO m) => PixelFormat -> m (CInt, V4 Word32)
pixelFormatToMasks :: PixelFormat -> m (CInt, V4 Word32)
pixelFormatToMasks PixelFormat
pf = IO (CInt, V4 Word32) -> m (CInt, V4 Word32)
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (CInt, V4 Word32) -> m (CInt, V4 Word32))
-> IO (CInt, V4 Word32) -> m (CInt, V4 Word32)
forall a b. (a -> b) -> a -> b
$
(Ptr CInt -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32))
-> (Ptr CInt -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
bpp ->
(Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32))
-> (Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
r ->
(Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32))
-> (Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
g ->
(Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32))
-> (Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
b ->
(Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32))
-> (Ptr Word32 -> IO (CInt, V4 Word32)) -> IO (CInt, V4 Word32)
forall a b. (a -> b) -> a -> b
$ \Ptr Word32
a -> do
(Bool -> Bool) -> Text -> Text -> IO Bool -> IO ()
forall (m :: Type -> Type) a.
MonadIO m =>
(a -> Bool) -> Text -> Text -> m a -> m ()
throwIf_ Bool -> Bool
not Text
"SDL.Video.pixelFormatEnumToMasks" Text
"SDL_PixelFormatEnumToMasks" (IO Bool -> IO ()) -> IO Bool -> IO ()
forall a b. (a -> b) -> a -> b
$
Word32
-> Ptr CInt
-> Ptr Word32
-> Ptr Word32
-> Ptr Word32
-> Ptr Word32
-> IO Bool
forall (m :: Type -> Type).
MonadIO m =>
Word32
-> Ptr CInt
-> Ptr Word32
-> Ptr Word32
-> Ptr Word32
-> Ptr Word32
-> m Bool
Raw.pixelFormatEnumToMasks (PixelFormat -> Word32
forall a b. ToNumber a b => a -> b
toNumber PixelFormat
pf) Ptr CInt
bpp Ptr Word32
r Ptr Word32
g Ptr Word32
b Ptr Word32
a
CInt -> Word32 -> Word32 -> Word32 -> Word32 -> (CInt, V4 Word32)
forall a a. a -> a -> a -> a -> a -> (a, V4 a)
wrap (CInt -> Word32 -> Word32 -> Word32 -> Word32 -> (CInt, V4 Word32))
-> IO CInt
-> IO (Word32 -> Word32 -> Word32 -> Word32 -> (CInt, V4 Word32))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
bpp IO (Word32 -> Word32 -> Word32 -> Word32 -> (CInt, V4 Word32))
-> IO Word32
-> IO (Word32 -> Word32 -> Word32 -> (CInt, V4 Word32))
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
r IO (Word32 -> Word32 -> Word32 -> (CInt, V4 Word32))
-> IO Word32 -> IO (Word32 -> Word32 -> (CInt, V4 Word32))
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
g IO (Word32 -> Word32 -> (CInt, V4 Word32))
-> IO Word32 -> IO (Word32 -> (CInt, V4 Word32))
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
b IO (Word32 -> (CInt, V4 Word32))
-> IO Word32 -> IO (CInt, V4 Word32)
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
a
where
wrap :: a -> a -> a -> a -> a -> (a, V4 a)
wrap a
bpp a
r a
g a
b a
a = (a
bpp, a -> a -> a -> a -> V4 a
forall a. a -> a -> a -> a -> V4 a
V4 a
r a
g a
b a
a)
masksToPixelFormat :: (MonadIO m) => CInt -> V4 Word32 -> m PixelFormat
masksToPixelFormat :: CInt -> V4 Word32 -> m PixelFormat
masksToPixelFormat CInt
bpp (V4 Word32
r Word32
g Word32
b Word32
a) = IO PixelFormat -> m PixelFormat
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO PixelFormat -> m PixelFormat)
-> IO PixelFormat -> m PixelFormat
forall a b. (a -> b) -> a -> b
$
Word32 -> PixelFormat
forall a b. FromNumber a b => b -> a
fromNumber (Word32 -> PixelFormat) -> IO Word32 -> IO PixelFormat
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> CInt -> Word32 -> Word32 -> Word32 -> Word32 -> IO Word32
forall (m :: Type -> Type).
MonadIO m =>
CInt -> Word32 -> Word32 -> Word32 -> Word32 -> m Word32
Raw.masksToPixelFormatEnum CInt
bpp Word32
r Word32
g Word32
b Word32
a