Sign in to follow this  
FoxHunter2

Blurry ID3DXFont in windowed mode

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?"

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this