SFML community forums

Help => Window => Topic started by: UltraNyan on April 19, 2016, 02:16:50 pm

Title: Per-pixel Transparent window with SFML content (win32 API) - The Final Solution
Post by: UltraNyan on April 19, 2016, 02:16:50 pm
This thread... again...

I have done many searches and read different forums, this is how I intend to do it on Windows and with SFML.

1. Render my SFML content to a transparent render texture and convert it to image.
2. Use UpdateLayeredWindows to create the transparent window based on that transparent render texture.

My main concern is that the program has to process the whole texture each frame.

I had some great satisfactory performance using TGA files with transparency and overwriting the SFML window:
(click to show/hide)
https://www.youtube.com/watch?v=u620mzo8Ta4 (https://www.youtube.com/watch?v=u620mzo8Ta4) The video actually uses per pixel transparency but the image I was using was just bad  :)

... any thoughts?
Title: Re: Per-pixel Transparent window with SFML content (win32 API) - The Final Solution
Post by: Hapax on April 19, 2016, 03:51:21 pm
Are you attempting to animate pixel transparency of a window?
Title: Re: Per-pixel Transparent window with SFML content (win32 API) - The Final Solution
Post by: UltraNyan on April 19, 2016, 06:42:05 pm
Are you attempting to animate pixel transparency of a window?

Yes.

And ideally I would like to split the updating the window into 2 parts. First part would update the window contents itself, regardless of the shape or transparency. The second part would update the transparency mask, that way you would be able to skip creating a new dataset for transparency and animate inside of the non transparent area.

Currently I have some difficulties understanding how exactly the UpdateLayerdWindows works because i cant avoid drawing the window over with the new picture used to generate the transparency.
Title: Re: Per-pixel Transparent window with SFML content (win32 API) - The Final Solution
Post by: Hapax on April 19, 2016, 11:31:16 pm
I'm not sure how well an operating system can actually animate a window's transparency.
If it's in real-time, you need to process every pixel manually and create regions (you mentioned this was for Windows only) etc. for every frame.
If it's not in real-time, though, you can store combined regions (effectively a frame's alpha map) and recall them as needed.
Title: Re: Per-pixel Transparent window with SFML content (win32 API) - The Final Solution
Post by: UltraNyan on April 19, 2016, 11:42:33 pm
I'm not sure how well an operating system can actually animate a window's transparency.
If it's in real-time, you need to process every pixel manually and create regions (you mentioned this was for Windows only) etc. for every frame.

Well the youtube video I included, it was running locked at 24 frames per second on my laptop(i7) on one core at about 40%. It was much more effective than setting the window shape that used about 100% of cpu and ran at about 15 fps. In both cases, it was loading the image file each frame (very ineffective) to simulate off screen rendering.

Quote
If it's not in real-time, though, you can store combined regions (effectively a frame's alpha map) and recall them as needed.
If I used a single sprite for the whole window, I could have some of the data for textures split in two: one for image and other for transparency, would be able to speed stuff up a bit by avoiding to process the whole image file each time i use it.

PS.
Im kinda busy atm with some other stuff, if I figure out how to properly use UpdateLayeredWindow then I will try to implement it with the render texture and post the results here.