Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Transparent window background
- - By JeanC Date 2015-01-17 06:27
Hello,

is it possible in Gosu to create a window with a transparent background ? I'm trying to play a movie under the game window and show the movie only on a certain portion of my game.
Parent - - By jlnr (dev) Date 2015-01-17 10:20
Good question. In Ruby: not directly.

In C++, it might be possible by calling SDL_SetWindowShape. I don't know if this even works on all platforms, though. I have never seen a non-rectangular window on OS X :)

The last time I've tried to do something like this (for a kiosk system, anyway) I've launched a video player in full-screen mode and placed it over the game window.

oli.ok has also written an extension for Gosu once that streamed a video file onto an OpenGL texture (i.e. Gosu::Image). This allowed for all kinds of crazy effects, but was a Linux-only, one-off project.
Parent - - By JeanC Date 2015-01-17 22:00
Thanks for the tip about SDL_SetWindowShape, I will try it on Raspberry Pi (I found an example in the "test" folder from the SDL2 Github repository). There is no info about this in the SDL2 documentation, probably because it doesn't work as expected on all systems.
Parent - - By jlnr (dev) Date 2015-01-18 10:03
I would be surprised if it was supported on the Raspberry Pi, as I couldn't even get 'normal' windowed mode to work :)

And a general SDL 2 tip - the stable v2.0.3 is pretty old. Sometimes things work better if you build from source.
Parent - - By JeanC Date 2015-01-18 15:11
I've built SDL2 directly from the Github source. OK, initially I've tried their provided test shape example from the "tests" folder, I was able to compile it and ... "segmentation fault" on the PI. Same code can be compiled and runs an OS X but there is no transparency effect, just the shapes are drawn on the screen surrounded by a black background.

That being said, pi3d lets you use a transparent window background both in the PI framebuffer (no X) and under X, I've played with some of their demos. So, technically, you can have transparent backgrounds on Pi. I was able to run a movie under one of the pi3d demos and it works.
Parent - By jlnr (dev) Date 2015-01-18 21:06
Interesting! I didn't expect this to be possible after my short trip into Raspberry Pi land.

If you want to see this feature in Gosu, you can lobby to get it fixed in SDL 2 and I'll add a short wrapper in Gosu. Window#shape=(image) or such. But only if it works on at least one platform :)
Parent - By knugie Date 2017-03-25 15:17
Hey JeanC, I'm trying to do something something very similar. Could you share some example code how you made a transparent window? Also now (two years later), how would you approach that today? Thanks.
Up Topic Gosu / Gosu Exchange / Transparent window background

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill