Another problem with these states, is how the ?: operator is used for each stage 3 times, it should be done 1 time and saved into the proper enumeration and then set using the single value into all of the calls. Here's how I know do it in IrrSpintz for DX9 -
Code: Select all
D3DTEXTUREFILTERTYPE magFilter = D3DTEXF_POINT;
D3DTEXTUREFILTERTYPE minFilter = D3DTEXF_POINT;
D3DTEXTUREFILTERTYPE mipFilter = D3DTEXF_POINT;
if( material.AnisotropicFilter )
{
magFilter = D3DTEXF_ANISOTROPIC;
minFilter = D3DTEXF_ANISOTROPIC;
mipFilter = D3DTEXF_ANISOTROPIC;
}
else if( material.TrilinearFilter )
{
magFilter = D3DTEXF_LINEAR;
minFilter = D3DTEXF_LINEAR;
mipFilter = D3DTEXF_LINEAR;
}
else if( material.BilinearFilter )
{
magFilter = D3DTEXF_LINEAR;
minFilter = D3DTEXF_LINEAR;
mipFilter = D3DTEXF_POINT;
}
pID3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, mipFilter );
pID3DDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(1, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(1, D3DSAMP_MIPFILTER, mipFilter );
pID3DDevice->SetSamplerState(2, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(2, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(2, D3DSAMP_MIPFILTER, mipFilter );
pID3DDevice->SetSamplerState(3, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(3, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(3, D3DSAMP_MIPFILTER, mipFilter );