在DirectX 11(C ++)中画线的最简单方法是? [英] Simplest way to draw line in DirectX 11 (C++)?

查看:159
本文介绍了在DirectX 11(C ++)中画线的最简单方法是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在DirectX 11应用程序中画一条线.我希望它具有恒定的宽度(不取决于与相机的距离),但是它必须是空间<3> 3 中的一条线,所以类似线框模式.我将在充满其他对象的场景中使用一些着色器渲染我的线条.

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.

在DirectX 11中使用C ++(不是C#)实现它的最佳和最简单的方法是什么?

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

代码示例将不胜感激;)

推荐答案

最常见的解决方案是在您的 IASetPrimitiveTopology 调用中使用D3D11_PRIMITIVE_TOPOLOGY_LINELIST.

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

这篇关于在DirectX 11(C ++)中画线的最简单方法是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