[SDL] Blitting / event handling with multiple threads

Gabriele Greco gabriele.greco at darts.it
Mon Jan 31 07:39:34 PST 2005

Christian Morgner wrote:
> Is there any possibility to call each object's draw() method (where a lot
> of blitting is done) from a separate thread, so that only this particular
> thread has to run at 60-80 loops/sec. and the other ones are only
> limitated by the CPU speed?

What's the point to draw an object 81+ times per second to a surface if 
you know that that particular surface will be displayed only 60/80 times 
per second?

I think you need to separate better the game logic from the actual 
drawing to the display.

The game logic have to choose the position of an object and the frame to 
display (based on collisions, events...).

The display loop should only draw the object on the screen.

This can be done in a single thread without problems, or, if you like, 
also with 2 threads with a mutex to arbitrate the access to the object 

Anyway a multithreaded program that keep 2 idle thread on a single 
processor machine is always slower than the same program built with a 
single thread approach.


More information about the SDL mailing list