Skip to content

Commit

Permalink
Add a WinAppSdk app that renders content with DirectX
Browse files Browse the repository at this point in the history
  • Loading branch information
ackh committed Jun 22, 2023
0 parents commit 97a6dfd
Show file tree
Hide file tree
Showing 51 changed files with 2,310 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
################################################################################
# Git automatically determines whether it deals with text or binary files. If it
# determines that a file is a text file it will convert all line endings of that
# file to be just single LF (line feed) characters before committing the file.
# This behaviour can be altered by providing more specific instructions for
# files after the below statement.
################################################################################

* text=auto


################################################################################
# Files interpreted by the Windows cmd.exe shall be treated as text files which
# means their line endings are converted to just LF instead of CRLF when such a
# file is committed. If the file is written out to the working directory the
# line endings are always converted to CRLF.
################################################################################

*.bat text eol=crlf
*.cmd text eol=crlf


################################################################################
# Visual Studio project and solution files shall be treated as text files which
# means that their line endings are converted to just LF instead of CRLF when
# such files are committed. To prevent issues with Visual Studio, the line
# endings of those files are always converted to CRLF once the files are written
# out to the working directory, regardless of the operating system on which this
# happens.
################################################################################

*.props text eol=crlf
*.sln text eol=crlf
*.vcxitems text eol=crlf
*.vcxproj text eol=crlf


################################################################################
# Treat the following files as text files which means that their line endings
# are converted to just LF instead of CRLF when such a file is committed. If the
# file is written out to the working directory the line endings are converted to
# the default line ending of the platform.
################################################################################

*.c text
*.cpp text
*.h text
*.hlsl text
*.hpp text
*.inl text
*.rc text
*.xaml text
*.xml text


################################################################################
# Treat the following files as binary files which means there is no line endings
# conversion applied and changes are stored as binary patches.
################################################################################

*.gif binary
*.jpg binary
*.pdf binary
*.png binary
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
################################################################################
# Prevents specific files and folders from being added to Git.
################################################################################

/.vs
/bin
/packages
/SwapChainPanelBugRepro/Generated Files
/SwapChainPanelBugRepro/obj


################################################################################
# Prevents files with the below listed file extensions from being added to Git.
################################################################################

*.db
*.opendb
*.user
*.suo
*.payload.desc
35 changes: 35 additions & 0 deletions SwapChainPanelBugRepro.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33414.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SwapChainPanelBugRepro", "SwapChainPanelBugRepro\SwapChainPanelBugRepro.vcxproj", "{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Debug|x64.ActiveCfg = Debug|x64
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Debug|x64.Build.0 = Debug|x64
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Debug|x64.Deploy.0 = Debug|x64
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Debug|x86.ActiveCfg = Debug|Win32
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Debug|x86.Build.0 = Debug|Win32
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Debug|x86.Deploy.0 = Debug|Win32
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Release|x64.ActiveCfg = Release|x64
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Release|x64.Build.0 = Release|x64
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Release|x64.Deploy.0 = Release|x64
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Release|x86.ActiveCfg = Release|Win32
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Release|x86.Build.0 = Release|Win32
{08C7CA65-5B00-4BC9-8128-FA34B8EF8685}.Release|x86.Deploy.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FEC6CC4D-F5F7-4831-9E6F-4F1BD89DBFA5}
EndGlobalSection
EndGlobal
32 changes: 32 additions & 0 deletions SwapChainPanelBugRepro/App.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "pch.h"
#include "App.h"
#include "MainWindow.h"


namespace winrt::SwapChainPanelBugRepro::implementation
{
using namespace winrt::Microsoft::UI::Xaml;


App::App()
{
InitializeComponent();

#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException([](IInspectable const&, UnhandledExceptionEventArgs const& e) {
if(IsDebuggerPresent())
{
auto errorMessage = e.Message();
__debugbreak();
}
});
#endif
}


void App::OnLaunched(LaunchActivatedEventArgs const&)
{
window = winrt::make<MainWindow>();
window.Activate();
}
}
17 changes: 17 additions & 0 deletions SwapChainPanelBugRepro/App.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "App.xaml.g.h"


namespace winrt::SwapChainPanelBugRepro::implementation
{
struct App : AppT<App>
{
public:
App();
void OnLaunched(winrt::Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);

private:
winrt::Microsoft::UI::Xaml::Window window{ nullptr };
};
}
3 changes: 3 additions & 0 deletions SwapChainPanelBugRepro/App.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace SwapChainPanelBugRepro
{
}
12 changes: 12 additions & 0 deletions SwapChainPanelBugRepro/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SwapChainPanelBugRepro.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SwapChainPanelBugRepro/Assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions SwapChainPanelBugRepro/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "pch.h"
#include "MainWindow.h"
#include "MainWindow.g.cpp"


