[SDL] SDL_UpdateRect in Multithreaded App
slouken at devolution.com
Tue Jul 23 11:04:01 PDT 2002
> Hi all,
> I'm not a guru of SDL, want a little tip. I have an
> app with multiple threads, having different thread
> change the same surface. I use lock/unlock surface ,
> but what about the SDL_UpdateRect()? I guess the
> problem of Xlib: unexpected async reply is because of
> the problem of UpdateRect from one thread while the
> other thread is modifying the surface contents.
Yup, don't do any graphics calls from a thread besides the main one.
If you really need separate threads updating a surface, make sure that
you use only software surfaces, do the thread-safe locking yourself,
and then signal the main thread when the surface needs to be displayed,
so it can call update rects.
-Sam Lantinga, Software Engineer, Blizzard Entertainment
More information about the SDL