AddVertex() public méthode

The add vertex is called to add another vertex to be rendered. To draw a point, AddVertex must be called once. For lines, twice, and for triangles 3 times. This method can only be called once begin has been called. If there is not enough room in the vertices buffer, Flush is called automatically.
Begin must be called before AddVertex can be called.
public AddVertex ( Vector2 vertex, Color color ) : void
vertex Vector2 The vertex.
color Color The color.
Résultat void
 public void Draw(Vector2 transform)
 {
     batch.Begin(PrimitiveType.LineList);
     foreach (var item in lines)
     {
         batch.AddVertex(item + transform, color);
     }
     batch.End();
 }
Exemple #2
0
        public void Draw(Vector2 transform)
        {
            //if (fill == false)
            //{
            //    device.RasterizerState = state;
            //}

            foreach (var item in point)
            {
                batch.AddVertex(item + transform, color);
            }

            //if (fill == false)
            //{
            //    device.RasterizerState = RasterizerState.CullCounterClockwise;
            //}
        }
        public void Draw(Vector2 transform)
        {
            if (fill == false)
            {
                device.RasterizerState = state;
            }

            if (point.Count < 3)
            {
                throw new InvalidOperationException("precisa de 3 pontos pelo menos para poder desenhar os triangulos");
            }

            batch.Begin(PrimitiveType.TriangleStrip);
            foreach (var item in point)
            {
                batch.AddVertex(item + transform, color);
            }
            batch.End();

            if (fill == false)
            {
                device.RasterizerState = RasterizerState.CullCounterClockwise;
            }
        }