@@ -47,8 +47,6 @@ public partial class RenderContext : IDisposable
4747 FilterMode = TextureFilterMode . Default
4848 } ;
4949
50- private bool IsAnisotropicFilteringOn = false ;
51-
5250 private static RasterizerState UIRasterizerState
5351 {
5452 get
@@ -121,6 +119,7 @@ internal Rectangle DeviceScissor
121119 }
122120 }
123121
122+ private bool _isAnisotropicFilteringOn ;
124123
125124 public Rectangle Scissor
126125 {
@@ -271,7 +270,7 @@ public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle? s
271270 /// <param name="depth"></param>
272271 public void Draw ( Texture2D texture , Vector2 position , Rectangle ? sourceRectangle , Color color , float rotation , Vector2 scale , float depth = 0.0f )
273272 {
274- SetTextureFiltering ( IsAnisotropicFilteringOn ? TextureFiltering . Anisotropic : TextureFiltering . Nearest ) ;
273+ SetTextureFiltering ( _isAnisotropicFilteringOn ? TextureFiltering . Anisotropic : TextureFiltering . Nearest ) ;
275274 color = CrossEngineStuff . MultiplyColor ( color , Opacity ) ;
276275 scale *= Transform . Scale ;
277276 rotation += Transform . Rotation ;
@@ -455,9 +454,8 @@ public void Begin()
455454 UIRasterizerState ,
456455 null ) ;
457456#elif STRIDE
458- var samplerState = _textureFiltering == TextureFiltering . Nearest ?
459- MyraEnvironment . Game . GraphicsDevice . SamplerStates . PointClamp :
460- MyraEnvironment . Game . GraphicsDevice . SamplerStates . LinearClamp ;
457+ var samplerState = SelectedSamplerState ( ) ;
458+
461459 _renderer . Begin ( MyraEnvironment . Game . GraphicsContext ,
462460 SpriteSortMode . Deferred ,
463461 BlendStates . AlphaBlend ,
@@ -471,6 +469,7 @@ public void Begin()
471469 _beginCalled = true ;
472470 }
473471
472+ #if MONOGAME || FNA
474473 private SamplerState SelectedSamplerState ( )
475474 {
476475 switch ( _textureFiltering )
@@ -485,6 +484,22 @@ private SamplerState SelectedSamplerState()
485484 throw new ArgumentOutOfRangeException ( ) ;
486485 }
487486 }
487+ #elif STRIDE
488+ private SamplerState SelectedSamplerState ( )
489+ {
490+ switch ( _textureFiltering )
491+ {
492+ case TextureFiltering . Nearest :
493+ return MyraEnvironment . Game . GraphicsDevice . SamplerStates . PointClamp ;
494+ case TextureFiltering . Linear :
495+ return MyraEnvironment . Game . GraphicsDevice . SamplerStates . LinearClamp ;
496+ case TextureFiltering . Anisotropic :
497+ return MyraEnvironment . Game . GraphicsDevice . SamplerStates . AnisotropicClamp ;
498+ default :
499+ throw new ArgumentOutOfRangeException ( ) ;
500+ }
501+ }
502+ #endif
488503
489504 public void End ( )
490505 {
@@ -523,7 +538,7 @@ public void Dispose()
523538
524539 public void SetAnisotropicFilteringMode ( bool isAnisotropicFiltering )
525540 {
526- IsAnisotropicFilteringOn = isAnisotropicFiltering ;
541+ _isAnisotropicFilteringOn = isAnisotropicFiltering ;
527542 }
528543 }
529544}
0 commit comments