SFML community forums

Help => Window => Topic started by: Alia5 on November 14, 2016, 03:00:12 am

Title: [HOWTO] Make Transparent SFML Window (on Windows 7+)
Post by: Alia5 on November 14, 2016, 03:00:12 am
It got asked multiple times here in the forums, and I've finally found THE solution after a lot of googeling, and it works like a charm.

I wanted to share this here, so it can be easily found via Google and help other since I didn't find this all too quickly.


With this method, "window.clear(sf::color::transparent);" effectively works like you would expect it.

No setting shapes, no masking, no nothing.

Everything not overlayed with shapes / sprites whatever is fully transparent.
Everything you draw is there, even if it is semi transparent.
Even frigging steam overlay works as you'd might expect!

Screenie:
(http://i.imgur.com/bP8DwcYs.png) (http://i.imgur.com/bP8DwcY.png)

Code:
https://gist.github.com/Alia5/5d8c48941d1f73c1ef14967a5ffe33d5
Title: Re: [HOWTO] Make Transparent SFML Window (on Windows 7+)
Post by: Hapax on November 14, 2016, 01:58:40 pm
Just to be clear, this is incredibly bad advice. Your post makes it sound like SFML can deal with it "automagically".

It is just not true.

The alpha value given to OpenGL is ignored for the window as the operation system provides the 'canvas' to draw and that canvas' alpha values are determined by the operating system.

Different operating systems deal with window transparency differently and none of the major ones do this automatically.

Your "solution" seems to only be targeted at Windows operating systems, which seems unfair...
(although it does seem to work even if it does require Desktop Window Manager to be used)

As you've mentioned, there are multiple discussions about this:
http://en.sfml-dev.org/forums/index.php?topic=9184.0
http://en.sfml-dev.org/forums/index.php?topic=7820.0
http://en.sfml-dev.org/forums/index.php?topic=16776.0
http://en.sfml-dev.org/forums/index.php?topic=18337.0
http://en.sfml-dev.org/forums/index.php?topic=18217.0
http://en.sfml-dev.org/forums/index.php?topic=19910.0
http://en.sfml-dev.org/forums/index.php?topic=18565.0
http://en.sfml-dev.org/forums/index.php?topic=13480.0
http://en.sfml-dev.org/forums/index.php?topic=6591.0
http://en.sfml-dev.org/forums/index.php?topic=5126.0

...