Hi, (maybe I’m asking a silly question)
I use these code to draw a texture(2D):
basicEffect.TextureEnabled = true;
basicEffect.Texture = testTexture;
//in Draw()
foreach (var pass in basicEffect.CurrentTechnique.Passes)
{
pass.Apply();
switch (filterMode)
{
case 0:
device.SamplerStates[0].Filter = TextureFilter.Point;
break;
case 1:
device.SamplerStates[0].Filter = TextureFilter.Linear;
break;
}
device.SetVertexBuffer(verbuf);
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
I want to do this: When I press F1, the TextureFilterMode change to Point, and when I press F2 it change to Linear. But I found if I set filterMode at first, it works correctly.But seems nothing happens when I press the key.
I’m sure after I press the key, the filterMode is changed and
device.SamplerStates[0].Filter = TextureFilter.Linear;
was runned. But I can’t see any changes in graphics.Just like the Filter setting is one-off.
Same thing happens when I want to change TextureAddressMode like this:
device.SamplerStates[0].AddressU = TextureAddressMode.Clamp;
The code was copied from a book teaching XNA, and when in XNA it runs correctly.(although there are some syntax differences)
What’s wrong with my code? Thanks.