Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [HOWTO] Make Transparent SFML Window (on Windows 7+)  (Read 3002 times)

0 Members and 1 Guest are viewing this topic.

Alia5

  • Newbie
  • *
  • Posts: 34
    • View Profile
[HOWTO] Make Transparent SFML Window (on Windows 7+)
« 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:


Code:
https://gist.github.com/Alia5/5d8c48941d1f73c1ef14967a5ffe33d5

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: [HOWTO] Make Transparent SFML Window (on Windows 7+)
« Reply #1 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

...
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything