0

I'm researching to draw a map route by the D3D. So I have created vertex buffer and fill it by the points: {-0.5, 0.5}, {-0.5, -0.5}, {0.5, -0.5}, {0.5, 0.5}. The Indexes buffer if: {0,1,2, 2,3,0}. So the rectangle is drown, now I need to draw a border in one pixel. Please give me an idea how to implement it.

Viacheslav Smityukh
  • 5,652
  • 4
  • 24
  • 42

1 Answers1

1

You can reuse your vertex buffer, and set the following on your device context:

deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP);

And then :

deviceContext->Draw(4,0);

That will draw lines on the rectangle border.

mrvux
  • 8,523
  • 1
  • 27
  • 61
  • Advice: to do it you should push-up the z of the vertices, because Z-buffer will suppress your drawings. Thanks a lot the border is drown correctly. – Viacheslav Smityukh Jul 04 '14 at 06:58
  • Good point, was not sure if you were using depth buffer or not. You can also set depth comparison to LESSEQUAL before to render lines as well, generally works pretty well (or set depth bias in rasterizer), so you can keep the same set of vertices. – mrvux Jul 04 '14 at 13:46
  • How can I change depth comparison? – Viacheslav Smityukh Jul 07 '14 at 05:39
  • This link should help: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205074(v=vs.85).aspx – mrvux Jul 08 '14 at 09:10
  • I have tested LESSOREQUAL comparison, it provides less quality than move points by the projection matrix – Viacheslav Smityukh Jul 09 '14 at 11:47