简体   繁体   English

在texture2D中绘制线条和字符(DirectCompute HLSL编程)

[英]Drawing lines and characters in a texture2D (DirectCompute HLSL programming)

I searched a lot without finding how to have a compute shader draw lines and characters in a texture2D. 我进行了大量搜索,但没有找到如何使计算着色器在texture2D中绘制线条和字符的方法。

My application has to do a lot of processing and generate a bitmap in a texture2D which is then rendered on screen and downloaded back to CPU and finally saved in a file. 我的应用程序必须进行大量处理,并在Texture2D中生成一个位图,然后将其显示在屏幕上并下载回CPU,最后保存在文件中。 After the bitmap is generated, I have to draw lines (and other simple geometric shapes) as well as character strings to annotate the bitmap. 生成位图后,我必须画线(和其他简单的几何形状)以及字符串来注释位图。 I'm stuck on this stage. 我被困在这个阶段。

btw: I'm using MSVC2015, DirectX/DirectCompute11, NVidia K4200 GPU. 顺便说一句:我正在使用MSVC2015,DirectX / DirectCompute11,NVidia K4200 GPU。

Any help appreciated. 任何帮助表示赞赏。

I finally solved my problem by implementing a classic algorithm to draw line on a rasterized image. 最终,我实现了一种经典算法来在光栅化图像上绘制线条,从而解决了我的问题。 I started from this code which is C code but very easy to translate to HLSL. 我从此代码开始,这是C代码,但非常容易转换为HLSL。 This implementation produce lines of any thickness. 此实现产生任何厚度的线。

I also wrote code to write characters to the texture2D the old way: I got a dot matrix font (There are a lot free to find on the internet), stored in a ByteAddressBuffer and copy pixel from that font to the texture2D. 我还写了代码,以旧的方式将字符写入texture2D:我得到了一个点阵字体(可以在互联网上免费找到),存储在ByteAddressBuffer中,然后将像素从该字体复制到Texture2D。 I make it easy to use by writing a few functions to "print" various data at given coordinates in the texture2D. 通过编写一些函数以在texture2D中的给定坐标处“打印”各种数据,我使它易于使用。 That works very well for what I needed. 对于我所需要的来说,这很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM