[.net] [XNA] Texture clamping

Started by
2 comments, last by mitchw 16 years, 3 months ago
Hello When I render my sprite (XNA 2.0 Build 2.0.11128.1, XP SP2) at a resolution 1:1 there's no arctefact, but as soon as there's magnification, there's zome strange texture problem on the bottom & right side of the sprite. I tried to set the following renderstate without success : GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Clamp; GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Clamp; GraphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Linear; In my previous project under OpenGL I solved this problem with : glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); Right now, I can't find any solution...
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
Advertisement
You can try use this code too:
GraphicsDevice.SamplerStates[0].MinFilter = TextureFilter.Linear;
Quote:Original post by Augi
You can try use this code too:
GraphicsDevice.SamplerStates[0].MinFilter = TextureFilter.Linear;


Bad copy/paste of me, I already tried this way too :(
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
If you're using SpriteBatch, be sure to set SpriteSortMode to Immediate, which tells SpriteBatch to set all of it's render states inside of Begin, rather than End. Otherwise, your state changes will get overwritten on End.

SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate,
SaveStateMode.None);

You can refer to this post to see exactly how SpriteBatch modifies the GraphicsDevice.

http://blogs.msdn.com/shawnhar/archive/2006/11/13/spritebatch-and-renderstates.aspx

(Of course had I taken a moment to put 1 and 1 together, SpriteBatch defaults to the behavior you mention)

This topic is closed to new replies.

Advertisement