Drawing text in directx 11

Started by
4 comments, last by korvax 11 years, 6 months ago
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..
Advertisement
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/

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.

[quote name='korvax' timestamp='1349686055' post='4987908']
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.
[/quote]

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.

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.

[quote name='korvax' timestamp='1349696716' post='4987957']
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.
[/quote]

It works prefect Eric no strange shader errors. thx.

This topic is closed to new replies.

Advertisement