Since I’ve been getting these errors:
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
main: ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
EDIT: I also get this error sometimes:
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
after 48888 requests (48888 known processed) with 0 events remaining.
I am trying to make my program multithread safe so I am putting calls to SDL_LockSurface before directly accessing the pixels.
I know that these functions access the pixels:
int SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
Are there any other functions that directly access the pixels?
SDL_LockSurface is used to get direct access to the pixels, it is unrelated to multi threading.
SDL only allows you to access its library function from one thread – the one that initialized the library and video subsystem, this applies to most gfx or UI libraries.
You’d have to pull out a copy of the pixels in the main thread, and distribute them to the other threads for processing. (And assemble the result back in the main thread if you need to display something again after you’ve processed the pixels)