4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Graphics;
9 internal class LineBatch
11 VertexPositionColor[] vertexBuffer =
new VertexPositionColor[512];
14 int iVertexBuffer = 0;
15 bool beginHasBeenCalled =
false;
16 public bool LightingEnabled =
true;
19 public void Begin( ref Matrix matrix )
21 Debug.Assert( !beginHasBeenCalled );
22 beginHasBeenCalled =
true;
30 Debug.Assert( beginHasBeenCalled );
32 beginHasBeenCalled =
false;
37 if ( iVertexBuffer > 0 )
39 effect = Graphics.GetColorEffect(ref matrix, LightingEnabled);
40 effect.CurrentTechnique.Passes[0].Apply();
42 Game.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(
43 PrimitiveType.LineList, vertexBuffer, 0, iVertexBuffer / 2);
49 public void Draw(Vector startPoint, Vector endPoint, Color color)
51 if ((iVertexBuffer + 2) > vertexBuffer.Length)
56 vertexBuffer[iVertexBuffer++] =
new VertexPositionColor(
57 new Vector3((
float)startPoint.X, (
float)startPoint.Y, 0f),
59 vertexBuffer[iVertexBuffer++] =
new VertexPositionColor(
60 new Vector3((
float)endPoint.X, (
float)endPoint.Y, 0f),