I'm currently tasked with porting a control from Direct 11 to DirectX 12.

How do I draw text on the screen?

How do I draw any 2D on a DirectX 12 device?

Current Text rendering code is below:

using (var textFormat = new TextFormat(device2DManager.DirectWriteFactory, string.IsNullOrEmpty(text.FontName) ? FontName : text.FontName, text.FontSize == 0 ? FontSize : text.FontSize)) { renderTarget.DrawText(text.Text, textFormat, new RawRectangleF(autoPosition.HasValue ? autoPoint.X : text.Location.X, autoPosition.HasValue ? autoPoint.Y : text.Location.Y, renderTarget.Size.Width, renderTarget.Size.Height), foreColor); }


1 Answer 1


How did you draw your text with DirectX 11?

D3DX9, D3DX10, D3DX11 and in fact the entire legacy DirectX SDK are deprecated per MSDN. You don't actually need it for DirectX 11, and it doesn't support anything to do with DirectX 12. See Living without D3DX

For drawing text on Direct3D 11 or Direct3D 12, you have two basic choices:

  1. You can use Direct2D/DirectWrite to render the text. With DirectX 11.1 or later, the device sharing makes this fairly straight-forward but it is a fair bit of code. This is the best option if you want to support complex layout, very large character sets, and highly scalable resolution output.

  2. Alternative you can either implement or use the same 'spritesheet' based approach that was implemented in the legacy D3DX library font system. For C++, see SpriteFont in the DirectX Tool Kit for DX11 and DX12.

For C# using SharpDX, option (1) might be your best bet.

  • \$\begingroup\$ Currently in 11.3 and rendering text using DirectWriteFactory and the Direct2D1 RenderTarget. That being said I cannot figure out for the life of me how to get the 2D context from a DirectX 12 device. \$\endgroup\$
    – Reaper
    Commented Aug 19, 2018 at 7:36
  • \$\begingroup\$ Can you create an 11.x and a 12 and them work together? Forgive me, I'm very new to DirectX 12. \$\endgroup\$
    – Reaper
    Commented Aug 21, 2018 at 20:53
  • \$\begingroup\$ You create a Direct3D 11 device to render the text to a texture, and use interop to render that texture onto a Direct3D 12 render target. See MSDN \$\endgroup\$ Commented Aug 22, 2018 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .