Transparent back buffer.

I'd like to make the display / back buffer transparent, all of the solutions I found on this were for Allegro 4 except for one:

  SetWindowLong(al_get_win_window_handle(display), GWL_EXSTYLE, GetWindowLong(al_get_win_window_handle(display), GWL_EXSTYLE) | WS_EX_LAYERED);
  SetLayeredWindowAttributes(al_get_win_window_handle(display), 0, 0, LWA_ALPHA);

Problem with this one is that it makes the entire window transparent, so anything I draw is also transparent.

And it will only run on Windows, which isn't the worst thing even though I'm planning on having my program be cross platform compatible. It just means I'll have to spend some more time looking at X11 and whatever mac uses.

To sum it up:
Is there a way to make my back buffer transparent so that the desktop is visible?
Like this:

//draw stuff

Edgar Reynaldo

I think what you want is UpdateLayeredWindow, but I don't think you can vary the alpha over different parts of the window, just set a transparency level for the whole window.


I was able to solve my problem but I had to give up on Allegro.

I used the glLayeredWindows demo to handle all of the drawing for me and modified it so I could put it in a class and use it in my project.

I also used lodepng to load the png files I'm using in my project.

I hope this will make it easier for others who wish to do the same.


This is indeed a missing Allegro feature. Transparent windows are possible on Linux and Windows, (and likely OSX) so we should probably implement this... one day.

Thread #614595. Printed from