You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some SFML classes use the m_cacheId to optimize the code. Because this is private, it can't be used from the outside.
One trick is to use the same name for a class (sf::Text) so you can friend sf::Texture and use this member internally. The downside is you get problems if someone or some dependency includes the original sf::Text (class redefinition).
My suggestion is to add some way to verify if a texture changed since its last use.
voidText::ensureGeometryUpdate() const
{
if (!m_font)
{
return;
}
// Do nothing, if geometry has not changed and the font texture has not changedif (!m_geometryNeedUpdate && m_font->getTexture(m_characterSize).m_cacheId == m_fontTextureId)
{
return;
}
I can't compile it with Clang because of the existing sf::text conflict. msvc and gcc compile ok. I can remove the cache check and rename it to sf::Text2 and then it works on all compilers, but it will always be slower than the original implementation.
I only use it to draw this wall of text:
Another reason is that I'm migrating to C++20 modules and I can't have this trick of using the existing name to get the friend access to m_cacheId as easily.
Some SFML classes use the
m_cacheId
to optimize the code. Because this is private, it can't be used from the outside.One trick is to use the same name for a class (sf::Text) so you can friend sf::Texture and use this member internally. The downside is you get problems if someone or some dependency includes the original sf::Text (class redefinition).
My suggestion is to add some way to verify if a texture changed since its last use.
related forum posts:
https://en.sfml-dev.org/forums/index.php?topic=14560.0
The text was updated successfully, but these errors were encountered: