[SDL] SDL_UpdateRect in Multithreaded App

Oliver van Porten [mcdeck] mcdeck at linuxbites.de
Sat Jul 27 03:22:00 PDT 2002


-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Sam Lantinga
Sent: Tuesday, July 23, 2002 8:03 PM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_UpdateRect in Multithreaded App


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

See ya,
	-Sam Lantinga, Software Engineer, Blizzard Entertainment

_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list