@@ -118,6 +118,10 @@ module SDL.Video.Renderer
118118 , textureBlendMode
119119 , BlendMode (.. )
120120 , textureColorMod
121+ #ifdef RECENT_ISH
122+ , textureScaleMode
123+ , ScaleMode (.. )
124+ #endif
121125
122126 -- ** Accessing 'Texture' Data
123127 , lockTexture
@@ -1335,6 +1339,51 @@ textureBlendMode (Texture t) = makeStateVar getTextureBlendMode setTextureBlendM
13351339 throwIfNeg_ " SDL.Video.Renderer.setTextureBlendMode" " SDL_SetTextureBlendMode" $
13361340 Raw. setTextureBlendMode t (toNumber bm)
13371341
1342+ #ifdef RECENT_ISH
1343+
1344+ -- | Scale modes used in copy operations
1345+ data ScaleMode
1346+ = ScaleModeNearest
1347+ -- ^ Nearest-neighbor scaling
1348+ | ScaleModeLinear
1349+ -- ^ Linear scaling
1350+ | ScaleModeBest
1351+ -- ^ anisotropic filtering
1352+ deriving (Bounded , Data , Enum , Eq , Generic , Ord , Read , Show , Typeable )
1353+
1354+ instance FromNumber ScaleMode Word32 where
1355+ fromNumber n = case n of
1356+ Raw. SDL_ScaleModeNearest -> ScaleModeNearest
1357+ Raw. SDL_ScaleModeLinear -> ScaleModeLinear
1358+ Raw. SDL_ScaleModeBest -> ScaleModeBest
1359+ _ -> error $ " fromNumber <ScaleMode>: unkonwn scale mode: " ++ (show n)
1360+
1361+ instance ToNumber ScaleMode Word32 where
1362+ toNumber ScaleModeNearest = Raw. SDL_ScaleModeNearest
1363+ toNumber ScaleModeLinear = Raw. SDL_ScaleModeLinear
1364+ toNumber ScaleModeBest = Raw. SDL_ScaleModeBest
1365+
1366+ -- | Get or set the scale mode use for texture scale operations.
1367+ --
1368+ -- This 'StateVar' can be modified using '$=' and the current value retrieved with 'get'.
1369+ --
1370+ -- See @<https://wiki.libsdl.org/SDL2/SDL_GetTextureScaleMode SDL_GetTextureScaleMode>@ and @<https://wiki.libsdl.org/SDL2/SDL_SetTextureScaleMode SDL_SetTextureScaleMode>@
1371+ textureScaleMode :: Texture -> StateVar ScaleMode
1372+ textureScaleMode (Texture t) = makeStateVar getTextureScaleMode setTextureScaleMode
1373+ where
1374+ getTextureScaleMode =
1375+ alloca $ \ x -> do
1376+ throwIfNeg_ " SDL.Video.Renderer.getTextureScaleMode" " SDL_GetTextureScaleMode" $
1377+ Raw. getTextureScaleMode t x
1378+ fromNumber <$> peek x
1379+
1380+ setTextureScaleMode sm =
1381+ throwIfNeg_ " SDL.Video.Renderer.setTextureScaleMode" " SDL_SetTextureScaleMode" $
1382+ Raw. setTextureScaleMode t (toNumber sm)
1383+
1384+ #endif
1385+
1386+
13381387-- | Get or set the blend mode used for blit operations.
13391388--
13401389-- This 'StateVar' can be modified using '$=' and the current value retrieved with 'get'.
0 commit comments