View Full Version : DwmBlurBehind and partial transparency

John M.
04-19-2016, 12:03 PM
Hello there,

I have been working on this rather graphically-heavy 2D GUI program for Windows which uses OpenGL for rendering. The problem I have is that I'm using DwmEnableBlurBehindWindow to enable desktop compositing, and as a result, it automatically blends any pixel whose alpha component is less than 255 with whatever is behind the window. Regardless of how many textures are overlapped in one area, it only takes one with a partially transparent pixel to 'trick' DWM into blending said pixel with what is behind the window.

The only way I can think of to fix this, since desktop compositing plays a crucial part in the application's design, is to somehow make the alpha-blending operations not calculate the 'new' alpha value, but rather force the post-blended alpha component from each pixel to either 255 or 0. On top of that, it must also be 'intelligent' enough to recognize partially transparent pixels ( > 0 && < 255) that are meant to be blended with whatever is behind the application's window.

My current solution to this is a combination of dynamic and static manual alpha-blending between textures, using a "SRC_ALPHA, ONE_MINUS_SRC_ALPHA" blending algorithm, and in the case of dynamic alpha-blending, re-uploading the texture each frame with glTexSubImage2D. This method is proving very inefficient and makes the code rather messy, and at this point, I wish to seek insight on how to achieve this with minimal CPU processing and GPU uploads.

Finally, I should note that I'm targeting older hardware also, and therefore I would like to stick to around OpenGL 1.1 for the solution. Writing a shader for this would be undoubtedly easy and simple, however that is unfeasible in the context of targeting older hardware.