Game Development Community

FontRenderer issues [workaround inside]

by Trent · in Torque X 3D · 11/29/2009 (7:22 pm) · 4 replies

Why does the font renderer draw what appears to be scaled up and highly transparent text when a fresh XNA project that only renders one line of text is quite crisp using the same SpriteBatch.DrawString() method?

I've been digging in the code and can find that it does use SpriteBatch.DrawString() and I've even hard coded values into that method, but it still does not draw text like stock XNA. I thought it might be rendering to a render target and scaling that after, but I can't seem to find any evidence of this either.

I will keep digging but rendering is not my specialty.


Edit: It appears if I use a font double the size it renders what appears to be normally, but of course that is not acceptable, it just might help track the problem.

#1
11/29/2009 (8:55 pm)
To help things along (I hope), I added a spritefont/spritebatch into the Game class, and rendered out some text using straight SpriteBatch.DrawString() in the overriden EndDraw() method before calling base.EndDraw(). I used exactly the same spritefont file for both lines of text.

protected override void EndDraw()
	{
		sprite.Begin();
		sprite.DrawString(font, "this is a xna test", new Vector2(0, 30), Color.Yellow);
		sprite.End();
		base.EndDraw();
	}

The first text is using GUIText, the second is my straight drawing.

i296.photobucket.com/albums/mm164/kiveryn/torquex_text_comparison.png
#2
11/29/2009 (9:05 pm)
Ok it's something to do with post processing...

I comment out line 553 in TorqueEngineComponent

//postProcess = !(_mainRenderTarget.IsNull || _mainRenderTarget.IsInvalid) && EnableBackBufferEffects && (_postProcessor != null);

and the text now renders perfectly.
#3
11/29/2009 (9:51 pm)
Ok, Engine.Settings.EnableBackBufferEffects is the culprit here.

This means that if I need refraction, according to TorqueEngineComponent.OnStartDraw(), then I have to suffer blurry text. I'm guessing I'll have to solve this on my own if I want refraction at some point.

I'd prefer that text just be drawn after everything though.
#4
12/10/2009 (8:51 pm)
Note that this setting causes issues with the particle emitters as noted in another post of mine (with another work around).