Hiya!
Just a quick question on drawing quads. I'm currently using:
GraphicsDevice.DrawPrimitives(PrimitiveType primitiveType,
int startVertex, int primitiveCount);
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.
I know that I can do so with DrawUserIndexedPrimitives() but I want my buffer! ;)
Edit: 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:
Quads: {v1,v2,v3,v4} {v5,v6,v7,v8} ...
Triangles: {v1,v2,v3} {v4,v5,v6} {v7,v8 ...}
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.
Edit 2: I'm sorry, I'm actually using a dynamic vertex buffer.
Posting some code on how I do my quads with six vertices:
// ## 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);
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.