问题
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 ;)
回答1:
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).
来源:https://stackoverflow.com/questions/21649766/simplest-way-to-draw-line-in-directx-11-c