1

由于我一直收到这些错误:

[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.

编辑:有时我也会收到此错误:

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
  after 48888 requests (48888 known processed) with 0 events remaining.

我试图使我的程序多线程安全,所以我在直接访问像素之前调用 SDL_LockSurface。

我知道这些函数访问像素:

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);

还有其他直接访问像素的功能吗?

4

1 回答 1

2

SDL_LockSurface 用于直接访问像素,它与多线程无关。

SDL 只允许您从一个线程访问其库函数 - 初始化库和视频子系统的线程,这适用于大多数 gfx 或 UI 库。

您必须在主线程中提取像素副本,并将它们分发给其他线程进行处理。(如果在处理完像素后需要再次显示某些内容,则将结果组合回主线程)

于 2012-10-29T19:42:46.930 回答