Jump to content
  • Advertisement
Sign in to follow this  
Dizzy_exe

OpenGL Problems with bitmap fonts in DirectX

This topic is 4871 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

This thing is driving me nuts! I'm writing a DirectX implementarion for my 3D renderer and I have problems displaying bitmap fonts. In OpenGL the text is sharp an looks pretty good, but in DirectX (using the same algorithm) it's all fuzzy and it seems that the renderer does some weird sampling to the font texture. Here are the 2 screenshots: OpenGL: Image hosted by Photobucket.com DirectX: Image hosted by Photobucket.com Does anyone know what parameters must be set in the Direct3D renderer to achieve the OpenGL image clarity?

Share this post


Link to post
Share on other sites
Advertisement
Take a look at IDirect3DDevice9::SetSampler() - you are probably going to want to mess around with the mag, min, and mip filters. To start out, try setting them to D3DTEXF_NONE, since your output is very blurry.

I would also examine your texture coordinates or source bitmap, because it looks like some characters (ie 's' and '8') are offset from the rest.

Share this post


Link to post
Share on other sites
I had somtehing similar, but I was using ID3DXFont. There the problem was that I didnt render the fonts as the last one and that messed up the alphablending. But if you say its the same algo as for OGL, yeah it can be that the samplers are off. Keep in mind thou, that using ID3DXSprite for bitmap fonts sets its own samplers a Begin(), so the render states cant possibily be off.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
First, thank you all for answering!

I partially solved the problem. There where 2 bugs:
- when I created the window I didn't take into account the window border so the client area was smaller then what I requested
- I had to change the coordinates with half a pixel in order to correctly map the txels to pixels (thanks sirob)

But something similar happens when I resize the window. Any ideas?

PS: More info: My renderer changes into a 2D state for 2D drawing using ortographic projections. For OpenGL I use glOrtho. For DirectX I use D3DXMatrixOrthoOffCenterRH. I set the following sampler parameters:
m_device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
m_device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
The rendering is done with display lists in OpenGL and a dynamic vertex buffer in Directx.
When I resize the window in OpenGL the text looks the same, but in DirectX it begins to get fuzzy all over again.

Share this post


Link to post
Share on other sites
Check your MIPMAP settings for the font texture? They, along with the sampler states, can greatly influence your text quality. Especially when you need arbitrary sized characters.

Share this post


Link to post
Share on other sites
Solved it.

It seems that DirectX doesn't automatically resize the backbuffer so when the window size is changed on Present it stretches the old backbuffer on the new client area.

Thread can be closed now.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!