microsoft / XboxGameBarSamples

Sample code for Xbox Game Bar Widgets
https://developer.microsoft.com/games/products/game-bar/
MIT License
145 stars 28 forks source link

[SDK BUG] Transparence Issue on DX11! #134

Closed ZaweSec closed 6 months ago

ZaweSec commented 6 months ago

Hi, im using the directx 11 sample of visual studio and ported it to the gamebar, i have AllowForegroundTransparency to true and the alpha mode to DXGI_ALPHA_MODE_PREMULTIPLIED;

this is the render:

bool App1Main::Render() 
{
    // Don't try to render anything before the first Update.
    if (m_timer.GetFrameCount() == 0)
    {
        return false;
    }

    auto context = m_deviceResources->GetD3DDeviceContext();
    DXGI_SWAP_CHAIN_DESC1 desctest;
    m_deviceResources->GetSwapChain()->GetDesc1(&desctest);

    // Reset the viewport to target the whole screen.
    auto viewport = m_deviceResources->GetScreenViewport();
    context->RSSetViewports(1, &viewport);

    // Reset render targets to the screen.
    ID3D11RenderTargetView *const targets[1] = { m_deviceResources->GetBackBufferRenderTargetView() };
    context->OMSetRenderTargets(1, targets, m_deviceResources->GetDepthStencilView());

    // Clear the back buffer and depth stencil view.    
    DirectX::XMVECTORF32 ClearColor = { { { 0, 0.0f, 0.0f, 0.f } } };

    context->ClearRenderTargetView(m_deviceResources->GetBackBufferRenderTargetView(), ClearColor);

    return true;
}

Untitled

ZaweSec commented 6 months ago

Update: fixed by changing the xaml from this

<Page
    x:Class="App1.DirectXPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

  <SwapChainPanel x:Name="swapChainPanel">
    <TextBlock Text="Hello from XAML!"
               HorizontalAlignment="Right"
               VerticalAlignment="Top"
               FontSize="30" />
  </SwapChainPanel>

  <Page.BottomAppBar>
    <AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
        <AppBarButton AutomationProperties.Name="Sample Button"
                      AutomationProperties.AutomationId="SampleAppBarButton"
                      Click="AppBarButton_Click"/>
      </StackPanel>
    </AppBar>
  </Page.BottomAppBar>
</Page>

to this :

<Page
    x:Class="App1.DirectXPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <SwapChainPanel x:Name="swapChainPanel">
        <TextBlock Text="Hello from XAML!"
               HorizontalAlignment="Right"
               VerticalAlignment="Top"
               FontSize="30" />
    </SwapChainPanel>
</Page>