#### Archived

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

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

## Recommended Posts

I don''t want to use the other font thing (CD3DFont class) included in the directx installation because you can''t pass in a rect as a parameter to clip the text, which I definatly need.. so I want to use ID3DXFont (even though its slower) but I am having trouble setting it up and using it. If anyone has sucessfully used it could you post your code here, from setting up the font interface to writing a simple message to the screen..........please or is there any examples or tutorials on the net? p.s. why are there no microsoft DirectX examples that use the ID3DXFont interface? (or are there?)

##### Share on other sites
c''mon guys! (or gals?)
Has no-one used the ID3DX interface..

Most of the times when I have posted on gamedev I have found a solution to my problem before I have finished writing
(It helps to think things through)
not this time though

##### Share on other sites
I''ve got another DX question (if no-one wants to answar my previous question):
why can I only load .bmp files from resources into textures, when I can load about 15 different file formats if I load them straight from file using createtexturefromfile??? What if I want to use a .tga as resource (compile it into my .exe) and load it into my texture, is it possible?
The only reason I want tga, and not .bp is because I can have 32-bit .tga''s that support alpha-layers ----- is there a way to use 2 bitmaps, one normal one alpha-layer, to load into a texture ?

##### Share on other sites
For your original question, it''s pretty easy. This should work without too many modifications:

  // at initializationLOGFONT lf;HFONT hFont;lf.lfHeight = 62;lf.lfWidth = 0;lf.lfEscapement = 0;lf.lfOrientation = 0;lf.lfWeight = FW_BOLD;lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;lf.lfCharSet = 0;lf.lfOutPrecision = lf.lfClipPrecision = lf.lfQuality = 0;lf.lfPitchAndFamily = 0;sprintf(lf.lfFaceName, "Arial");hFont = CreateFontIndirect(&lf);if(FAILED(D3DXCreateFont(m_pDevice, hFont, &m_pFont))){ m_pFont = NULL;}DeleteObject(hFont);// at shutdownif(m_pFont){ m_pFont->Release(); m_pFont = NULL;}// to draw textif(m_pFont){char str[] = "This is a test";RECT r;r.left = 1;r.top = 1;r.bottom = 60;r.right = 180;m_pFont->DrawTextA(str, -1, &r, DT_LEFT | DT_WORDBREAK, D3DCOLOR_XRGB(255, 255, 255));}

##### Share on other sites
quote:
Original post by stevenmarky
I''ve got another DX question (if no-one wants to answar my previous question):
why can I only load .bmp files from resources into textures, when I can load about 15 different file formats if I load them straight from file using createtexturefromfile??? What if I want to use a .tga as resource (compile it into my .exe) and load it into my texture, is it possible?
The only reason I want tga, and not .bp is because I can have 32-bit .tga''s that support alpha-layers ----- is there a way to use 2 bitmaps, one normal one alpha-layer, to load into a texture ?

U can use D3DXLoadTextureFromResource() to load TGA, JPEG, etc.. from the exe.

##### Share on other sites
"U can use D3DXLoadTextureFromResource() to load TGA, JPEG, etc.. from the exe. "
what is this, this is''nt documented? did you mean D3DXLoadSurfaceFromResourceA()
(I looked it up)

##### Share on other sites
Thank you, jaxson, you''ve helped me out a lot there

• 43
• 11
• 17
• 11
• 13