Avoid creating new glyph page too many times
This commit is contained in:
parent
9734c2e890
commit
de95db5c93
@ -96,7 +96,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
|
virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
|
||||||
|
|
||||||
virtual void addLazyLoadCharacters(const wchar_t *s) {}
|
virtual u32 addLazyLoadCharacters(const wchar_t *s) { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace gui
|
} // end namespace gui
|
||||||
|
@ -114,12 +114,12 @@ CBillboardTextSceneNode::CBillboardTextSceneNode(ISceneNode* parent, ISceneManag
|
|||||||
{
|
{
|
||||||
Font = (gui::IGUIFontBitmap*)font;
|
Font = (gui::IGUIFontBitmap*)font;
|
||||||
Font->grab();
|
Font->grab();
|
||||||
u32 old_texture_count = Font->getSpriteBank()->getTextureCount();
|
u32 texture_count = Font->addLazyLoadCharacters(text);
|
||||||
Font->addLazyLoadCharacters(text);
|
_IRR_DEBUG_BREAK_IF(texture_count==0);
|
||||||
|
|
||||||
// mesh with one buffer per texture
|
// mesh with one buffer per texture
|
||||||
Mesh = new SMesh();
|
Mesh = new SMesh();
|
||||||
for (u32 i=0; i<old_texture_count; ++i)
|
for (u32 i=0; i<texture_count; ++i)
|
||||||
{
|
{
|
||||||
SMeshBuffer *mb = new SMeshBuffer();
|
SMeshBuffer *mb = new SMeshBuffer();
|
||||||
mb->Material = Material;
|
mb->Material = Material;
|
||||||
|
@ -126,13 +126,30 @@ u32 ScalableFont::getSpriteNoFromChar(const wchar_t *c) const
|
|||||||
} // getSpriteNoFromChar
|
} // getSpriteNoFromChar
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void ScalableFont::addLazyLoadCharacters(const wchar_t *c)
|
u32 ScalableFont::addLazyLoadCharacters(const wchar_t *c)
|
||||||
{
|
{
|
||||||
if (!m_face->supportLazyLoadChar()) return;
|
IGUISpriteBank* sp = m_face->getSpriteBank();
|
||||||
|
u32 tex_count = sp->getTextureCount();
|
||||||
|
if (!m_face->supportLazyLoadChar()) return tex_count;
|
||||||
|
|
||||||
m_face->insertCharacters(c);
|
m_face->insertCharacters(c);
|
||||||
m_face->updateCharactersList();
|
m_face->updateCharactersList();
|
||||||
|
|
||||||
|
// Make sure text of billboard wasn't located in the last texture
|
||||||
|
for (const wchar_t p = *c; *c; c++)
|
||||||
|
{
|
||||||
|
const core::array<SGUISprite>& s = sp->getSprites();
|
||||||
|
const FontWithFace::FontArea& area =
|
||||||
|
m_face->getAreaFromCharacter(p, NULL/*fallback_font*/);
|
||||||
|
u32 cur_tex_no = s[area.spriteno].Frames[0].textureNumber;
|
||||||
|
if (cur_tex_no == (tex_count -1))
|
||||||
|
{
|
||||||
m_face->createNewGlyphPage();
|
m_face->createNewGlyphPage();
|
||||||
|
return tex_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tex_count -1;
|
||||||
|
|
||||||
} // addLazyLoadCharacters
|
} // addLazyLoadCharacters
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
/** returns the sprite number from a given character */
|
/** returns the sprite number from a given character */
|
||||||
virtual u32 getSpriteNoFromChar(const wchar_t *c) const;
|
virtual u32 getSpriteNoFromChar(const wchar_t *c) const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
virtual void addLazyLoadCharacters(const wchar_t *s);
|
virtual u32 addLazyLoadCharacters(const wchar_t *s);
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Below is not used:
|
// Below is not used:
|
||||||
/** set an Pixel Offset on Drawing ( scale position on width ) */
|
/** set an Pixel Offset on Drawing ( scale position on width ) */
|
||||||
|
Loading…
Reference in New Issue
Block a user