• Advertisement
Sign in to follow this  

3D text rendering with DirectX Toolkit's SpriteFont

This topic is 1510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to implement text/symbol rendering in 3D perspective projection setup using DirectXTK's SpriteBatch/SpriteFont. I've searched the web on related topics and found two helpful articles [1],[2].
To experiment with walbourn's code given in [2], I start with the DirectXTK simple sample [3]. I want to change the code so that the Windows logo and the text "DirectXTK Simple Sample" take on a 3D perspective feel of look. The only changes I've made so far is in function Renderer::Render() of file Renderer.cpp. In details, I pass an transform matrix as the function argument to Renderer::Render.
```
    // Draw sprite
    XMMATRIX world = XMLoadFloat4x4( &m_world );
    XMMATRIX view = XMLoadFloat4x4( &m_view );
    XMMATRIX projection = XMLoadFloat4x4( &m_projection );
    XMMATRIX local = XMMatrixMultiply( world, XMMatrixTranslation( -2.f, -2.f, -4.f ) );
    XMMATRIX worldViewProj = local * view * projection;

    m_sprites->Begin(DirectX::SpriteSortMode_Deferred, nullptr, nullptr, nullptr, nullptr, nullptr, worldViewProj);
    //m_sprites->Begin();
    m_sprites->Draw( m_texture2.Get(), XMFLOAT2(10,75), nullptr, Colors::White );
    m_font->DrawString( m_sprites.get(), L"DirectXTK Simple Sample", XMFLOAT2( 100, 10 ), Colors::Yellow );
    m_sprites->End();
```
The rendering result is apparently wrong as both logo and text are invisible at first and then become rays of light staring from the top-left corner of the screen, and then disappear again at the end of animation period. Could someone tell me what's wrong with my code. How to change the code so that the logo and the text are rendered on the surface of the tea pot or character face? Thank you in advance.

 

[1] SpriteBatch billboards in a 3D world. http://blogs.msdn.com/b/shawnhar/archive/2011/01/12/spritebatch-billboards-in-a-3d-world.aspx?PageIndex=2.
[2] SpriteBatch.Begin()
https://directxtk.codeplex.com/discussions/459391.
[3] DirectXTK Simple Sample (Windows 8.1)
http://code.msdn.microsoft.com/DirectXTK-Simple-Sample-a0b6de36.

 

PS: I've posted this question on MSDN a few days ago but got no reply yet. Sorry for the repetition.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement