Blitting from a seperate thread

I’m currently in the process of writing a SDL driver for BasiliskII (a GPL
Mac emulator), and I’m modelling it around the current X driver.

The current X driver is launching a seperate thread to do the blitting when a
software surface is present.

I read in the docs that doing this with SDL is a bad idea. To what extent is
this true?–
– Michael Samuel

I’m currently in the process of writing a SDL driver for BasiliskII (a GPL
Mac emulator), and I’m modelling it around the current X driver.

The current X driver is launching a seperate thread to do the blitting when a
software surface is present.

I read in the docs that doing this with SDL is a bad idea. To what extent is
this true?

You should always call video functions like SDL_UpdateRects() from the thread
which set the display mode. You can do blitting from any thread you like.
If you have more than one thread performing blitting, you’ll need some way
of synchronizing the access to the target surface. Passing SDL_THREADSAFE
as one of the flags to SDL_AllocSurface() or SDL_SetVideoMode() may be what
you want.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/