Just need to check if I am doing this right. I want to set the Anisotropy levels.
//initialize Anisotropy settings
private void InitAnisotropy()
{
if (device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMinifyAnisotropic)
{
device.SamplerStates[0].MinFilter = TextureFilter.Anisotropic;
}
else if (device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMinifyLinear)
{
device.SamplerStates[0].MinFilter = TextureFilter.Linear;
}
if (device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMagnifyAnisotropic)
{
device.SamplerStates[0].MagFilter = TextureFilter.Anisotropic;
}
else if (device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMagnifyLinear)
{
device.SamplerStates[0].MagFilter = TextureFilter.Linear;
}
if (device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMipMapPoint)
{
device.SamplerStates[0].MipFilter = TextureFilter.Point;
}
else if (device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMipMapLinear)
{
device.SamplerStates[0].MipFilter = TextureFilter.Linear;
}
//set anisotropy (ensure less than max in TextureCapabilities
device.SamplerStates[0].MaxAnisotropy = currAnisotropy;
}
Is this correct or do i have to set all 16 instances of SamplerState in SamplerStates to these settings

Setting Anisotropy level....
notadog
I'm just confused as my card has a max AF of 16x and there are 16 samplers in SamplerStates.
So to rephrase.
To set anisotropy to 16x is it:
A)
SamplerStates[0].MaxAnisotropy = 16;
or
B)
Foreach (SamplerState ss in SamplerStates)
ss.MaxAnisotropy = 16;
hazz
bahadir
Wow, that blog link was some dense stuff!
So based on that, if you boxed a value type and iterated over it, then in your loop unboxed it and modified the value, would this have the ultimate impact of doing the modification that you want How would this look in code for something like an int
Xadja
In the CLR, most objects are passed by reference. So when it copies the variable, this is really just copying a reference to the underlying object, and when you modify properties of that reference, this does affect the original object.
The CLR also supports value types, which are truly copied rather than just referenced when you assign them to a different variable. XNA Framework types like Vector3, Matrix, and the builtin vertex structures are value types, but most other things are reference types.
http://www.albahari.com/value%20vs%20reference%20types.html and http://blogs.msdn.com/cbrumme/archive/2003/05/10/51425.aspx have some more detail on this.
Dordorgum
The other entries in SamplerStates are for more advanced effects that might be using more than one texture.
user11
Eng. A. Kilani
Yes that is correct, but obviously its only setting Anisotropic/Linear for sampler 0.
You should set this each time you want to use it (unless you can guarantee something else won't override it).
NewbieDude
This doesn't really answer your question, but something to consider:
Foreach generates a copy, not a reference, so if you did this, your final values in SamplerStates wouldn't actually change. The identifier that you supply is effectively ReadOnly. You'd want to use
for (int i = 0; SamplerStates.Length; ++i) //I don't know if it's .Length or .Count here, sorry
{
//set
}
Check out http://msdn.microsoft.com/library/default.asp url=/library/en-us/csref/html/vclrftheforeachstatement.asp for more info.