public override void BindGpuProgram( GpuProgram program )
{
switch ( program.Type )
{
case GpuProgramType.Vertex:
ActiveD3D9Device.VertexShader = ( (D3DVertexProgram)program ).VertexShader;
break;
case GpuProgramType.Fragment:
ActiveD3D9Device.PixelShader = ((D3DFragmentProgram)program).PixelShader;
break;
case GpuProgramType.Geometry:
throw new AxiomException( "Geometry shaders not supported with D3D9" );
}
// Make sure texcoord index is equal to stage value, As SDK Doc suggests:
// "When rendering using vertex shaders, each stage's texture coordinate index must be set to its default value."
// This solves such an errors when working with the Debug runtime -
// "Direct3D9: (ERROR) :Stage 1 - Texture coordinate index in the stage must be equal to the stage index when programmable vertex pipeline is used".
for (var nStage=0; nStage < 8; ++nStage)
SetTextureStageState(nStage, TextureStage.TexCoordIndex, nStage);
base.BindGpuProgram( program );
}