That’s also what I need (except I’m using GTK), and I got tired of
waiting for SDL 1.3 so I’ve been hacking on SDL 1.2.4 off and on
for the past 3 or 4 days and finally seem to have something that works:
at least, I can get a GTK test program running that has two SDL widgets
in it.
The result is a bit ugly; I’ve created a new type SDL_Window that
contains the context specific to one video surface that needs to be
passed around so that multiple windows can coexist. Unfortunately this
changed the API, so if you need any of the SDL helper libraries
(gfxPrimitives, etc.) then those would have to be modified as well.
How about using a “hidden” global variable and a “select_context()” style
API, instead of that extra argument? SDL isn’t thread safe anyway, so I
doubt this would cause any problems.
Also, I did all of this on Solaris, so it may or may not work on Linux,
and it definitely won’t work on other platforms. (I only changed the
x11 video driver code and the common library code).
I’ll give it a try!
I may have also
broken the event processing–I’m not sure, but since I use GTK for that
anyway, it’s irrelevant to me.
Well, one would need some extra info in events, to determine from which
"context" they’re coming. I have some ideas for how to hack that in. (At
least one that would preserve binary compatibility, I think.)
On the plus side, all of my changes are wrapped in appropriate #ifdef
blocks so if the macro MULTI_WINDOW is not defined in the Makefiles,
they disappear and you get an unmodified SDL 1.2.4.
Nice.
Would be even nicer if one could detect in a binary compatible way,
whether or not the currently linked SDL library is multi window capable.
(The rest of the API would have to be binary compatible for that to make
sense, of course.)
My fix is just a temporary workaround, and I took the approach that
would require the least changes to the code; the correct way to add
multi-window support requires rewriting the entire library to strip out
all those global variables.
Yeah, that’s the main reason why it hasn’t been done before, and most
probably isn’t going into 1.2.
But if there is any interest in what I’ve
done, I can make the source available. At least it’s a starting point
for anyone who wants to pursue this further and can’t wait for SDL 1.3.
Sure. I’d at least play some with it. It’s not unlikely that I
"accidentally" fix any problems I might run into. (I’m primarilly
interested in using “raw SDL”, without any normal toolkit involved, so
some fixing will probably be needed.)
Actually I’m even toying with the idea of just extracting only the
video-specific code from SDL to create a high performance GTK Canvas
widget, since that’s really what I need for my application. (I don’t
need nor care about the other subsystems: audio, joystick, event
handling, etc…)
I’ve been thinking along those lines as well. The SDL blitting API is
clean, simple and fast, and could serve as a great foundation for a
slightly higher level rendering API.
I’m occasionally working on a specialized “multimedia GUI toolkit” that
would preferably be built on something very similar to SDL. GDK could
possibly do the job, but it’s too high level IMHO. GTK+ or Qt would just
be a waste of resources, as I’d need to “bypass” most of it all the time.
I need “raw” blitting and pixel control on the RGB level, as well as
total concistency across platforms.
So, as I won’t be using Qt, GTK+ or whatever, I’ll still need basic input
handling. Thus, just using the rendering part from SDL would only be half
a solution. I’d rather “fix” SDL’s event handling, than bring some other
code base in.
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
-------------------------------------> http://olofson.net -'On Wednesday 24 April 2002 09:43, Mark Lindner wrote: