We don't need to add a new glyph page for billboard text anymore
This commit is contained in:
parent
46be4948b2
commit
c4b4ea006e
@ -95,8 +95,6 @@ public:
|
||||
\param s String of symbols which are not send down to the videodriver
|
||||
*/
|
||||
virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
|
||||
|
||||
virtual u32 addLazyLoadCharacters(const wchar_t *s) { return 0; }
|
||||
};
|
||||
|
||||
} // end namespace gui
|
||||
|
@ -114,12 +114,10 @@ CBillboardTextSceneNode::CBillboardTextSceneNode(ISceneNode* parent, ISceneManag
|
||||
{
|
||||
Font = (gui::IGUIFontBitmap*)font;
|
||||
Font->grab();
|
||||
u32 texture_count = Font->addLazyLoadCharacters(text);
|
||||
_IRR_DEBUG_BREAK_IF(texture_count==0);
|
||||
|
||||
// mesh with one buffer per texture
|
||||
Mesh = new SMesh();
|
||||
for (u32 i=0; i<texture_count; ++i)
|
||||
for (u32 i=0; i<Font->getSpriteBank()->getTextureCount(); ++i)
|
||||
{
|
||||
SMeshBuffer *mb = new SMeshBuffer();
|
||||
mb->Material = Material;
|
||||
|
@ -29,6 +29,8 @@ class FaceTTF;
|
||||
class DigitFace : public FontWithFace
|
||||
{
|
||||
private:
|
||||
virtual bool supportLazyLoadChar() const OVERRIDE { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual unsigned int getGlyphPageSize() const OVERRIDE { return 256; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual float getScalingFactorOne() const OVERRIDE { return 0.7f; }
|
||||
@ -43,8 +45,6 @@ public:
|
||||
virtual void init() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void reset() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool supportLazyLoadChar() const OVERRIDE { return false; }
|
||||
|
||||
}; // DigitFace
|
||||
|
||||
|
@ -92,6 +92,39 @@ protected:
|
||||
/** Used in top side bearing calculation. */
|
||||
int m_glyph_max_height;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Check characters to see if they are loaded in font, if not load them.
|
||||
* For font that doesn't need lazy loading, nothing will be done.
|
||||
* \param in_ptr Characters to check.
|
||||
* \param first_load If true, it will ignore \ref supportLazyLoadChar,
|
||||
* which is called in \ref reset. */
|
||||
void insertCharacters(const wchar_t* in_ptr, bool first_load = false)
|
||||
{
|
||||
if (!supportLazyLoadChar() && !first_load) return;
|
||||
|
||||
for (const wchar_t* p = in_ptr; *p; ++p)
|
||||
{
|
||||
if (*p == L'\r' || *p == L'\n' || *p < (wchar_t)32)
|
||||
continue;
|
||||
if (!loadedChar(*p))
|
||||
{
|
||||
loadGlyphInfo(*p);
|
||||
if (supportChar(*p))
|
||||
addLazyLoadChar(*p);
|
||||
else if (m_fallback_font != NULL)
|
||||
{
|
||||
if (!m_fallback_font->loadedChar(*p))
|
||||
{
|
||||
m_fallback_font->loadGlyphInfo(*p);
|
||||
if (m_fallback_font->supportChar(*p))
|
||||
m_fallback_font->addLazyLoadChar(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void updateCharactersList();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Set the fallback font for this font, so if some character is missing in
|
||||
* this font, it will use that fallback font to try rendering it.
|
||||
@ -203,6 +236,8 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
void loadGlyphInfo(wchar_t c);
|
||||
// ------------------------------------------------------------------------
|
||||
void createNewGlyphPage();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Add a character into \ref m_new_char_holder for lazy loading later. */
|
||||
void addLazyLoadChar(wchar_t c) { m_new_char_holder.insert(c); }
|
||||
// ------------------------------------------------------------------------
|
||||
@ -210,6 +245,9 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
void setDPI();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override it if sub-class should not do lazy loading characters. */
|
||||
virtual bool supportLazyLoadChar() const { return true; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Defined by sub-class about the texture size of glyph page, it should be
|
||||
* a power of two. */
|
||||
virtual unsigned int getGlyphPageSize() const = 0;
|
||||
@ -263,44 +301,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return the dpi of this face. */
|
||||
unsigned int getDPI() const { return m_face_dpi; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override it if sub-class should not do lazy loading characters. */
|
||||
virtual bool supportLazyLoadChar() const { return true; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Check characters to see if they are loaded in font, if not load them.
|
||||
* For font that doesn't need lazy loading, nothing will be done.
|
||||
* \param in_ptr Characters to check.
|
||||
* \param first_load If true, it will ignore \ref supportLazyLoadChar,
|
||||
* which is called in \ref reset. */
|
||||
void insertCharacters(const wchar_t* in_ptr, bool first_load = false)
|
||||
{
|
||||
if (!supportLazyLoadChar() && !first_load) return;
|
||||
|
||||
for (const wchar_t* p = in_ptr; *p; ++p)
|
||||
{
|
||||
if (*p == L'\r' || *p == L'\n' || *p < (wchar_t)32)
|
||||
continue;
|
||||
if (!loadedChar(*p))
|
||||
{
|
||||
loadGlyphInfo(*p);
|
||||
if (supportChar(*p))
|
||||
addLazyLoadChar(*p);
|
||||
else if (m_fallback_font != NULL)
|
||||
{
|
||||
if (!m_fallback_font->loadedChar(*p))
|
||||
{
|
||||
m_fallback_font->loadGlyphInfo(*p);
|
||||
if (m_fallback_font->supportChar(*p))
|
||||
m_fallback_font->addLazyLoadChar(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void updateCharactersList();
|
||||
// ------------------------------------------------------------------------
|
||||
void createNewGlyphPage();
|
||||
|
||||
}; // FontWithFace
|
||||
|
||||
|
@ -518,9 +518,8 @@ u64 STKTexture::getHandle()
|
||||
|
||||
if (!glIsTextureHandleResidentARB(m_texture_handle))
|
||||
glMakeTextureHandleResidentARB(m_texture_handle);
|
||||
|
||||
return m_texture_handle;
|
||||
#endif
|
||||
return m_texture_handle;
|
||||
} // getHandle
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -127,33 +127,5 @@ u32 ScalableFont::getSpriteNoFromChar(const wchar_t *c) const
|
||||
return area.spriteno;
|
||||
} // getSpriteNoFromChar
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
u32 ScalableFont::addLazyLoadCharacters(const wchar_t *c)
|
||||
{
|
||||
IGUISpriteBank* sp = m_face->getSpriteBank();
|
||||
u32 tex_count = sp->getTextureCount();
|
||||
if (!m_face->supportLazyLoadChar()) return tex_count;
|
||||
|
||||
m_face->insertCharacters(c);
|
||||
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();
|
||||
return tex_count;
|
||||
}
|
||||
}
|
||||
|
||||
return tex_count -1;
|
||||
|
||||
} // addLazyLoadCharacters
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
@ -86,8 +86,6 @@ public:
|
||||
/** returns the sprite number from a given character */
|
||||
virtual u32 getSpriteNoFromChar(const wchar_t *c) const;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual u32 addLazyLoadCharacters(const wchar_t *s);
|
||||
// ------------------------------------------------------------------------
|
||||
// Below is not used:
|
||||
/** set an Pixel Offset on Drawing ( scale position on width ) */
|
||||
virtual void setKerningWidth (s32 kerning) {}
|
||||
|
Loading…
Reference in New Issue
Block a user