简体   繁体   中英

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.

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

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. 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. I make it easy to use by writing a few functions to "print" various data at given coordinates in the texture2D. That works very well for what I needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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