SDl and Window ID

hi all,

is there a possibility to tell the SDL with which window id to start. I
guess, default is, but for cathing the window for example in a qt wigdet I
have to set set window id manually.

can anybody help me?

regards christian

I’m not certain if this is what you are asking, but there are several Window
Management options in SDL:

http://sdldoc.csn.ul.ie/wm.phpOn Thursday 26 July 2001 01:41pm, Christian Spitzner wrote:

hi all,

is there a possibility to tell the SDL with which window id to start. I
guess, default is, but for cathing the window for example in a qt wigdet I
have to set set window id manually.

can anybody help me?


Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >

Samuel Hart wrote:

hi all,

is there a possibility to tell the SDL with which window id to start. I
guess, default is, but for cathing the window for example in a qt wigdet I
have to set set window id manually.

can anybody help me?

I’m not certain if this is what you are asking, but there are several Window
Management options in SDL:

no, I already found this part in the docs ;-), but I am lookink for a way, to
tell a sdl window (surface), where to pop up. until now, we did video decoding,
displaying the picture by use of a simple X11 window, embedded in a qt widget.
we first create the qt widget and get the window id of the widget. afterwards
we create the X11 window, whith this window id, returned from the qt widget. in
this way, we get a embedded X11 window.

my question is now, whether there is a opportunity to do so with sdl calls
(because we want to use the hw acceleration provided with sdl).

regards christian> On Thursday 26 July 2001 01:41pm, Christian Spitzner wrote:

http://sdldoc.csn.ul.ie/wm.php


Sam “Criswell” Hart AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >

we first create the qt widget and get the window id of the widget.
afterwards we create the X11 window, whith this window id, returned
from the qt widget. in this way, we get a embedded X11 window.

#include <stdio.h>
#include “SDL.h”

int SDL_InitWithWindowID(long windowid)
{
char envr[100];
snprintf(envr, sizeof (buf), “SDL_WINDOWID=%ld”, my_window_id);
putenv(buf);
return(SDL_Init(SDL_INIT_VIDEO));
}

That’s the gist of it.

You need to check return values, make sure you don’t overflow envr (!), etc.

Also remember that SDL_WINDOWID is a hack, but it will work in an X11
environment. If I remember, someone also hacked Win32 support for it, too,
but I couldn’t say.

Remember, kiddies, this is also a fun thing to set from bash, if you
wanted to, say, have plaympeg run a movie on your root window. Who needs
wallpaper? :slight_smile:

–ryan.

int SDL_InitWithWindowID(long windowid)
{
char envr[100];
snprintf(envr, sizeof (buf), “SDL_WINDOWID=%ld”, my_window_id);
putenv(buf);
return(SDL_Init(SDL_INIT_VIDEO));
}

That should be “windowid” and not “my_window_id” in the snprintf call, and
"envr" and not “buf” in the putenv call.

I’m going to bed now. :slight_smile:

–ryan.

“Ryan C. Gordon” wrote:

we first create the qt widget and get the window id of the widget.
afterwards we create the X11 window, whith this window id, returned
from the qt widget. in this way, we get a embedded X11 window.

#include <stdio.h>
#include “SDL.h”

int SDL_InitWithWindowID(long windowid)
{
char envr[100];
snprintf(envr, sizeof (buf), “SDL_WINDOWID=%ld”, my_window_id);
putenv(buf);
return(SDL_Init(SDL_INIT_VIDEO));
}

That’s the gist of it.

You need to check return values, make sure you don’t overflow envr (!), etc.

Also remember that SDL_WINDOWID is a hack, but it will work in an X11
environment. If I remember, someone also hacked Win32 support for it, too,
but I couldn’t say.

thanx ryan,
that was exactly what I wanted :-]. but I have to port the application also on
windows - and, what a surprise - need the same functionality there as well. so,
if anybody knows a way how to hack this feature it would be great to get
informed.

bye christian>

Remember, kiddies, this is also a fun thing to set from bash, if you
wanted to, say, have plaympeg run a movie on your root window. Who needs
wallpaper? :slight_smile:

–ryan.


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

Christian Spitzner mailto:@Christian_Spitzner
Fraunhofer Institut
Integrierte Schaltungen Phone :+49 9131 776-371
Audio Department Fax :+49 9131 776-398
Am Weichselgarten 3 http://www.iis.fhg.de/amm
D-91058 Erlangen, Germany

thanx ryan,
that was exactly what I wanted :-]. but I have to port the application also on
windows - and, what a surprise - need the same functionality there as well. so,
if anybody knows a way how to hack this feature it would be great to get
informed.

This might work on Windows too, but it hasn’t been tested in a while.

See ya!
-Sam Lantinga, Lead Programmer, Loki Software, Inc.

Hi Sam,
I have tried doing just this using the SetEnvriomentVarible Windows
API call before calling SDL_Init but I could not get it to work.
I really think that an SDL API function like SetWindowID( Window ID goes
here ); and probably a corrseponding GetWindowID,
should be added to SDL for those occastions when you want to embed an
SDL_Surface within a window ( on Windows ) or within a Widget or similar
on Linux.

Or alternatively if you can point me to some coding involving the
SDL_WINDOWID environment variable that works on all the OSes that SDL
supports.

Would this be a big change? I have never looked at the SDL internals so
anyone with more experience should let me know how much work this might be.

Thanks,

Dominqiue.
http://www.DelphiGamer.com

Sam Lantinga wrote:>> thanx ryan,

that was exactly what I wanted :-]. but I have to port the application also on
windows - and, what a surprise - need the same functionality there as well. so,
if anybody knows a way how to hack this feature it would be great to get
informed.

This might work on Windows too, but it hasn’t been tested in a while.

See ya!
-Sam Lantinga, Lead Programmer, Loki Software, Inc.

I really think that an SDL API function like SetWindowID( Window ID goes
here ); and probably a corrseponding GetWindowID,
should be added to SDL for those occastions when you want to embed an
SDL_Surface within a window ( on Windows ) or within a Widget or similar
on Linux.

Ahh! No!

I said it was a hack. You can’t even count on there BEING a windowed
environment running, or that it can handle this.

This isn’t SDL’s purpose. It’s just a cool trick.

(Also, try putenv(“SDL_VIDEODRIVER=windib”) into your code before the
SDL_Init call on Win32…that might get you the SDL_WINDOWID support. You
have to make sure you’re running on Windows, though, as that will stop it
from working at all on Linux.)

–ryan.

Hi Ryan,
I don’t think that would be much of a change. All it would have to do
is Check to see that the Parent WindowID had been set. If it has been
set then the user obviously want to use a Windowed environment and if
the WindowID is not set do what it does now. I’m sure this is how it
currently works with this Environment Variable.

Thanks.

Dominique.
http://www.DelphiGamer.com

Ryan C. Gordon wrote:>> I really think that an SDL API function like SetWindowID( Window ID goes

here ); and probably a corrseponding GetWindowID,
should be added to SDL for those occastions when you want to embed an
SDL_Surface within a window ( on Windows ) or within a Widget or similar
on Linux.

Ahh! No!

I said it was a hack. You can’t even count on there BEING a windowed
environment running, or that it can handle this.

This isn’t SDL’s purpose. It’s just a cool trick.

(Also, try putenv(“SDL_VIDEODRIVER=windib”) into your code before the
SDL_Init call on Win32…that might get you the SDL_WINDOWID support. You
have to make sure you’re running on Windows, though, as that will stop it
from working at all on Linux.)

–ryan.

Ryan C. Gordon wrote

(Also, try putenv(“SDL_VIDEODRIVER=windib”) into your code before the
SDL_Init call on Win32…that might get you the SDL_WINDOWID support. You
have to make sure you’re running on Windows, though, as that will stop it
from working at all on Linux.)

Hi Ryan,
I have tried this hack under windows to no avail. Can anyone see what
may be wrong with the following code?

{$IFDEF WIN32}
if not SetEnvironmentVariable(‘SDL_VIDEODRIVER’,‘windib’) then
Memo.Lines.Add(‘Could Not set SDL_VIDEODRIVER’);

if not SetEnvironmentVariable(‘SDL_WINDOWID’,
PChar(inttostr(Panel1.Handle))) then
Memo.Lines.Add(‘Could Not set SDL_WINDOWID’);
{$ENDIF}

I do not get any error messages, so I can only assume that the
SetEnvironmentVariable API call is working.

Does anyone have some C/C++ code that works on Windows?

Thanks

Dominique
http://www.DelphiGamer.com