Blurry ID3DXFont in windowed mode

Started by
8 comments, last by FoxHunter2 19 years, 9 months ago
Hi! I'm using ID3DXFont in my DirectX9 application to output some statistics on the screen. In fullscreenmode the font looks fine and sharp, but in windowed mode the font look very ugly and blurry, hard to read. Anyone experienced this? If it helps, here's the code:
HDC hDC = GetDC(NULL);

		LOGFONT fStatsFont;
		ZeroMemory(&fStatsFont, sizeof(LOGFONT));
		fStatsFont.lfHeight = -MulDiv(11, GetDeviceCaps(hDC, LOGPIXELSY), 72);
		fStatsFont.lfWidth	= 0;
		fStatsFont.lfOrientation = 0;
		fStatsFont.lfEscapement = 0;
		fStatsFont.lfWeight = FW_NORMAL;
		fStatsFont.lfItalic = FALSE;
		fStatsFont.lfUnderline = FALSE;
		fStatsFont.lfStrikeOut = FALSE;
		fStatsFont.lfCharSet = DEFAULT_CHARSET;
		fStatsFont.lfOutPrecision = OUT_TT_PRECIS;
		fStatsFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
		fStatsFont.lfQuality = DEFAULT_QUALITY;
		fStatsFont.lfPitchAndFamily = DEFAULT_PITCH;
		strcpy(fStatsFont.lfFaceName, "Arial");

		ReleaseDC(NULL, hDC);

		hRes = D3DXCreateFontIndirect(pD3DDevice, &fStatsFont, &pD3DStatsFont);
		if(FAILED(hRes))
		{
			Error(hRes, "D3DXCreateFontIndirect() failed!");
			return false;
		}
regards
Advertisement
Do you have filtering enabled? Does the font take up exactly the same space in windowed mode as it does in full screen? If not, then it sounds like you might be setting the backbuffer width and height to something other than the window width and height when it is windowed. That's the only thing I could think of...

Chris
Chris ByersMicrosoft DirectX MVP - 2005
Quote:Original post by Supernat02
Do you have filtering enabled? Does the font take up exactly the same space in windowed mode as it does in full screen? If not, then it sounds like you might be setting the backbuffer width and height to something other than the window width and height when it is windowed. That's the only thing I could think of...

Chris


I agree with Chris. It's not a problem with fonts, but with scaling sprites.
www.tmreality.com
Thanks so far, do you need any more information to track down my problem?

The backbuffer is set like this:
d3dpp.Windowed = TRUE;d3dpp.BackBufferWidth	= pSettings->Window_WindowedWidth();d3dpp.BackBufferHeight = pSettings->Window_WindowedHeight();


So the backbuffer and the window are of the same size.

There's no filtering used I'm aware of, how do I turn on filtering?
And what do you mean by "Does the font take up exactly the same space in windowed mode as it does in full screen?"
make sure that your backbuffer's width and height are the size of the client area of your window, and not the size of the whole window including borders, etc..

xyzzy
Yes that has caught me out before now. You can use GetViewport to find out what it is actually set to.
------------------------See my games programming site at: www.toymaker.info
Thanks a lot, that did the trick.

However, in Fullscreen mode the font is bigger than in windowed mode. Is this the correct behavior? I thought 14pt should be 14pt, or am I missing something?
It should be the same size in relation to the size of the render area. If you're comparing a 640x480 fullscreen vs. 640x480 window on a 1024x768 Desktop, then the fullscreen text will appear much bigger though they take up the same number of pixels.
Stay Casual,KenDrunken Hyena
(chuckle) I was getting the same problem when I switched from fullscreen to windowed and yep, GetViewport fixed it, thanks aswell.
thanks for the explanation, Ken.

by the way, just in this moment I'm reading your tutorials on DrunkenHyena.com. Great work, keep it up!

This topic is closed to new replies.

Advertisement