mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- Added preloading of fonts to reduce the chance that characters from a single
font will require more than one hardware texture to display. SVN r717 (trunk)
This commit is contained in:
parent
4c9d633a94
commit
499fefec07
4 changed files with 52 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
January 26, 2008
|
||||
- Added preloading of fonts to reduce the chance that characters from a single
|
||||
font will require more than one hardware texture to display.
|
||||
- Fixed: P_RailAttack() crashed if you didn't specify a puff for a rail.
|
||||
- Decided that allowing arbitrary alpha values for color remaps isn't so hot.
|
||||
Changed it back the way it was.
|
||||
|
|
|
@ -741,6 +741,50 @@ int FFont::GetCharWidth (int code) const
|
|||
return Chars[code - FirstChar].Pic->GetScaledWidth();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FFont :: Preload
|
||||
//
|
||||
// Loads most of the 7-bit ASCII characters. In the case of D3DFB, this
|
||||
// means all the characters of a font have a better chance of being packed
|
||||
// into the same hardware texture.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FFont::Preload() const
|
||||
{
|
||||
// First and last char are the same? Wait until it's actually needed
|
||||
// since nothing is gained by preloading now.
|
||||
if (FirstChar == LastChar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = MAX(FirstChar, 0x21); i < MIN(LastChar, 0x7e); ++i)
|
||||
{
|
||||
int foo;
|
||||
FTexture *pic = GetChar(i, &foo);
|
||||
if (pic != NULL)
|
||||
{
|
||||
pic->GetNative(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FFont :: StaticPreloadFonts
|
||||
//
|
||||
// Preloads all the defined fonts.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FFont::StaticPreloadFonts()
|
||||
{
|
||||
for (FFont *font = FirstFont; font != NULL; font = font->Next)
|
||||
{
|
||||
font->Preload();
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -91,8 +91,10 @@ public:
|
|||
int GetSpaceWidth () const { return SpaceWidth; }
|
||||
int GetHeight () const { return FontHeight; }
|
||||
int GetDefaultKerning () const { return GlobalKerning; }
|
||||
void Preload() const;
|
||||
|
||||
static FFont *FindFont (const char *fontname);
|
||||
static void StaticPreloadFonts();
|
||||
|
||||
// Return width of string in pixels (unscaled)
|
||||
int StringWidth (const BYTE *str) const;
|
||||
|
|
|
@ -1386,6 +1386,10 @@ bool V_DoModeSetup (int width, int height, int bits)
|
|||
screen->SetFont (SmallFont);
|
||||
screen->SetGamma (Gamma);
|
||||
|
||||
// Load fonts now so they can be packed into textures straight away,
|
||||
// if D3DFB is being used for the display.
|
||||
FFont::StaticPreloadFonts();
|
||||
|
||||
{
|
||||
int ratio;
|
||||
int cwidth;
|
||||
|
|
Loading…
Reference in a new issue