Jump to content
  • Advertisement
Sign in to follow this  
iliak

[.net] [XNA] Texture clamping

This topic is 3822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
You can try use this code too:
GraphicsDevice.SamplerStates[0].MinFilter = TextureFilter.Linear;

Share this post


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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!