Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Can I call sf::Texture::update(sf::Image) from another thread?  (Read 1439 times)

0 Members and 1 Guest are viewing this topic.

Jamin Grey

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Of Stranger Flames
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.
Of Stranger Flames - My work-in-progress para-historical (and classically-inspired) 2D rpg.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Can I call sf::Texture::update(sf::Image) from another thread?
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/