Sign in to follow this  
iliak

[.net] [XNA] Texture clamping

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this