16
General / Re: How to load images in a dedicated thread?
« on: December 30, 2013, 03:47:41 pm »
Thank you for your explanations so far.
Why is there a porting effort? I would've assumened, that both sf::Thread as well as std::thread is platform independent.
I tried firering a thread each time i load an image, but i think that the thread creation overhead is too big (there was still a noticeable lag). My other approach was to create the thread only once and to call launch each time i want to load an image. That however didn't work. Maybe i shouldn't call launch more than once?
Anyway, i'm not creating an sf::Image, but a sf::Texture. My understanding is that not only reading the image from disk, but also copying it to the graphics memory is a heavy operation. I'm describing this because of the weird errors i got. Is it possible, that i'm not allowed to access the graphics card from two different threads?
That sounds very interesting, i will look into that.
Quote
... the porting effort is very small anyway.
Why is there a porting effort? I would've assumened, that both sf::Thread as well as std::thread is platform independent.
I tried firering a thread each time i load an image, but i think that the thread creation overhead is too big (there was still a noticeable lag). My other approach was to create the thread only once and to call launch each time i want to load an image. That however didn't work. Maybe i shouldn't call launch more than once?
Anyway, i'm not creating an sf::Image, but a sf::Texture. My understanding is that not only reading the image from disk, but also copying it to the graphics memory is a heavy operation. I'm describing this because of the weird errors i got. Is it possible, that i'm not allowed to access the graphics card from two different threads?
Quote
If you have a good understanding of the C++11 threading library, you can also use the high-level operation std::async() which returns a std::future.
That sounds very interesting, i will look into that.