SFML community forums

Help => Graphics => Topic started by: 1aam2am1 on June 22, 2017, 11:56:53 pm

Title: Font not loaded
Post by: 1aam2am1 on June 22, 2017, 11:56:53 pm
When I first create sf::Font object and then use this font for many sf::Text objects.
Next I draw them(main thread)
Next to main thread I launch (resource loading thread), where sf::Font is loaded.
The bug is if the text was first drawn. Then even when we load font, nothing is drawn.
Title: Re: Font not loaded
Post by: eXpl0it3r on June 23, 2017, 12:44:34 pm
IIRC you need to re-setFont on the text objects if you change the font.
Additionally loading the font in a separate thread isn't really adviced. OpenGL isn't multithreaded and you need to synchronize the font object, making the threaded loading pretty much pointless.
If you do run into performance issues due to loading, I recommend you just load the file from disk into memory in a separate thread and the call loadFromMemory in the main thread.
Title: Re: Font not loaded
Post by: 1aam2am1 on June 24, 2017, 10:48:41 pm
I want oryginalny load textures and sound. In thread pool. And this happened due to testing buttons witch text in the main thread. The issue is can't the code in sf::Text ensure that event if the font is set but not loaded the m_geometryNeedUpdate will be false. This is very simple to code event is current api.