Jump to content
  • Advertisement
Sign in to follow this  
FoxHunter2

Blurry ID3DXFont in windowed mode

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

If you intended to correct an error in the post then please contact us.

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
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

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
Yes that has caught me out before now. You can use GetViewport to find out what it is actually set to.

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
(chuckle) I was getting the same problem when I switched from fullscreen to windowed and yep, GetViewport fixed it, thanks aswell.

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!