Multiple SDL Surfaces

Hello

I am thinking about using SDL in a project. After
looking over the SDL docs and taking a brief look at
the source, it appears to me that SDL does not allow
the creating of multiple surfaces per application.
Does anyone know of any plans to implement this type
of functionality in SDL anytime soon.

Thanks
Mark=====
Mark Jones
@Mark_Jones


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

You can create multiple surfaces. You can’t create multiple windows,
though. Is that what you are trying to accomplish?> ----- Original Message -----

From: markalanj@yahoo.com (Mark Jones)
To:
Sent: Friday, April 12, 2002 11:31 PM
Subject: [SDL] Multiple SDL Surfaces

Hello

I am thinking about using SDL in a project. After
looking over the SDL docs and taking a brief look at
the source, it appears to me that SDL does not allow
the creating of multiple surfaces per application.
Does anyone know of any plans to implement this type
of functionality in SDL anytime soon.

Thanks
Mark

=====
Mark Jones
markalanj at yahoo.com


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Not multiple windows yet - you can have as many surfaces as you like
though. This works well enough unless you’re trying to write a GUI of
some sort, in which case you’ll probably have to do it as an MDI-ish app.
For a game this is fine. For a DVD player it can be a little frustrating.On Fri, Apr 12, 2002 at 08:31:05PM -0700, Mark Jones wrote:

I am thinking about using SDL in a project. After
looking over the SDL docs and taking a brief look at
the source, it appears to me that SDL does not allow
the creating of multiple surfaces per application.
Does anyone know of any plans to implement this type
of functionality in SDL anytime soon.


Joseph Carter Sooner or later, BOOM!

  • Overfiend sighs
    Netscape sucks.
    It is a house of cards resting on a bed of quicksand.
    during an earthquake
    in a tornado

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020412/ccdaecad/attachment.pgp

Yes I need multiple surfaces with multiple windows.

Mark
— Jason Hoffoss wrote:> You can create multiple surfaces. You can’t create

multiple windows,
though. Is that what you are trying to accomplish?

----- Original Message -----
From: “Mark Jones” <@Mark_Jones>
To:
Sent: Friday, April 12, 2002 11:31 PM
Subject: [SDL] Multiple SDL Surfaces

Hello

I am thinking about using SDL in a project. After
looking over the SDL docs and taking a brief look
at
the source, it appears to me that SDL does not
allow
the creating of multiple surfaces per application.
Does anyone know of any plans to implement this
type
of functionality in SDL anytime soon.

Thanks
Mark

=====
Mark Jones
@Mark_Jones


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====
Mark Jones
@Mark_Jones


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

Yes I need multiple surfaces with multiple windows.

In that case, you don’t want to use SDL then.

-Jason

----- Original Message -----
From: markalanj@yahoo.com (Mark Jones)
To:
Sent: Saturday, April 13, 2002 11:22 PM
Subject: Re: [SDL] Multiple SDL Surfaces

Mark Jones wrote:

Yes I need multiple surfaces with multiple windows.

you might do some fork frickery…but then you need to do some IPC to make the windows work together…–
-==-
Jon Atkins
http://jcatki.2y.net/

That really blows. Are there any plans to add this
functionality?

— Jason Hoffoss wrote:> ----- Original Message -----

From: “Mark Jones” <@Mark_Jones>
To:
Sent: Saturday, April 13, 2002 11:22 PM
Subject: Re: [SDL] Multiple SDL Surfaces

Yes I need multiple surfaces with multiple
windows.

In that case, you don’t want to use SDL then.

-Jason


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====
Mark Jones
@Mark_Jones


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

That really blows. Are there any plans to add this
functionality?

Sort of. SDL 1.3 is going to support multiple monitors, and as a side effect
of this support it will be possible to have multiple windows. However, SDL
will never be designed for real windowing applications, at best you will be
able to tell SDL to draw to a window normally managed by another windowing
toolkit.

There is no timeframe yet for SDL 1.3

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Thats exactly what I am going to do.

— Jonathan Atkins wrote:> Mark Jones wrote:

Yes I need multiple surfaces with multiple
windows.

you might do some fork frickery…but then you need
to do some IPC to make the windows work together…


-==-
Jon Atkins
http://jcatki.2y.net/


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====
Mark Jones
@Mark_Jones


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

Thats exactly what I want to do. I use Qt and would
like to be able to have SDL to render into a window I
have already created with Qt.

Mark
— Sam Lantinga wrote:> > That really blows. Are there any plans to add this

functionality?

Sort of. SDL 1.3 is going to support multiple
monitors, and as a side effect
of this support it will be possible to have multiple
windows. However, SDL
will never be designed for real windowing
applications, at best you will be
able to tell SDL to draw to a window normally
managed by another windowing
toolkit.

There is no timeframe yet for SDL 1.3

See ya,
-Sam Lantinga, Software Engineer, Blizzard
Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====
Mark Jones
@Mark_Jones


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

Thats exactly what I want to do. I use Qt and would
like to be able to have SDL to render into a window I
have already created with Qt.

You can use the SDL_WINDOWID hack, but nobody has ever reported back
whether or not this works with Qt either on Windows or Unix. So…
please let me know if this works! :slight_smile:

http://www.libsdl.org/projects/gtk-demo/

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

That’s also what I need (except I’m using GTK), and I got tired of waiting for
SDL 1.3 :wink: 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.

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 may have also broken the event
processing–I’m not sure, but since I use GTK for that anyway, it’s irrelevant
to me.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. 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. 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. 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…) Mark Mark Jones wrote:

Thats exactly what I want to do. I use Qt and would
like to be able to have SDL to render into a window I
have already created with Qt.

Mark
— Sam Lantinga wrote:

That really blows. Are there any plans to add this
functionality?

Sort of. SDL 1.3 is going to support multiple
monitors, and as a side effect
of this support it will be possible to have multiple
windows. However, SDL
will never be designed for real windowing
applications, at best you will be
able to tell SDL to draw to a window normally
managed by another windowing
toolkit.

There is no timeframe yet for SDL 1.3

See ya,
-Sam Lantinga, Software Engineer, Blizzard
Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====
Mark Jones
markalanj at yahoo.com


Mark Lindner http://www.dystance.net/ @Mark_Lindner

…there is nothing more difficult to carry out, nor more doubtful of
success, nor more dangerous to handle, than to initiate a new order of
things. For the reformer makes enemies of all those who profit by the old
order, and only lukewarm defenders in all those who would profit by the
new order…" --Niccolo Machiavelli

That’s also what I need (except I’m using GTK), and I got tired of
waiting for SDL 1.3 :wink: 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. :slight_smile:

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. :wink: (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:

David Olofson wrote:

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.

I thought about that, but was afraid there might be cases where it wouldn’t
work (subconsiously, I was worried about threading issues I guess, even though
they may not apply in this case). Although it would be a fairly easy change.

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.)

I may have some of that in place already…have a look…the SDL_Window
context structure is being passed into some event/mouse routines as well,
since I had to make those changes to get the library to compile. It may just
be a matter of yanking additional fields out of the monolithic SDL_Video
structure and putting them in SDL_Window.

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. :wink: (I’m primarilly
interested in using “raw SDL”, without any normal toolkit involved, so
some fixing will probably be needed.)

Drop by my website at http://www.dystance.net/ping/
and you can pull down the tarball and give it a whirl. Maybe we can polish
this further to get something that works acceptably during the interim while
we wait for SDL 1.3. Binary compatiblity would certainly be nice, if possible.

Mark------------------------------------------------------------------------------
Mark Lindner http://www.dystance.net/ mesmerism at attbi.com

…there is nothing more difficult to carry out, nor more doubtful of
success, nor more dangerous to handle, than to initiate a new order of
things. For the reformer makes enemies of all those who profit by the old
order, and only lukewarm defenders in all those who would profit by the
new order…" --Niccolo Machiavelli

David Olofson wrote:

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.

I thought about that, but was afraid there might be cases where it
wouldn’t work (subconsiously, I was worried about threading issues I
guess, even though they may not apply in this case). Although it would
be a fairly easy change.

Yeah. Multi context state machine APIs don’t really feel right these
days. heh Then again, it seems to work for OpenGL…

[…]

Drop by my website at http://www.dystance.net/ping/
and you can pull down the tarball and give it a whirl.

Ok. I’ll look at it ASAP. (Will probably at least try to build it on
Linux tonight.)

Maybe we can
polish this further to get something that works acceptably during the
interim while we wait for SDL 1.3.

Yeah. We’ve discussed this a few times on the list, but no one needed it
enough “right now” to go ahead and hack something.

Binary compatiblity would certainly
be nice, if possible.

I think it’s possible, although it might not be too clean. (Can’t add
calls - that’s the main problem.) We’d have to figure out which call to
abuse for the context switching, and it’s at least a bit tricky to
support “extended events” without adding one or two calls. heh

Then again, an application telling SDL that it’s aware of multiple
windows could of course be expected to be using an extended event
struct… (We wouldn’t want to overflow the stack allocated structs of
older applications when using the patched lib.)

Oh well. I’ll just have a look and see if I get any bright ideas! :wink:

//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 Thursday 25 April 2002 10:17, Mark Lindner wrote: