locked
Rendering text to a texture?

    Question

  • I've got a WinRT DirectX game that is a Xaml/DirectX hybrid.  As the project nears completion, lag has made it evident that using Xaml for a popup control was a bit too much to ask for, at least in my fast-paced game.  I've remade my popup control full DX now, but there's a terrible side effect.  Where before (when my popup was Xaml), it was easy to insure it popped up above my hud (also xaml) text.  Now, as would be expected, when my control pops up close to the hud, the hud obscures it... very unprofessional.

    So now, I have to figure out how to render my hud text below my popup.  As far as I can see, that means I've got to render text into a bitmap.

    My engine is a hand-refactored version of the wonderful 3D/Xaml sample.  Can I have some recommendations as to what to do? (Pointing to a sample where text is actually rendered in a 3D world would be great). I've played with DirectWrite, but that text also shows above all the D3D rendering.  If there were a way to sandwich a layer of text just above a "billboard" I'm using as a background and below every other thing rendered in the 3D scene, that would work too.

    My text needs are small... only 3 strings, none more than 5 characters.  I want to render a nice font.  If I can't figure anything else out in the next 2 days, I'm going to fall back to my own bitmap samples of characters, but that's going to be tougher to localize in the future.

    Thanks,

    Jim Tomasko

    Friday, January 04, 2013 6:05 AM

Answers

  • So basically you want to render a sprite with a texture that has dynamically generated text, correct? That's pretty easy to accomplish. You can make use of Direct2D/DirectWrite to render the text to the texture pretty easily.

    Alternatively, you can look at the SpriteBatch and SpriteFont classes available in the DirectXTK library.

    • Marked as answer by HeadRoach Friday, January 04, 2013 10:36 PM
    Friday, January 04, 2013 7:32 PM

All replies

  • So basically you want to render a sprite with a texture that has dynamically generated text, correct? That's pretty easy to accomplish. You can make use of Direct2D/DirectWrite to render the text to the texture pretty easily.

    Alternatively, you can look at the SpriteBatch and SpriteFont classes available in the DirectXTK library.

    • Marked as answer by HeadRoach Friday, January 04, 2013 10:36 PM
    Friday, January 04, 2013 7:32 PM
  • Hi Chuck,

    Ok, D2D/DirectWrite rendering into a texture sounds good.  In the interest of time, are there any examples that will work with WinRT?

    Friday, January 04, 2013 10:41 PM