SDL on a GTK widget

Hello,

I am trying to make an application using SDL and GTK (under the gnome
desktop), but with no success…

this is the problem:

I have a gnomeapp, with a menu that says “New Screen…”. The user
clicks, and then, he selects the size (800x600, etc). With this info, I
create a drawing area (the new app contents) and, on the configure
event, I open the SDL surface, like the gtk-demo.c

Questions:

a) Do I need to make the winhack before SDL_Init ? The user can close
the window, and the drawing area dissapear… and you can create a new
one, etc (I mean, the SDL_WINDOWID is not always the same). Do I need to
call SDL_Quit before the winhack?

b) If I use the darea->window (this is the GdkWindow from the drawing
area widget) in the winhack… When I call SDL_SetVideoMode, I have a
strange error:

Gdk-ERROR **: BadWindow (invalid Window parameter)
serial 32 error_code 3 request_code 3 minor_code 0

BUT if I use the gnomeapp window, I can open the surface over the
gnomeapp (but this include the menus and toolbars)

I supose that SDL can only be “hacked” to use a top-level window… am
I right?

c) I have a Geforce 256 with X Free 3.3.6, but SDL_GetVideoInfo says
that I have no hw acceleration… Is this normal?

d) Using the full app window (just to continue doing tests) I loaded a
BMP. It seems to work on all resolutions… but for a while! On the next
refresh event, the normal app window is repainted, but the BMP isnt…
so, I see the picture for a second or less. Which event should I use?

Well, thanks a lot for this help. I hope I can integrate SDL over
GtkWidgets to make a full multimedia desktop and a nice developer
interface…–
signed
derethor of centolos

Derethor wrote:

Hello,

I am trying to make an application using SDL and GTK (under the gnome
desktop), but with no success…

When you figure out the best way to go about doing all of this please let
me know, In the near future im going to be diving into the whole mess of
using GTK with SDL, and if you by any chance figure out how to do it in
Windows let me know, if it can be done in other Os’s ill probly throw
together a lib so there will be a cross-platform, simpler way of going
about doing it.

c) I have a Geforce 256 with X Free 3.3.6, but SDL_GetVideoInfo says
that I have no hw acceleration… Is this normal?

Install XFree 4.0.1 (or whatever the newest is). It is MUCH beter at
hardware acceleration.

d) Using the full app window (just to continue doing tests) I loaded a
BMP. It seems to work on all resolutions… but for a while! On the next
refresh event, the normal app window is repainted, but the BMP isnt…
so, I see the picture for a second or less. Which event should I use?

Well, thanks a lot for this help. I hope I can integrate SDL over
GtkWidgets to make a full multimedia desktop and a nice developer
interface…


signed
derethor of centolos

Jess

Questions:

a) Do I need to make the winhack before SDL_Init ? The user can close
the window, and the drawing area dissapear… and you can create a new
one, etc (I mean, the SDL_WINDOWID is not always the same). Do I need to
call SDL_Quit before the winhack?

Yes.

I supose that SDL can only be “hacked” to use a top-level window… am
I right?

That’s correct.

c) I have a Geforce 256 with X Free 3.3.6, but SDL_GetVideoInfo says
that I have no hw acceleration… Is this normal?

Yes. The X server doesn’t expose the hardware to the X clients.
XFree86 4.0 with DGA allows you to use hardware acceleration.

d) Using the full app window (just to continue doing tests) I loaded a
BMP. It seems to work on all resolutions… but for a while! On the next
refresh event, the normal app window is repainted, but the BMP isnt…
so, I see the picture for a second or less. Which event should I use?

I’m not sure. It does indeed sound like GTk and SDL are fighting over the
window. You’ll have to play around to figure out how to make sure GTk doesn’t
draw on it. Please post how you got it to work when you figure it out as
I’m sure more people are interested!

Well, thanks a lot for this help. I hope I can integrate SDL over
GtkWidgets to make a full multimedia desktop and a nice developer
interface…

That would be very nice. :slight_smile:

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software