I have a thread that does the following:
In another thread there is a function that does the following:
I have read in the documentation that generally SDL lib function calls should all be from the same thread. Does this include directly changing an SDL_Surface? How about using the lock and unlock functions for the surface? I would think these lock and unlock pair are intended to be used in multi-threaded situations.
How about the SDL_Flip function? If this needs to be called from the SDL thread that initialzed SDL, then I could simply signal a user event and handle it in the other thread.
The lock/unlock on SDL_Surfaces are to handle backends that place bitmaps in something other than system memory. Locking a surface pulls the bitmap back into system memory for modifications, while unlock pushes it back out.
They are not for multithreading.
You might be able to get by with locking/unlocking the surface in the main thread and passing the bitmap pointer to your worker thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With