• Advertisement
Sign in to follow this  

Using D3DXFont in a GUI Engine. Need Help.

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

Hello folks, I am trying to update my GUI engine and having thoughts of using D3DXFont for my text rendering. Currently, i have been using the original CD3DFont class that came with the old version of DXSDK. Thru the years this custom class have evolved in my engine to perform actions needed in a GUI. But this time i am trying to replace it with D3DXFont. Now my question is, how do i access the vertex buffers of the quads representing the fonts to be rendered? The reason i need this is so that i can render stuff like underline, striking, background highlight, etc... to a specified portion of the text to be rendered. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by harmless
But this time i am trying to replace it with D3DXFont. Now my question is, how do i access the vertex buffers of the quads representing the fonts to be rendered? The reason i need this is so that i can render stuff like underline, striking, background highlight, etc... to a specified portion of the text to be rendered.
You don't without a fair bit of hacking around. ID3DXFont uses a ID3DXSprite for rendering. You could provide your own ID3DXSprite implementation, and pass that to ID3DXFont::Draw, but that would be pretty hacky and horrible.

The other alternative is to not use ID3DXFont; it's just a helper function, it's not designed to be a fully functional text interface or anything. If you need control that it doesn't provide, you'll have to write your own text rendering system.

If you do go for the custom ID3DXSprite route, just create a class derived from ID3DXSprite, implement all the virtual methods, then pass a pointer to that class to ID3DXFont::Draw. ID3DXFont will draw multiple sprites, one for each glyph. It'll also generate textures (Glyphs rendered to a texture). I seem to recall that they're not very well spaced out on the texture, and there's a lot of wasted space. Personally, I just wrote my own font rendering engine.

A while ago, I wrote A Journal Entry on what ID3DXSprite and ID3DXFont do internally (Although that was with a fairly old SDK now).

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by harmless
But this time i am trying to replace it with D3DXFont. Now my question is, how do i access the vertex buffers of the quads representing the fonts to be rendered? The reason i need this is so that i can render stuff like underline, striking, background highlight, etc... to a specified portion of the text to be rendered.
You don't without a fair bit of hacking around. ID3DXFont uses a ID3DXSprite for rendering. You could provide your own ID3DXSprite implementation, and pass that to ID3DXFont::Draw, but that would be pretty hacky and horrible.

The other alternative is to not use ID3DXFont; it's just a helper function, it's not designed to be a fully functional text interface or anything. If you need control that it doesn't provide, you'll have to write your own text rendering system.

If you do go for the custom ID3DXSprite route, just create a class derived from ID3DXSprite, implement all the virtual methods, then pass a pointer to that class to ID3DXFont::Draw. ID3DXFont will draw multiple sprites, one for each glyph. It'll also generate textures (Glyphs rendered to a texture). I seem to recall that they're not very well spaced out on the texture, and there's a lot of wasted space. Personally, I just wrote my own font rendering engine.

A while ago, I wrote A Journal Entry on what ID3DXSprite and ID3DXFont do internally (Although that was with a fairly old SDK now).


Thanks for the feedback.

I do have a custom font class as i mentioned in my original post. It was derived from the original CD3DFont class that came with the early versions of DX8 SDK several years ago. As i have been using it since then, it has evolved in such a way that it's got all the features i need for my GUI engine. However, i thought about replacing it with ID3DXFont. However, i might just stick out with my existing custom font class if i have to redo almost all the features that i needed which already existed in my font class.

Share this post


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

  • Advertisement