• 12
• 27
• 9
• 20
• 33

[SLIMDX] Draw Text?

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

Recommended Posts

Hi, what is the best way to draw text with SlimDX (e.g. Debug informations...). I tried to use font.Draw, but that doesn't seem to work (or is it me who is silly?).

Gdi works, but that's not a good solution (it will flicker...).

Are there other ways?

Share on other sites
Quote:
 I tried to use font.Draw, but that doesn't seem to work

It worked for me. This is how I used it:

// During initializationfont = new SlimDX.Direct3D9.Font(device, new System.Drawing.Font(FontFamily.GenericSansSerif, 14));// During renderingfont.DrawString(null, "abc", 10, 60, Color.Maroon);

Though this is from an older version of SlimDX and I don't know if anything changed since then.

Share on other sites
Well I am using D3D10.

SlimDX.Direct3D10.Font font = new SlimDX.Direct3D10.Font(device, 14, "Arial");
.....
font.Draw(null, "abc", new Rectangle(100, 100, 500, 500), FontDrawFlags.Top, new Color4(0.0f, 0.0f, 0.0f, 0.0f));

This won't show anything and it is killing the depth buffer as well.

Share on other sites
Looks fine, the problem is likely in the "..." (or before, or after, the two valid lines of code you posted).

Share on other sites
Well i am initializing the font just one time of course.

The rendering thing is between:

device.ClearRenderTargetView(renderTarget, clearColor);
device.ClearDepthStencilView(renderTargetDepth, DepthStencilClearFlags.Depth, 1f, 0);

//Render.... also the font.Draw..

swapChain.Present(0, PresentFlags.None);