ID3DXFont questions
I looked up ID3DXFont on MSDN, and it is incredibly vague about some things. If someone could explain these things I''d appreciate it.
First of all, what exactly should I give to PreloadCharacters? I''m going to be using most letters, so should I just call it like this:
pFont->PreloadCharacters(''0'', ''9'');
pFont->PreloadCharacters(''A'', ''Z'');
pFont->PreloadCharacters(''a'', ''z'');
Also, how exactly does PreloadText work? Does it only speed things up if I have EXACTLY that text and does nothing if I have the same text plus one more character? For example, say I do this:
// After the font has been created
pFont->PreloadText("Kills: ", 7);
// in Render()
char szBuf[20];
sprintf(szBuf, "Kills: %i", m_iKills);
pFont->DrawText(NULL, szBuff, /*other stuff*/);
Will the PreloadText make a difference or not? MSDN isn''t very specific.
I am wondering this too, because I am seeing no performance increase by preloading text that never changes once it''s loaded. It may only be an improvement means for a common set of strings that will be used over time.
i.e.
Text1 = "Text1";
Text2 = "Text2";
Text3 = "Text3";
etc...
PreloadText(Text1, Text1.Length());
PreloadText(Text2, Text2.Length());
PreloadText(Text3, Text3.Length());
Then, every frame, you switch which text is displayed. Since all 3 are preloaded, the font object has already rendered the text to memory and just displays it, instead of having to re-render it.
I believe that the font object checks it''s current call to the previous call, and if it is the same text as the previous call, displays the previously rendered text. That is why using PreloadText for text that doesn''t change is pointless.
Again, this is my observation, the MSDN doesn''t say much.
Chris
i.e.
Text1 = "Text1";
Text2 = "Text2";
Text3 = "Text3";
etc...
PreloadText(Text1, Text1.Length());
PreloadText(Text2, Text2.Length());
PreloadText(Text3, Text3.Length());
Then, every frame, you switch which text is displayed. Since all 3 are preloaded, the font object has already rendered the text to memory and just displays it, instead of having to re-render it.
I believe that the font object checks it''s current call to the previous call, and if it is the same text as the previous call, displays the previously rendered text. That is why using PreloadText for text that doesn''t change is pointless.
Again, this is my observation, the MSDN doesn''t say much.
Chris
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement