Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 906753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:26:30+00:00 2026-05-15T16:26:30+00:00

Just a quick question on drawing quads. I’m currently using: GraphicsDevice.DrawPrimitives(PrimitiveType primitiveType, int startVertex,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:26:31+00:00Added an answer on May 15, 2026 at 4:26 pm

    Yes that’s possible. You’ll need to use TriangleStrip as the PrimitiveType. In Your VertexBuffer, You define Your vertices in the following order:

    1---3
    |\  |
    | \ |
    |  \|
    0---2

    EDIT to adress Your modified question

    I don’t know, how Your code looks like, but in general the information about the primitve count is used in the following places:

    • Buffer creation: public VertexBuffer (
      GraphicsDevice graphicsDevice,
      int sizeInBytes,
      BufferUsage usage
      )
      //sizeInBytes depends on the primitive count.
    • Draw call: public void DrawPrimitives (
      PrimitiveType primitiveType,
      int startVertex,
      int primitiveCount
      )

    Note, the information about the size of Your vertex format is needed in a couple more places but shouldn’t be a problem as the size shouldn’t change.

    Update

    Thx for the clarification, now I know, what You want to achieve. The correct way to handle Your problem is to use a vertex buffer in conjunction with a index buffer. The vertex buffer holds the vertices, the index buffer holds the order in which to connect the vertices to form triangles. Imagine You want to draw the following quad on Your screen:

     (0,1)________(1,1)
         |        |
         |        |
         |________|
     (0,0)        (1,0)

    What You did earlier was this:

    Vector3 v0, v1, v2, v3;
    v0 = new Vector3(0, 0, 0);
    v1 = new Vector3(1, 0, 0);
    v2 = new Vector3(0, 1, 0);
    v3 = new Vector3(1, 1, 0);
    
    List vertices = new List();
    //first triangle
    vertices.add(v0);
    vertices.add(v2);
    vertices.add(v1);
    
    //second triangle
    vertices.add(v2);
    vertices.add(v1);
    vertices.add(v3);
    
    VertexBuffer vb = new VertexBuffer(...);
    vb.setData(verticesToDraw);
    
    //draw the scene using PrimitiveType.TriangleList and primitive count 2
    

    What You do now is this:

    //vertices stay the same as in the example above!
    List vertices = new List();
    vertices.add(v0);
    vertices.add(v1);
    vertices.add(v2);
    vertices.add(v3);
    
    int[] indices = new int[6];
    //first triangle
    indices[0] = 0;
    indices[1] = 2; 
    indices[2] = 1;
    
    //second triangle
    indices[3] = 2;
    indices[4] = 1;
    indices[5] = 3;
    
    VertexBuffer vb = new VertexBuffer(...);
    IndexBuffer ib = new IndexBuffer(...);
    
    vb.setData(vertices);
    ib.setData(indices);
    
    /*draw using the DrawIndexedPrimitives() method rather than the
    DrawPrimitives() method and use PrimitiveType.TriangleList and
    primitive count 2.*/
    

    You see, You save 2 vertices per quad but have instead to use 6 indices which specify the order in which to build triangle from the vertices. So this method is only useful if Your vertices are big (cary many information like normals, texture coordinates etc) and are shared by many triangles.

    Riemers.net has a really nice, short and easy to understand tutorial on vertex and index buffers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 469k
  • Answers 469k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This works for me... /// <summary> /// Creates new process… May 16, 2026 at 2:50 am
  • Editorial Team
    Editorial Team added an answer Does the initial page you're loading actually display? Are you… May 16, 2026 at 2:50 am
  • Editorial Team
    Editorial Team added an answer It's sorting the entire collection, not against a specific "card".… May 16, 2026 at 2:50 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.