liballeg / allegro5

The official Allegro 5 git repository. Pull requests welcome!
https://liballeg.org
Other
1.9k stars 286 forks source link

Allegro 5 - frameless transparent window #1076

Open thilidric opened 5 years ago

thilidric commented 5 years ago

Hey guys!

For a couple of days i tried to work on enabling the window transparency for background. I did manage to do it with Winapi but once I start drawing with allegro i get back the solid background color.

Guys from IRC suggested me to use this:

al_clear_to_color(al_map_rgba(0, 0, 0, 0));
al_flip_display();

But it just draws the black background anyway.

Any ideas if it is possible to achieve transparent background in window?

EdgarReynaldo commented 5 years ago

Transparent windows aren't currently supported in Allegro 5.2.5- yet, I have some work I did on this issue though, I can dredge it up. Give me a few days. Message me any time.

thilidric commented 5 years ago

Thanks for an reply. I would love to see ur work.

I was also thinking about using an CS_DROPSHADOW to have atleast a nice shadow around my frameless window, managed to add it on pure winapi, struggling on allegro becouse I need to capture some winapi messages from an window to make it work (dont remember them right now, got the sources on different desktop).

thilidric commented 5 years ago

I see no response but I`ve managed to accomplish atleast a nice shadow around the frameless window. I did an second window and layered in under my main, then just handle all the minimize, close, resize and move events to be equal for both windows.

Thanks to it i was also able to draw a more fancy border in the underlaying window but just could not make the png alpha for shadows to kick in.

Anyway, it looks a lot better with shadow then just plain flat frameless window. Results showing main and shadow window: https://pasteboard.co/IxJqxmc.png

EdgarReynaldo commented 5 years ago

Sorry. I don't seem to get notified of replies to this thread.

I haven't had time to work on it yet. The key is OpenGL with WGL_TRANSPARENT_ARB extensions and LayeredWindow.

Necklaces commented 2 years ago

@EdgarReynaldo Just joining in to say I'd love to see this get implemented!

EdgarReynaldo commented 2 years ago

@Necklaces There is one way to get a transparent window, and another to get translucent windows. For translucent windows all you need is DWMEnableBlurBehind. You can do it without allegro and without interfering with allegro. Windows Vista and up is required for a translucent window.

EdgarReynaldo commented 2 years ago

Sorry. I don't seem to get notified of replies to this thread.

I haven't had time to work on it yet. The key is OpenGL with WGL_TRANSPARENT_ARB extensions and LayeredWindow.

WGL_TRANSPARENT_ARB is not needed. Neither is OpenGL. But you do need to set a color key with LayeredWindow.

Necklaces commented 2 years ago

@EdgarReynaldo Unfortunately I'm mainly on GNU/Linux and DWMEnableBlurBehind and LayeredWindow seem to be Windows only? Ideally I'd need a cross platform solution - which from what I've read looks to be hard. Thus, it seems to me that it would be better if transparency was implemented in Allegro.

EdgarReynaldo commented 2 years ago

Those are the ONLY way to do it on Windows. On Linux it's actually much easier as all you have to do is add an alpha mask when creating the window. The Linux fix should be in GIT already. As for OSX or other platforms I don't know. So there's no real cross platform way to do it without delving into OS specific function calls and techniques.

Edgar

On 7/18/2022 4:09 PM, Nichlas Severinsen wrote:

@EdgarReynaldo https://github.com/EdgarReynaldo Unfortunately I'm mainly on GNU/Linux and DWMEnableBlurBehind and LayeredWindow seem to be Windows only? Ideally I'd need a cross platform solution - which from what I've read looks to be hard. Thus, it seems to me that it would be better if transparency was implemented in Allegro.

— Reply to this email directly, view it on GitHub https://github.com/liballeg/allegro5/issues/1076#issuecomment-1188313258, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2JBYNFVKK6TBP672D6533VUXBZJANCNFSM4IPUVACQ. You are receiving this because you were mentioned.Message ID: @.***>

MatiasMunk commented 3 months ago

I was wondering if more work has been done on this, since this is also something I am really interested in!

EdgarReynaldo commented 3 months ago

I was wondering if more work has been done on this, since this is also something I am really interested in!

Use DWM and DWMEnableBlurBehind on the Window along with a 32 bit backbuffer to include alpha. I haven't had full success with this yet. Aero glass effects interfere with the window.