Jump to content
  • Advertisement
Sign in to follow this  

Transparent backbuffer

This topic is 1320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I'm trying to get a transparent backbuffer, for integrating my DX-rendered gui better with the rest of the OS. I've got a few questions/issues with that though:

 

- I've found out that I'm supposed to use DwmExtendFrameIntoClientArea for that. It also kind of works, though I get some sort of strange alpha/z-ordering issues, as you can see in Issue.png. Here is the code I'm using the create the window (plain old windows w/o any libary): (see edit below)

 

- Even though I can now see whats underneath the empty areas of my GUI... I still can't click/do anything else there, since the empty backbuffer is still overlapping the whole screen. Is there any way of "deactivating" certain areas of my backbuffer/invisible window, so that my application behaves like it was rendered using normal windows? Note that I can't just move the backbuffer as the main window you see moves, because there might be popup-windows of all sorts, which can go over the area of the main window... so any method for willingly deactivate area of a window?

 

EDIT: Ok, I was too fast in blaming the windows-part for this. Apparently the issue is with my rendering, because its those areas with the weird issues, where I render an alpha-blended texture over a solid texture. That happens for all my texts, and also for the icon in the upper left. Now I can get rid of this effect for most parts, by using alpha testing via clip (when alpha in the texture is 0), but what am I supposed to do when I have semi-transparent values, like the edges of the icon in the upper left? I can't just disable alpha-writing all together, since after clearing everything in the backbuffer is 0 (transparent). But I need to somehow only write alpha when the value is greater then what is currently in the buffer.

 

I'm rendering my gui with painters-algorithm and batched, so everything that is on top gets drawn last, in one go. Is there any way to achieve this kind of alpha-effect to fix my issue? So what I want summed up is:

 

- Every pixel with alpha > 0 should get drawn.

- In case texture pixel alpha is greater than backbuffer pixel alpha, the alpha value is written

- Otherwise, the pixel should still be blended to the content thats already in the backbuffer, but alpha value should stay the same.

 

EDIT2: Ugh, I'm just too tired to think. Of course I can configurate the AlphaSrcBlend and AlphaDestBlend-states to fig this issue. Havn't used those in a while, huh. So the rendering problems are solved now, though Issue#2 is still up. Any ideas for that?

Edited by Juliean

Share this post


Link to post
Share on other sites
Advertisement

Nevermind, I figured it out. I'll post a step-by-step solution for anyone who might stumble across this, since direct gathered information seems to be very sparse on that topic:

 

- Make sure swapchain-buffer format is set to DXGI_R8G8B8A8_UNORM.

- Call DwmExtendFrameIntoClientArea with the created windows metrics.

- Clear the backbuffer to (0, 0, 0, 0) at the beginning of every frame (read: whenever there is something redrawn)

 

This should show the content of whats behind the empty parts of the backbuffer. The next steps will now result in being able to actually interact with whats behind that:

 

- Calculate the bounding-rects of all your visible elements on the screen.

- Create a HRGN that covers all those areas by using CreateRectRgn for each element, and then CombineRgn(last, last, this, RGN_OR) them into one another

- At the end, set this region with SetWindowRgn(hwnd, rgn, true)

 

Since this will also hide the window parts that are not in the region, you can potentially skip the first three steps if all you have is rectangular structures without transparency, though this can lead to visible artifacts when moving elements around the screen.

 

Hope this helps someone who might have the same problem as I did.

Edited by Juliean

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!