Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The most efficient way is to use an indexed draw and then to repeat indices in between the 2 rectangles.</p> <p>ie indices 0, 1, 2, 3, 3, 4, 4, 5, 6, 7 produces the following triangles from triangle stripping</p> <p>0, 1, 2 - 1, 2, 3 - 2, 3, 3 - 3, 3, 4 - 3, 4, 4 - 4, 4, 5 - 4, 5, 6 - 5, 6, 7</p> <p>the triangles 2, 3, 3 - 3, 3, 4 - 3, 4, 4 and 4, 4, 5 all have zero area and will be discarded very early on the graphics card. This way you get 4 triangles rendered in one call to DrawIndexedPrimitive.</p> <p>Of course that means you are sending in 10 indices. You may as well just send in 12 indices and draw both rectangles as 4 triangles in a tri list. When using indexed drawing you'll find that the hardware keeps track of what vertices it has already transformed so that it doesn't have to bother again. </p> <p>ie if you define your index buffer as</p> <p>0, 1, 2, 3, 0, 2, 4, 5, 6, 7, 4, 6</p> <p>and you have a post transform cache of at least 4 vertices (Pretty much every graphics card has a significantly larger post transform cache, The GeForce 3 certainly did!) then you can see that both triangles will be rendered and yet each vertex will only be transformed once. Counter-intuitively on any post DX8 hardware (ie any DX9 or 10 hardware) you'll find that the use of this post transform cache and extra simplicity of triangle lists means that you'll actrually get BETTER performance from a triangle list than a triangle strip.</p> <p>So in summary in answer to the question "So my question is, what is the most efficient way to draw two Rectangles with D3DPT_TRIANGLESTRIP?" the answer is to draw is a D3DPT_TRIANGLELIST and stop worrying about it :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload