[SDL] rendering from a different thread.
Scott Harper
orcein at gmail.com
Fri Jan 4 08:44:45 PST 2008
On Jan 4, 2008, at 2:33 PM, Peter Ketting wrote:
>> afaik you can only render in the main thread - at least, I've tried
>> to no avail.
>> SDL docs seem to support this.
>
>> Ed
>
> I've succesfuly rendered using a seperate thread and it worked
> just as suspected. The way I did it was to set up a render thread
> which rendered the graphics constantly, while a timer signaled the
> main thread to process the game logic at a constant frame rate.
Sorry for my ignorance, but is this at all significantly different
from using the MAIN thread to setup a separate processing thread that
has callbacks to logic every so often, and on the main thread you
constantly render in opengl? I see this question of OpenGL rendering
from separate threads come up a lot and the answer is always "In some
cases (maybe most) you can and it's fine, but in a few you can't,"
thus the running suggestion is, "You probably aught not do it."
Taking that, it seems simple that if you want to have a thread for
rendering that is separate from your thread for processing (which
seems perfectly reasonable to me), why not make it the MAIN thread for
rendering, just to be safe, and a second thread for processing?
Is there something terribly special about the MAIN thread that you'd
rather use it for processing than rendering? I mean I've written
programs with threads, but I've not ever studied the ins and outs of
threaded systems and how they handle thread priorities and what
significance there may or may not be for threads spawned from the main
thread (or OTHER threads, even) versus the main thread itself. So...
is there a big difference?
-- Scott
PS: Sorry if it's an uneducated question.
More information about the SDL
mailing list