Sign in to follow this  

ID3DXFont generated textures - how do I access them?

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

I am using the ID3DXFont/sprite utility in DX9 to render text to the screen. I would like to use a pixel shader to enhance the text when rendering it. Primarily I'm trying to improve the smoothing/anti-aliasing on the text. Does anyone know how to access the texture that ID3DXFont generates for the font so I can sample from it? I tried getting it using the DC of the font, but that just seems to be a compatible DC not the actual DC of the surface of the texture. I've searched the forums and google and found one thread on here where someone said they used a pixel shader, but I'm not sure how they used the texture from ID3DXFont. The thread is here (and is locked or I would've posted there): http://www.gamedev.net/community/forums/topic.asp?topic_id=529421 Any help would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Its not possible to get the textures generated by the ID3DXFont, after all it does not generate a whole TEXT texture, but gliphs with symbols that are local to the object (generated with GDI, and you don't know how many of them) and does lots of draws to create the whole text on screen with different texture coordinates.
You have 3 choices :

1) Use different render target, render the texture to that render target and reuse it to do the second pass on the pixel shader to smooth it.
2) Recreate the ID3DXFont so you can use whole text textures (in this case try to take a look at my blog for some ideas as i've already done it and it work quite well)
3) Mess out with the DC and GDI. (not good imho)

Share this post


Link to post
Share on other sites
The only way you could do it is by passing a proxy IDirect3DDevice9 to D3DXCreateFont, and intercepting the calls to CreateTexture() to create your own proxy textures, and to then handle the locking and unlocking of the textures to grab the pixel information.

Although that's a pretty horrible way to do things - you'd be best off writing your own font renderer. ID3DXFont is just a helper class, it's not supposed to be any sort of ultimate solution.

Share this post


Link to post
Share on other sites
It sure would be nice if ID3DXFont could just antialias text properly :P

I'm interested in a rewritten font renderer, has anyone else already recreated a DirectX 9 font renderer and made it public?

Share this post


Link to post
Share on other sites
Quote:
Original post by AshleysBrain
I'm interested in a rewritten font renderer, has anyone else already recreated a DirectX 9 font renderer and made it public?
I've written one, but it's pretty mixed in with some of my engine stuff (In particular my texture atlas and sprite code), and there's a few minor bugs.

If you want it anyway; PFont.h and PFont.cpp

Share this post


Link to post
Share on other sites

This topic is 3100 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.

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