microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
MIT License
2.57k stars 510 forks source link

SpriteFont DrawString issue making text into black boxes #463

Closed Zoardedz closed 1 month ago

Zoardedz commented 3 months ago

I'm trying to make a GUI SpriteBatch that'll render a rectangle and an FPS counter as a test, I'm using your vs-templates (Win32 no device resources) with a few changes just making it more polymorphic, that aside there's a bug in my code that turns the text into black boxes if layered above the drawn rectangle, I assume this is because it's trying to reference the texture I used for the rectangle (images below) image image I made a different SpriteBatch instance for the FPS counter but it also gave me the same result (surprisingly??) I assume it could be as I said, trying to reference the image I used for the rectangle instead of the SpriteFont textures or an unrelated issue relating to blendstates or something else.

Zoardedz commented 3 months ago

-I also used RenderDoc to check if the FPS text displays correctly when layered under the rectangle and it displayed the text like normal

Zoardedz commented 3 months ago

If it helps, this is practically the draw function every IElement2D uses. image

walbourn commented 2 months ago

Is the render target here alpha-blended? Note that SpriteBatch defaults to using Premultiplied alpha, and if you are using straight-alpha with the rectangle it will be 'wrong' here.