public override void Paint(Device device)
{
int numPoints = points.Count;
if (numPoints < 1) return; // Cannot paint polygon with less than 3 points (2 stored + mouse position)
device.VertexFormat = CustomVertex.TransformedColored.Format;
recalcPoints();
if (numPoints > 1)
{
Cull cull = device.RenderState.CullMode;
bool alphaEnable = device.RenderState.AlphaBlendEnable;
ShadeMode shadeMode = device.RenderState.ShadeMode;
// Draw Triangles
device.RenderState.CullMode = Cull.None;
device.RenderState.AlphaBlendEnable = true;
device.RenderState.ShadeMode = ShadeMode.Flat;
device.RenderState.SourceBlend = Blend.BothSourceAlpha;
device.RenderState.DestinationBlend = Blend.DestinationColor;
device.DrawUserPrimitives(PrimitiveType.TriangleFan, numPoints - 1, verts);
device.RenderState.AlphaBlendEnable = alphaEnable;
device.RenderState.CullMode = cull;
device.RenderState.ShadeMode = shadeMode;
}
// Draw Polygon Contour
device.DrawUserPrimitives(PrimitiveType.LineStrip, numPoints + ((numPoints > 1) ? 1 : 0), lineVertices);
}