Jump to content

  • Log In with Google      Sign In   
  • Create Account

Drawing text in directx 11


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
5 replies to this topic

#1 korvax   Members   -  Reputation: 306

Like
0Likes
Like

Posted 08 October 2012 - 02:47 AM

Hi,
im looking for a "generic directx" way to draw text in Directx 11, I been reading that Directx 11 should be able to sync with Direct 2D (or vice versa). Has anyone be able to use D2D with Directx 11 and have some kind of example? Or do we all need to get Windows 8 so we can get this to work in DX11.1?

is there a correct way of doing this as it was in dx10?

Ive have been trying FW1Fontwrapper aswell, but can really get it to work.. Verry strange Shader errors in the debug window and the text is being displayed but the the 3d objects in the background is not showing..

Sponsor:

#2 Corvwyn   Members   -  Reputation: 331

Like
0Likes
Like

Posted 08 October 2012 - 02:55 AM

Lately I've updated my code to be compatible with the new Windows 8 sdk. Removing the d3dx libraries, adding D3DCompiler, new texture loading etc. The libraries are for both windows 8 and windows 7 "classic" applications as they call it.

Microsoft has released some new libraries that provide texture loading, sprite batching and sprite fonts. I haven't tested this yet, but you can find it here if you want to check it out:

http://directxtk.codeplex.com/

Edited by Corvwyn, 08 October 2012 - 02:56 AM.


#3 Erik Rufelt   Crossbones+   -  Reputation: 3627

Like
0Likes
Like

Posted 08 October 2012 - 03:03 AM

Ive have been trying FW1Fontwrapper aswell, but can really get it to work.. Verry strange Shader errors in the debug window and the text is being displayed but the the 3d objects in the background is not showing..


Try using the FW1_RESTORESTATE flag when drawing strings, if you rely on your shaders and render states still being set after drawing strings, or the font-shaders will be active on the device-context after drawing strings.

If you still get any errors in the debug window with the flag I would be very interested in seeing them, if you can copy them here.

#4 korvax   Members   -  Reputation: 306

Like
0Likes
Like

Posted 08 October 2012 - 05:45 AM


Ive have been trying FW1Fontwrapper aswell, but can really get it to work.. Verry strange Shader errors in the debug window and the text is being displayed but the the 3d objects in the background is not showing..

Try using the FW1_RESTORESTATE flag when drawing strings, if you rely on your shaders and render states still being set after drawing strings, or the font-shaders will be active on the device-context after drawing strings.
If you still get any errors in the debug window with the flag I would be very interested in seeing them, if you can copy them here.


So just then
pFontWrapper->DrawString(
pContext,
L"Text",// String
128.0f,// Font size
100.0f,// X position
50.0f,// Y position
0xff0099ff,
FW1_RESTORESTATE);
Does it matter where in the rendering process i put this.. Before or after draw for example? Im out and have no access to my code right now.. will post my errors her soon.


Lately I've updated my code to be compatible with the new Windows 8 sdk. Removing the d3dx libraries, adding D3DCompiler, new texture loading etc. The libraries are for both windows 8 and windows 7 "classic" applications as they call it.

Microsoft has released some new libraries that provide texture loading, sprite batching and sprite fonts. I haven't tested this yet, but you can find it here if you want to check it out:

http://directxtk.codeplex.com/

Super thanks will check this out.. was also looking for a texture loading lib so this is perfect.

#5 Erik Rufelt   Crossbones+   -  Reputation: 3627

Like
0Likes
Like

Posted 08 October 2012 - 06:33 AM

Does it matter where in the rendering process i put this.. Before or after draw for example? Im out and have no access to my code right now.. will post my errors her soon.


The FW1_RESTORESTATE option must be used in every call to DrawString, to keep the context states unchanged after the draw is complete.

If you mean text rendering, it depends on where you want it. Put it last if you want the text on top of everything else. If you want to draw the text with depth-testing or otherwise modify the rendering, that requires some additional flags and manual setting of states.

Edited by Erik Rufelt, 08 October 2012 - 06:34 AM.


#6 korvax   Members   -  Reputation: 306

Like
0Likes
Like

Posted 08 October 2012 - 01:38 PM


Does it matter where in the rendering process i put this.. Before or after draw for example? Im out and have no access to my code right now.. will post my errors her soon.


The FW1_RESTORESTATE option must be used in every call to DrawString, to keep the context states unchanged after the draw is complete.


It works prefect Eric no strange shader errors. thx.




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