namespace winrt::SwapChainPanelBugRepro::implementation
{
using namespace winrt;
using namespace winrt::Microsoft::UI::Xaml;
using namespace winrt::Microsoft::UI::Xaml::Controls;
using namespace winrt::Windows::UI::Xaml::Interop;


void MainWindow::OnLoaded(IInspectable const& sender, RoutedEventArgs const&) const
{
NavigationView navigationView = sender.try_as<NavigationView>();
navigationView.SelectedItem(navigationView.MenuItems().GetAt(0));
}


void MainWindow::OnSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) const
{
std::string selectedItemTagValue = to_string(unbox_value<hstring>(args.SelectedItem().try_as<NavigationViewItem>().Tag()));
sender.Content().try_as<Frame>().Navigate(_tagValueToPageTypeMap.at(selectedItemTagValue));
}


const std::map<std::string, TypeName, std::less<>> MainWindow::_tagValueToPageTypeMap =
{
{ "TrianglePage", xaml_typename<TrianglePage>() },
{ "SquarePage" , xaml_typename<SquarePage>() },
};
}
26 changes: 26 additions & 0 deletions SwapChainPanelBugRepro/MainWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <functional>
#include "MainWindow.g.h"


namespace winrt::SwapChainPanelBugRepro::implementation
{
struct MainWindow : MainWindowT<MainWindow>
{
public:
void OnLoaded(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args) const;
void OnSelectionChanged(winrt::Microsoft::UI::Xaml::Controls::NavigationView sender, winrt::Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs args) const;

private:
static const std::map<std::string, winrt::Windows::UI::Xaml::Interop::TypeName, std::less<>> _tagValueToPageTypeMap;
};
}


namespace winrt::SwapChainPanelBugRepro::factory_implementation
{
struct MainWindow : MainWindowT<MainWindow, implementation::MainWindow>
{
};
}
8 changes: 8 additions & 0 deletions SwapChainPanelBugRepro/MainWindow.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SwapChainPanelBugRepro
{
[default_interface]
runtimeclass MainWindow : Microsoft.UI.Xaml.Window
{
MainWindow();
}
}
24 changes: 24 additions & 0 deletions SwapChainPanelBugRepro/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="SwapChainPanelBugRepro.MainWindow"
mc:Ignorable="d">

<NavigationView
Background="White"
PaneDisplayMode="Top"
IsBackButtonVisible="Collapsed"
IsBackEnabled="False"
IsSettingsVisible="False"
Loaded="OnLoaded"
SelectionChanged="OnSelectionChanged">
<NavigationView.MenuItems>
<NavigationViewItem Content="Triangle View" Tag="TrianglePage"/>
<NavigationViewItem Content="Square View" Tag="SquarePage"/>
</NavigationView.MenuItems>
<Frame/>
</NavigationView>

</Window>
51 changes: 51 additions & 0 deletions SwapChainPanelBugRepro/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="SwapChainPanelBugRepro"
Publisher="CN=ackh"
Version="1.0.0.0" />

<Properties>
<DisplayName>SwapChainPanelBugRepro</DisplayName>
<PublisherDisplayName>ackh</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily
Name="Windows.Desktop"
MinVersion="10.0.18362.0"
MaxVersionTested="10.0.20348.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application
Id="SwapChainPanelBugRepro"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="SwapChainPanelBugRepro"
Description="SwapChainPanelBugRepro"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
8 changes: 8 additions & 0 deletions SwapChainPanelBugRepro/Page/SquarePage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "pch.h"
#include "SquarePage.h"
#include "SquarePage.g.cpp"


namespace winrt::SwapChainPanelBugRepro::implementation
{
}
19 changes: 19 additions & 0 deletions SwapChainPanelBugRepro/Page/SquarePage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "SquarePage.g.h"


namespace winrt::SwapChainPanelBugRepro::implementation
{
struct SquarePage : SquarePageT<SquarePage>
{
};
}


namespace winrt::SwapChainPanelBugRepro::factory_implementation
{
struct SquarePage : SquarePageT<SquarePage, implementation::SquarePage>
{
};
}
8 changes: 8 additions & 0 deletions SwapChainPanelBugRepro/Page/SquarePage.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SwapChainPanelBugRepro
{
[default_interface]
runtimeclass SquarePage : Microsoft.UI.Xaml.Controls.Page
{
SquarePage();
}
}
16 changes: 16 additions & 0 deletions SwapChainPanelBugRepro/Page/SquarePage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="using:SwapChainPanelBugRepro"
x:Class="SwapChainPanelBugRepro.SquarePage"
mc:Ignorable="d">

<Controls:SquareView
Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>

</Page>
Loading

0 comments on commit 97a6dfd

Please sign in to comment.