[SDL] SDL with Windows
Doug
biteme at bitbasher.net
Thu Oct 5 05:59:55 PDT 2006
In article <loom.20061005T001444-834 at post.gmane.org>,
mrambhatla at phoenixworldwide.com says...
>
>Can I open multiple instances of SDL from the same application?
You can have multiple off-screen SDL surfaces in one instance of an app, but
you can only really have one display SDL surface per process (which includes
all threads within the main process).
[sidenote: trying to use SDL from different threads within the same process
sometimes works (depending on what SDL features you use in the threads), but
it's uber risky]
I got around this (in Windows only) by creating a SharedMemory class, which
handles scheduling, interlocking, and synchronization. Then I spawn these
little mini-SDL rendering apps, which most of the time just
WaitForSingleObject() on an appropriate rendering event. When the event for
a rendering mini-app is signaled, the little mini-app just gets the "data" it
needs from the shared memory.
The main app does all "tough" work, but relies on the little mini-rendering
apps to do the drawing. In my case, I've got the main app managing 4 USB
digital cameras. When all the cameras are in viewfinder mode, they spit
frames at me fast-and-furious. I just route the frame data to the
appropriate shared memory and then set the event for that rendering mini-app.
So far all four mini-apps are doing just fine, each rendering 320x240 30fps
video, and none of the mini-apps nor the main app consume 100% CPU. Also,
the SDL gfx library works well as I use it to decompress the JPEG frames.
Doug.
More information about the SDL
mailing list