SFML community forums

Help => Graphics => Topic started by: Jamin Grey on July 20, 2013, 10:02:38 pm

Title: Can I call sf::Texture::update(sf::Image) from another thread?
Post by: Jamin Grey on July 20, 2013, 10:02:38 pm
I want to load a sf::Texture from memory, return it immediately, but start a new thread (using C++11's std::thread) that will (in a local thread-owned sf::Image) modify the pixel that, and upload the new pixel data when finished.

Can I call sf::Texture::update(sf::Image) from this new thread? My code doesn't call that specific function anyplace else, though it's possible the texture could be getting drawn at the exact same time.
Title: Re: Can I call sf::Texture::update(sf::Image) from another thread?
Post by: eXpl0it3r on July 20, 2013, 10:35:02 pm
You can call it, but it will have some undefined results if the texture is being used at the same time, thus you'll have to make sure, that the texture isn't being used in the meantime, which means you're most likely want to use some locks.