private void FlushVertexArray(int start, int end, Effect effect, Texture texture)
{
if (start == end)
return;
var vertexCount = end - start;
// If the effect is not null, then apply each pass and render the geometry
if (effect != null)
{
var passes = effect.CurrentTechnique.Passes;
foreach (var pass in passes)
{
pass.Apply();
// Whatever happens in pass.Apply, make sure the texture being drawn
// ends up in Textures[0].
_device.Textures[0] = texture;
_device.DrawUserIndexedPrimitives(
PrimitiveType.TriangleList,
_vertexArray,
0,
vertexCount,
_index,
0,
(vertexCount / 4) * 2,
VertexPositionColorTexture.VertexDeclaration);
}
}
else
{
// If no custom effect is defined, then simply render.
_device.DrawUserIndexedPrimitives(
PrimitiveType.TriangleList,
_vertexArray,
0,
vertexCount,
_index,
0,
(vertexCount / 4) * 2,
VertexPositionColorTexture.VertexDeclaration);
}
}
}