PolGraphic
PolGraphic

Reputation: 3364

Simplest way to draw line in DirectX 11 (C++)?

I want to draw a line in my DirectX 11 application. I want it to have constant width (not depending on distance from camera), but it has to be a line in space (3D), so something like lines of objects in wireframe mode. I will render my line in a scene full of other objects with some shaders.

What would be the best and simplest way to achive it in DirectX 11 with C++ (not C#)?

Code sample will be appreciated ;)

Upvotes: 2

Views: 12033

Answers (1)

Paul-Jan
Paul-Jan

Reputation: 17278

The most common solution would be to use D3D11_PRIMITIVE_TOPOLOGY_LINELIST in your IASetPrimitiveTopology calls.

I suspect (but didn't profile) it is also a pretty fast way of rendering lines. In your comment, you mention the cost of switching the primitive topology setting. I'd say that cost is negligible, as it comes down to one state switch per frame (render primitives first, lines last).

Upvotes: 3

Related Questions