[SDL] SDL_UpdateRect in Multithreaded App

Robert Wohleb rwohleb at r2tech.com
Tue Jul 23 11:15:01 PDT 2002


Can you use a video card surface in a thread if you guarantee that no other
thread is using the surface at the same time? Or is part of the SDL library
the problem?

~Rob

-----Original Message-----
From: Sam Lantinga [mailto:slouken at devolution.com]
Sent: Tuesday, July 23, 2002 11:03 AM
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