Jump to content

  • Log In with Google      Sign In   
  • Create Account

3D text rendering with DirectX Toolkit's SpriteFont


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 30 November 2013 - 10:11 AM

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.



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS