title: XNA - Using Dynamic Vertex Buffer and only four(4) vertices
body: <p>Just a quick question on drawing quads. I'm currently using:</p>
  
  <pre><code>GraphicsDevice.DrawPrimitives(PrimitiveType primitiveType,
                          int startVertex, int primitiveCount);
  </code></pre>
  
  <p>This draws my quads perfectly fine but the only way I can make it work is to use six (6) vertices for my quads (drawing them as two triangles). I'm just wondering if it is possible to feed the GPU with four (4) vertices and still retain my dynamic vertex buffer.</p>
  
  <p>I know that I can do so with DrawUserIndexedPrimitives() but I want my buffer! ;)</p>
  
  <p><strong>Edit:</strong> Do I need, and if so where do I tell my GPU that I'm feeding it four vertices per two triangles? I'm currently storing my quads as nQuads * 6 vertices in a vertex buffer and my GPU uses every three vertices as a triangle. So just switching to four vertices means:</p>
  
  <pre><code>Quads: {v1,v2,v3,v4} {v5,v6,v7,v8} ...
  Triangles: {v1,v2,v3} {v4,v5,v6} {v7,v8 ...}
  </code></pre>
  
  <p>Which is not a good thing since triangle number two uses one vertex from the first quad, number three uses two from the second quad, and so on and so forth.</p>
  
  <p><strong>Edit 2:</strong> I'm sorry, I'm actually using a dynamic vertex buffer.</p>
  
  <p>Posting some code on how I do my quads with six vertices:</p>
  
  <pre><code>        // ## CONSTRUCTION
          // Setting up buffer and vertex holder.
          particleVertexBuffer = new DynamicVertexBuffer(graphicsDevice,
              ParticleQuad.VerticesSizeInBytes * nMaxParticles,
              BufferUsage.WriteOnly);
          particleVertices = new ParticleVertex[nMaxParticles * 6];
  
          // ## ADD VERTICES
          particleVertices[i].Set();
          particleVertices[i+1].Set();
          particleVertices[i+2].Set();
          particleVertices[i+3].Set();
          particleVertices[i+4].Set();
          particleVertices[i+5].Set();
  
  
          // ## SET BUFFER
          particleVertexBuffer.SetData(particleVertices, 0, nMaxParticles * 6, SetDataOptions.NoOverwrite);
          graphicsDevice.Vertices[0].SetSource(particleVertexBuffer, 0, ParticleVertex.SizeInBytes);
  
          // ## DRAW
          graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList,
                      FirstUsedParticle * 6, ((LastUsedParticle - FirstUsedParticle)+1)* 2);
  </code></pre>
  
  <p>Now, there are a bit more to it because I use a circular queue and a bit other stuff, but this would be enough for understandability.</p>