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

假如想象 提交于 2021-02-18 18:15:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!