Archived

This topic is now archived and is closed to further replies.

Mythomania

Text in DX8 without D3DX

Recommended Posts

EAX    136
Perhaps you could make a font image, that contains every letter of the alphabet, and then use that as your font, just display the appropriate letters in the right places.

I doubt this will help, but it''s how I put text in my tile engine.

EAX

Share this post


Link to post
Share on other sites
Oluseyi    2107
Arbitrary text in arbitrary fonts, arbitrary text in a fixed font or fixed text in fixed fonts?

The first is a large scope problem which I don''t even feel like discussing here. The second is a question of prerendering each of the characters in the font into a tileset and using their scan codes (or some other hash function thereof) as indices while the third is best done by prerendering the entire text if it''s of reasonable size, or using the same method as the second if there''s a decent amount.



I wanna work for Microsoft!

Share this post


Link to post
Share on other sites
invective    118
If you need a small exe, and you need to create the font dynamically, instead of just loading it as a texture, you are going to have to do something like what the font class does anyways, and use GDI to make the font, then stick it into a texture. You can edit the D3Dfont class and cut out the functionality you don''t need to reduce code size. Alternatively, you can draw the font with a bunch of line lists, but that doesn''t sound very fun to me.

Share this post


Link to post
Share on other sites
CrazedGenius    156
Does D3DX bloat the exe? If so, by how much?

Correct me if this is wrong:

D3DX includes a whole bunch of basic functions in a DLL, so they add very little to the size of your exe. If you write even a couple matrix functions, you are expanding the size of your exe much more than the D3DX stub calls would AND and the D3DX DLL is still taking up space on your harddrive.

Why would you do this?

Edited by - CrazedGenius on November 13, 2001 10:25:05 AM

Share this post


Link to post
Share on other sites
S1CA    1418
The debug version of D3DX (d3dx8d.lib) is indeed in a DLL. However, AFAIK it doesn''t ship in the retail runtimes, so it''d have to shipped with the app. Which would kinda break the rules for a 64k demo.

The release version of D3DX is a static library (d3dx8.lib), depending on the version, you may get some bloat. Certain linker options should help to strip any unused stuff (although there is a certain amount of interdependency inside D3DX - for example if you want to create a texture to recieve the font, you''d also have to have the stuff for texture filtering etc).

The GDI solution would be the one I''d choose if I were making something which needed to be 64k. Just write the font out to a texture at startup, then use that at runtime.


--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
CrazedGenius    156
Duh... sorry, I wasn't thinking... I'd be curious to see what the bloat actually is with a decent linker. It just seems like creating/maintaining equivalent functions would be an easily avoidable headache. But then again, if you have solid size requirements...

Edited by - CrazedGenius on November 13, 2001 1:51:37 PM

Share this post


Link to post
Share on other sites
Mythomania    122
First thanx for all your help.

@bloat: i had an exe of 10kb size (after packing). when i linked to the d3dx without using it it stayed the same. so unnecessary stuff was obviously left out. when i ONLY used the font stuff i got a 100kb exe AFTER packing....bit big ;-)

now to your solution: how do i use gdi to put the font into a texture? i never really worked with fonts. neither with gdi.
what does a font handle represent? can i get the actual graphics data from that handle?

Share this post


Link to post
Share on other sites
invective    118
Basically, you need to make a bitmap, get a device contect for the bitmap, and then select a font and output the text to the bitmap. Then you copy the bitmap bits into a direct3d texture, which is pretty much what the font sample does. I do not believe there is a way to get a device context for the back buffer surface, like you used to be able to do in directdraw.

Share this post


Link to post
Share on other sites