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

Author Topic: Per-pixel Transparent window with SFML content (win32 API) - The Final Solution  (Read 4021 times)

0 Members and 2 Guests are viewing this topic.

UltraNyan

  • Newbie
  • *
  • Posts: 3
    • View Profile
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)
The video actually uses per pixel transparency but the image I was using was just bad  :)

... any thoughts?
« Last Edit: April 19, 2016, 02:33:12 pm by UltraNyan »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Are you attempting to animate pixel transparency of a window?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

UltraNyan

  • Newbie
  • *
  • Posts: 3
    • View Profile
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.
« Last Edit: April 19, 2016, 06:50:10 pm by UltraNyan »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

UltraNyan

  • Newbie
  • *
  • Posts: 3
    • View Profile
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.
« Last Edit: April 19, 2016, 11:55:42 pm by UltraNyan »