I have a thread that does the following:
- Initializes SDL
- Stores a pointer to the SDL_Surface
- Goes into a loop and waits for any mouse events and processes them
In another thread there is a function that does the following:
- Gets the pointer to the SDL_Surface
- Does a SDL_LockSurface
- Manipulates the pixels
- Does a SDL_UnlockSurface
- Calls SDL_Flip on the surface
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.