Rectangles instead of characters



I can't get the lib work. I got rectangles instead of characters on the output image. The generated character table texture seems fine to me, it might be a drawing issue, maybe some device setting.

Init and drawing calls:
if (spriteRenderer == null)
    spriteRenderer = new SpriteTextRenderer.SpriteRenderer(device);
    spriteRenderer.HandleDepthStencilState = true; // doesn't matter though
    textBlockRenderer = new SpriteTextRenderer.TextBlockRenderer(spriteRenderer,
        "Arial", SlimDX.DirectWrite.FontWeight.Normal, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Normal, 36);
textBlockRenderer.DrawString("Hello world", Vector2.Zero, Color.Red);
Could somebody help me, please?


file attachments

Closed Apr 15, 2013 at 7:09 AM by Nico201
Problem has been solved


Nico201 wrote Apr 1, 2013 at 2:38 PM

Thank you for your post. I tried your code and it works for me. How have you verified the character table? Have you saved it or analyzed it via PIX? Please make sure that the property PIXCompatible is set to false. If you have included the complete project in your solution, you could check if the generated texture coordinates seem reasonable. See the method IterateString() in TextBlockRenderer.cs. You should take a look at CD when Sprite.Draw is called.

wrote Apr 14, 2013 at 3:57 PM

mmilan wrote Apr 14, 2013 at 3:57 PM

Sorry for late reply. At least, I've discovered the problem is somewhere around texture colors and blending. The attached output is made after changing D3DDevice10.ClearRenderTargetView(rtv, new SlimDX.Color4(0, 1, 1, 1)); to Color4(1, 0, 0, 0) or Color4(0, 0, 0, 0) in CreateCharTable. The characters seem OK, just the background color isn't transparent.

Nico201 wrote Apr 14, 2013 at 9:00 PM

You're probably right. The lib won't handle the blend state. Try to set an appropriate state. I usually use the following one:
BlendDesc = new BlendStateDescription()
    AlphaToCoverageEnable = false,
    IndependentBlendEnable = false,
    RenderTargets[0].BlendOperation = BlendOperation.Add,
    RenderTargets[0].DestinationBlend = BlendOption.InverseSourceAlpha,
    RenderTargets[0].SourceBlend = BlendOption.SourceAlpha,
    RenderTargets[0].BlendEnable = true,
    RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All

mmilan wrote Apr 14, 2013 at 10:11 PM

And it works, thank you!

I have to add though, that I didn't tampered with the blending at all (device.ImmediateContext.OutputMerger.BlendState was null). If the lib requires blending setup, then it should be part of the lib.

Nico201 wrote Apr 15, 2013 at 7:08 AM

That's correct. I'll change that in a future release.

Thanks again for your participation.

wrote Apr 15, 2013 at 7:09 AM

wrote May 16, 2013 at 3:41 AM