public override void Render( RenderOperation op )
{
// Exit immediately if there is nothing to render
// This caused a problem on FireGL 8800
if ( op.vertexData.vertexCount == 0 )
{
return;
}
base.Render( op );
// To think about: possibly remove setVertexDeclaration and
// setVertexBufferBinding from RenderSystem since the sequence is
// a bit too D3D9-specific?
VertexDeclaration = op.vertexData.vertexDeclaration;
// TODO: the false parameter has to be carried inside op as var
SetVertexBufferBinding(op.vertexData.vertexBufferBinding, op.numberOfInstances, false, op.useIndices);
// Determine rendering operation
var primType = PrimitiveType.TriangleList;
var lprimCount = op.vertexData.vertexCount;
var cnt = op.useIndices && primType != PrimitiveType.PointList ? op.indexData.indexCount : op.vertexData.vertexCount;
switch ( op.operationType )
{
case OperationType.TriangleList:
primType = PrimitiveType.TriangleList;
lprimCount = cnt / 3;
break;
case OperationType.TriangleStrip:
primType = PrimitiveType.TriangleStrip;
lprimCount = cnt - 2;
break;
case OperationType.TriangleFan:
primType = PrimitiveType.TriangleFan;
lprimCount = cnt - 2;
break;
case OperationType.PointList:
primType = PrimitiveType.PointList;
lprimCount = cnt;
break;
case OperationType.LineList:
primType = PrimitiveType.LineList;
lprimCount = cnt / 2;
break;
case OperationType.LineStrip:
primType = PrimitiveType.LineStrip;
lprimCount = cnt - 1;
break;
} // switch(primType)
if (lprimCount == 0)
return;
if (op.useIndices)
{
var d3DIdxBuf = (D3DHardwareIndexBuffer)op.indexData.indexBuffer;
ActiveD3D9Device.Indices = d3DIdxBuf.D3DIndexBuffer;
do
{
// Update derived depth bias
if (derivedDepthBias && currentPassIterationNum > 0)
{
SetDepthBias(derivedDepthBiasBase +
derivedDepthBiasMultiplier * currentPassIterationNum,
derivedDepthBiasSlopeScale);
}
// draw the indexed primitives
ActiveD3D9Device.DrawIndexedPrimitives(primType,
op.vertexData.vertexStart,
0,
op.vertexData.vertexCount,
op.indexData.indexStart,
lprimCount);
} while (UpdatePassIterationRenderState());
}
else
{
// nfz: gpu_iterate
do
{
// Update derived depth bias
if (derivedDepthBias && currentPassIterationNum > 0)
{
SetDepthBias(derivedDepthBiasBase +
derivedDepthBiasMultiplier * currentPassIterationNum,
derivedDepthBiasSlopeScale);
}
// Unindexed, a little simpler!
ActiveD3D9Device.DrawPrimitives(primType, op.vertexData.vertexStart, lprimCount);
} while (UpdatePassIterationRenderState());
}
}