public override void SetTexture( int stage, bool enabled, Texture texture )
{
var dxTexture = (D3DTexture)texture;
if ( enabled && dxTexture != null )
{
// note used
dxTexture.Touch();
var ptex = dxTexture.DXTexture;
if ( _texStageDesc[ stage ].tex != ptex )
{
ActiveD3D9Device.SetTexture( stage, ptex );
// set stage description
_texStageDesc[ stage ].tex = ptex;
_texStageDesc[ stage ].texType = D3DHelper.ConvertEnum( dxTexture.TextureType );
}
SetSamplerState( GetSamplerId( stage ), SamplerState.SrgbTexture, dxTexture.HardwareGammaEnabled );
}
else
{
if ( _texStageDesc[ stage ].tex != null )
{
ActiveD3D9Device.SetTexture(stage, null);
}
SetTextureStageState( stage, TextureStage.ColorOperation, TextureOperation.Disable );
// set stage description to defaults
_texStageDesc[ stage ].tex = null;
_texStageDesc[ stage ].autoTexCoordType = TexCoordCalcMethod.None;
_texStageDesc[ stage ].coordIndex = 0;
_texStageDesc[ stage ].texType = D3DTextureType.Normal;
}
}