سؤال

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 ;)

هل كانت مفيدة؟

المحلول

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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top