diff --git a/WindowsDesktop.sln b/WindowsDesktop.sln
index f7fec4ff..6f7100c0 100644
--- a/WindowsDesktop.sln
+++ b/WindowsDesktop.sln
@@ -121,6 +121,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaEngineApp", "WindowsDe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaEngineAppVideo", "WindowsDesktop\MediaFoundation\MediaEngineAppVideo\MediaEngineAppVideo.csproj", "{232B973F-403D-41F0-BD99-8FE0ED4CBE1D}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasePrimitivesApp", "WindowsDesktop\Direct2D1\BasePrimitivesApp\BasePrimitivesApp.csproj", "{ECB47EB9-EDF8-49AE-8278-AA388056FA19}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -465,6 +467,14 @@ Global
{232B973F-403D-41F0-BD99-8FE0ED4CBE1D}.Win8Debug|Any CPU.Build.0 = Debug|Any CPU
{232B973F-403D-41F0-BD99-8FE0ED4CBE1D}.Win8Release|Any CPU.ActiveCfg = Release|Any CPU
{232B973F-403D-41F0-BD99-8FE0ED4CBE1D}.Win8Release|Any CPU.Build.0 = Release|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Win8Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Win8Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Win8Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}.Win8Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -512,5 +522,6 @@ Global
{48F1120F-3F33-4542-A696-D99BF675258E} = {9F670CC4-1680-4967-99FB-B397024DD10A}
{72370861-90C4-46C3-8B66-C0D85370659C} = {BD136A46-83B6-4497-9566-1CE674F76ACB}
{232B973F-403D-41F0-BD99-8FE0ED4CBE1D} = {BD136A46-83B6-4497-9566-1CE674F76ACB}
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19} = {3010221B-0CD5-4DBD-B95E-C852B6E654FA}
EndGlobalSection
EndGlobal
diff --git a/WindowsDesktop/Direct2D1/BasePrimitivesApp/BasePrimitivesApp.csproj b/WindowsDesktop/Direct2D1/BasePrimitivesApp/BasePrimitivesApp.csproj
new file mode 100644
index 00000000..3d174e43
--- /dev/null
+++ b/WindowsDesktop/Direct2D1/BasePrimitivesApp/BasePrimitivesApp.csproj
@@ -0,0 +1,81 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {ECB47EB9-EDF8-49AE-8278-AA388056FA19}
+ WinExe
+ Properties
+ BasePrimitivesApp
+ BasePrimitivesApp
+ v2.0
+
+
+ 512
+ 221503b5
+ ..\..\
+ true
+
+
+ true
+ bin\Debug\
+ DEBUG;TRACE
+ full
+ AnyCPU
+ prompt
+
+
+ bin\Release\
+ TRACE
+ true
+ pdbonly
+ AnyCPU
+ prompt
+ true
+ true
+
+
+
+ $(SharpDXPackageBinDir)\SharpDX.dll
+
+
+ $(SharpDXPackageBinDir)\SharpDX.Direct2D1.dll
+
+
+ $(SharpDXPackageBinDir)\SharpDX.Direct3D10.dll
+
+
+ $(SharpDXPackageBinDir)\SharpDX.DXGI.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WindowsDesktop/Direct2D1/BasePrimitivesApp/Program.cs b/WindowsDesktop/Direct2D1/BasePrimitivesApp/Program.cs
new file mode 100644
index 00000000..37bcb54f
--- /dev/null
+++ b/WindowsDesktop/Direct2D1/BasePrimitivesApp/Program.cs
@@ -0,0 +1,299 @@
+// Copyright (c) 2010-2013 SharpDX - Julien Vulliet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using SharpDX;
+using SharpDX.Direct2D1;
+using SharpDX.DirectWrite;
+using SharpDX.Windows;
+using System.Windows.Forms;
+
+using D2DFactory = SharpDX.Direct2D1.Factory;
+using DWriteFactory = SharpDX.DirectWrite.Factory;
+
+// Very quick overview to show how to draw shapes in Direct2D
+namespace BaePrimitivesApp
+{
+ public class Program
+ {
+ private static D2DFactory d2dFactory;
+ private static DWriteFactory dwFactory;
+ private static RenderForm mainForm;
+
+ private static WindowRenderTarget renderTarget;
+
+ //Various brushes for our example
+ private static SolidColorBrush backgroundBrush;
+ private static SolidColorBrush borderBrush;
+
+ private static TextFormat textFormat;
+ private static StrokeStyle simpleDashedStroke;
+
+
+ [STAThread]
+ static void Main(string[] args)
+ {
+ mainForm = new RenderForm("Advanced Text rendering demo");
+
+ d2dFactory = new D2DFactory();
+ dwFactory = new DWriteFactory(SharpDX.DirectWrite.FactoryType.Shared);
+
+ //Simple text format to draw text
+ textFormat = new TextFormat(dwFactory, "Arial", 16.0f);
+
+ //Dashed Stroke
+ simpleDashedStroke = new StrokeStyle(d2dFactory, new StrokeStyleProperties() { DashStyle = DashStyle.Dash });
+
+ CreateResources();
+
+ var bgcolor = new Color4(0.0f,0.0f,0.0f,1.0f);
+
+ RenderLoop.Run(mainForm, () =>
+ {
+ renderTarget.BeginDraw();
+ renderTarget.Clear(bgcolor);
+
+ DrawBasicShapes();
+
+ DrawCurves();
+
+ DrawCompositeGeometry();
+
+ try
+ {
+ renderTarget.EndDraw();
+ }
+ catch
+ {
+ CreateResources();
+ }
+ });
+
+ d2dFactory.Dispose();
+ dwFactory.Dispose();
+
+ borderBrush.Dispose();
+ backgroundBrush.Dispose();
+ renderTarget.Dispose();
+ }
+
+ private static void CreateResources()
+ {
+ if (renderTarget != null) { renderTarget.Dispose(); }
+ if (backgroundBrush != null) { backgroundBrush.Dispose(); }
+ if (borderBrush != null) { borderBrush.Dispose(); }
+
+
+ HwndRenderTargetProperties wtp = new HwndRenderTargetProperties();
+ wtp.Hwnd = mainForm.Handle;
+ wtp.PixelSize = new Size2(mainForm.ClientSize.Width, mainForm.ClientSize.Height);
+ wtp.PresentOptions = PresentOptions.Immediately;
+ renderTarget = new WindowRenderTarget(d2dFactory, new RenderTargetProperties(), wtp);
+
+ backgroundBrush = new SolidColorBrush(renderTarget, new Color4(0.3f, 0.3f, 0.3f, 1.0f));
+ borderBrush = new SolidColorBrush(renderTarget, new Color4(0.9f, 0.9f, 0.9f, 1.0f));
+
+ }
+
+ private static void DrawBasicShapes()
+ {
+ int x = 20;
+ int y = 20;
+
+ //Simple shapes rendering
+ renderTarget.DrawText("Shapes", textFormat, new RectangleF(x, y, 100, 30), backgroundBrush);
+
+ y += 40;
+
+ var rectangle = new RectangleF(x, y, 100, 30);
+
+ renderTarget.FillRectangle(rectangle, backgroundBrush);
+ renderTarget.DrawRectangle(rectangle, borderBrush);
+
+ y += 40;
+
+ var roundRect = new RoundedRectangle()
+ {
+ Rect = new RectangleF(x, y, 100, 30),
+ RadiusX = 3,
+ RadiusY = 3
+ };
+
+ renderTarget.FillRoundedRectangle(roundRect, backgroundBrush);
+ renderTarget.DrawRoundedRectangle(roundRect, borderBrush);
+
+ y += 40;
+
+ var ellipse = new Ellipse()
+ {
+ Point = new Vector2(x + 50, y + 10), //In case of ellipse we use center
+ RadiusX = 30,
+ RadiusY = 10
+ };
+
+ renderTarget.FillEllipse(ellipse, backgroundBrush);
+ renderTarget.DrawEllipse(ellipse, borderBrush);
+
+ y += 40;
+
+ //Show a few more primitives with different strokes
+
+ rectangle = new RectangleF(x, y, 100, 30);
+ renderTarget.DrawRectangle(rectangle, borderBrush, 5.0f); //Large stroke style
+ y += 40;
+
+ rectangle = new RectangleF(x, y, 100, 30);
+ renderTarget.DrawRectangle(rectangle, borderBrush, 2.0f, simpleDashedStroke);
+ y += 40;
+ }
+
+ private static void DrawCurves()
+ {
+
+ //Now show a few path examples
+ int y = 20;
+ int x = 200;
+ renderTarget.DrawText("Paths", textFormat, new RectangleF(x, y, 100, 30), backgroundBrush);
+
+ //Simple line
+ y += 40;
+ renderTarget.DrawLine(new Vector2(x, y), new Vector2(x + 50, y + 15), borderBrush);
+
+ y += 40;
+
+ /*To construct bezier we need to build path geometry, here they built every frame,
+ * but you will likely want to cache geometry construction.
+ * Geometry does not depend on rendertarget but factory, so it can be reused */
+
+ var quadBezier = new PathGeometry(d2dFactory);
+
+ /*Geometry sink allows us to add curves to our path, please note that we can add as many as we want */
+ var geometrySink = quadBezier.Open();
+
+ //Start a curve
+ geometrySink.BeginFigure(new Vector2(x, y), FigureBegin.Hollow);
+ geometrySink.AddQuadraticBezier(new QuadraticBezierSegment()
+ {
+ Point1 = new Vector2(x + 20, y + 15), //Control point
+ Point2 = new Vector2(x + 60, y + 2) //End point
+ });
+
+ geometrySink.EndFigure(FigureEnd.Open);
+
+ geometrySink.Close(); //Finish curve
+
+ renderTarget.DrawGeometry(quadBezier, borderBrush);
+ quadBezier.Dispose();
+
+
+ //Just build a closed quad bezier now
+ var quadBezierCLosed = new PathGeometry(d2dFactory);
+
+ /*Geometry sink allows us to add curves to our path, please note that we can add as many as we want */
+ var closedGeometrySink = quadBezierCLosed.Open();
+
+ //Start a curve
+ closedGeometrySink.BeginFigure(new Vector2(x, y), FigureBegin.Hollow);
+ closedGeometrySink.AddQuadraticBezier(new QuadraticBezierSegment()
+ {
+ Point1 = new Vector2(x + 20, y + 15), //Control point
+ Point2 = new Vector2(x + 60, y + 2) //End point
+ });
+
+ closedGeometrySink.EndFigure(FigureEnd.Closed); //Here we tell d2d to finish back path to original point
+
+ closedGeometrySink.Close(); //Finish curve
+
+ renderTarget.DrawGeometry(quadBezierCLosed, borderBrush);
+
+ quadBezierCLosed.Dispose();
+
+ y += 80;
+
+ //Now we'll draw a more complex path
+ var complexPath = new PathGeometry(d2dFactory);
+
+ var complexSink = complexPath.Open();
+
+ complexSink.BeginFigure(new Vector2(x,y), FigureBegin.Hollow);
+
+ complexSink.AddLine(new Vector2(x + 20, y + 50));
+ complexSink.AddLine(new Vector2(x + 10, y + 5));
+ complexSink.AddBezier(new BezierSegment()
+ {
+ Point1 = new Vector2(x + 50, y + 30),
+ Point2 = new Vector2(x + 20, y + 75),
+ Point3 = new Vector2(x + 30, y + 100)
+ });
+
+ complexSink.EndFigure(FigureEnd.Open);
+ complexSink.Close();
+
+ renderTarget.DrawGeometry(complexPath, borderBrush);
+
+ complexPath.Dispose();
+ }
+
+
+ private static void DrawCompositeGeometry()
+ {
+ int x = 400;
+ int y = 20;
+
+ //Composite shapes rendering
+ renderTarget.DrawText("Composite", textFormat, new RectangleF(x, y, 100, 30), backgroundBrush);
+
+ y += 100;
+
+ var e1 = new Ellipse()
+ {
+ Point = new Vector2(x+50,y),
+ RadiusX = 100,
+ RadiusY = 30
+ };
+
+ var e2 = new Ellipse()
+ {
+ Point = new Vector2(x+20,y),
+ RadiusX = 50,
+ RadiusY = 60
+ };
+
+
+ //Same as per curves, you'll likely want to cache geometry construction, composition can be expensive
+ EllipseGeometry ellipse1 = new EllipseGeometry(d2dFactory, e1);
+ EllipseGeometry ellipse2 = new EllipseGeometry(d2dFactory, e2);
+
+ PathGeometry combinedGeometry = new PathGeometry(d2dFactory);
+ GeometrySink sink = combinedGeometry.Open();
+
+ ellipse1.Combine(ellipse2, CombineMode.Intersect, sink); //You can easily try other combine modes here
+
+ sink.Close();
+
+ renderTarget.FillGeometry(combinedGeometry, backgroundBrush);
+ renderTarget.DrawGeometry(combinedGeometry, borderBrush);
+
+ combinedGeometry.Dispose();
+ ellipse1.Dispose();
+ ellipse2.Dispose();
+ }
+
+ }
+}
diff --git a/WindowsDesktop/Direct2D1/BasePrimitivesApp/Properties/AssemblyInfo.cs b/WindowsDesktop/Direct2D1/BasePrimitivesApp/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..867562ec
--- /dev/null
+++ b/WindowsDesktop/Direct2D1/BasePrimitivesApp/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TextRenderingApp")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("TextRenderingApp")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("2a7209b1-9362-4b68-ae9b-0c8c4faec8c6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/WindowsDesktop/Direct2D1/BasePrimitivesApp/packages.config b/WindowsDesktop/Direct2D1/BasePrimitivesApp/packages.config
new file mode 100644
index 00000000..366777b5
--- /dev/null
+++ b/WindowsDesktop/Direct2D1/BasePrimitivesApp/packages.config
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WindowsUWP.sln b/WindowsUWP.sln
new file mode 100644
index 00000000..15ce31e3
--- /dev/null
+++ b/WindowsUWP.sln
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPSwapchain", "WindowsUWP\Direct3D11\Swapchain\UWPSwapchain.csproj", "{948B81A7-97FF-4C62-82B6-35A8733DDD7F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|ARM.ActiveCfg = Debug|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|ARM.Build.0 = Debug|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|ARM.Deploy.0 = Debug|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x64.ActiveCfg = Debug|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x64.Build.0 = Debug|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x64.Deploy.0 = Debug|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x86.ActiveCfg = Debug|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x86.Build.0 = Debug|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x86.Deploy.0 = Debug|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|ARM.ActiveCfg = Release|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|ARM.Build.0 = Release|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|ARM.Deploy.0 = Release|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x64.ActiveCfg = Release|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x64.Build.0 = Release|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x64.Deploy.0 = Release|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x86.ActiveCfg = Release|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x86.Build.0 = Release|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {91C21AD8-0B37-492E-B233-289135C42A0E}
+ EndGlobalSection
+EndGlobal
diff --git a/WindowsUWP/Direct3D11/Swapchain/App.xaml b/WindowsUWP/Direct3D11/Swapchain/App.xaml
new file mode 100644
index 00000000..7f60b57e
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/App.xaml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/WindowsUWP/Direct3D11/Swapchain/App.xaml.cs b/WindowsUWP/Direct3D11/Swapchain/App.xaml.cs
new file mode 100644
index 00000000..6f2f7948
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/App.xaml.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+namespace UWPSwapchain
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App : Application
+ {
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ this.InitializeComponent();
+ this.Suspending += OnSuspending;
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used such as when the application is launched to open a specific file.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
+ {
+ Frame rootFrame = Window.Current.Content as Frame;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (rootFrame == null)
+ {
+ // Create a Frame to act as the navigation context and navigate to the first page
+ rootFrame = new Frame();
+
+ rootFrame.NavigationFailed += OnNavigationFailed;
+
+ if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ //TODO: Load state from previously suspended application
+ }
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+
+ if (e.PrelaunchActivated == false)
+ {
+ if (rootFrame.Content == null)
+ {
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ rootFrame.Navigate(typeof(MainPage), e.Arguments);
+ }
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+ }
+
+ ///
+ /// Invoked when Navigation to a certain page fails
+ ///
+ /// The Frame which failed navigation
+ /// Details about the navigation failure
+ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
+ }
+
+ ///
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ ///
+ /// The source of the suspend request.
+ /// Details about the suspend request.
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+ //TODO: Save application state and stop any background activity
+ deferral.Complete();
+ }
+ }
+}
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/LockScreenLogo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/LockScreenLogo.scale-200.png
new file mode 100644
index 00000000..735f57ad
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/LockScreenLogo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/SplashScreen.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/SplashScreen.scale-200.png
new file mode 100644
index 00000000..023e7f1f
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/SplashScreen.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Square150x150Logo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Square150x150Logo.scale-200.png
new file mode 100644
index 00000000..af49fec1
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Square150x150Logo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.scale-200.png
new file mode 100644
index 00000000..ce342a2e
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644
index 00000000..f6c02ce9
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/StoreLogo.png b/WindowsUWP/Direct3D11/Swapchain/Assets/StoreLogo.png
new file mode 100644
index 00000000..7385b56c
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/StoreLogo.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Wide310x150Logo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Wide310x150Logo.scale-200.png
new file mode 100644
index 00000000..288995b3
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml
new file mode 100644
index 00000000..dff91358
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml.cs b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml.cs
new file mode 100644
index 00000000..89868296
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml.cs
@@ -0,0 +1,151 @@
+using SharpDX.DXGI;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using SharpDX;
+using SharpDX.Direct3D11;
+using Windows.ApplicationModel;
+using System.Text;
+using System.Diagnostics;
+
+namespace UWPSwapchain
+{
+
+
+ public sealed partial class MainPage : Page
+ {
+ SharpDX.Direct3D11.Device device;
+ SharpDX.Direct3D11.DeviceContext deviceContext;
+
+ SharpDX.DXGI.SwapChain1 swapchain;
+ Texture2D backBufferTexture;
+ RenderTargetView backBufferView;
+
+ Stopwatch sw = Stopwatch.StartNew();
+
+ public MainPage()
+ {
+ this.InitializeComponent();
+
+ bool enableDebug = false;
+
+ DeviceCreationFlags flags = DeviceCreationFlags.BgraSupport;
+ if (enableDebug)
+ flags |= DeviceCreationFlags.Debug;
+
+ this.device = new SharpDX.Direct3D11.Device(SharpDX.Direct3D.DriverType.Hardware, flags);
+ this.deviceContext = this.device.ImmediateContext;
+ }
+
+ private void CompositionTarget_Rendering(object sender, object e)
+ {
+ SharpDX.Color4 c = Color.Red;
+ c.Red = (float)Math.Abs(Math.Sin(sw.Elapsed.TotalSeconds));
+
+ //This is your render call, perform all render tasks and then call present on the swap chain
+ this.deviceContext.ClearRenderTargetView(this.backBufferView, c);
+
+ //Attach render target and set viewport
+ this.deviceContext.OutputMerger.SetRenderTargets(this.backBufferView);
+ this.deviceContext.Rasterizer.SetViewport(new ViewportF(0.0f, 0.0f, this.backBufferTexture.Description.Width, this.backBufferTexture.Description.Height, 0.0f, 1.0f));
+
+ //perform draw calls here
+
+ this.swapchain.Present(0, PresentFlags.None);
+ }
+
+ private void panel_Loaded(object sender, RoutedEventArgs e)
+ {
+ //This is trigerred when panel is loaded, you can now create your swap chain.
+
+ //Please note : Do not use this.panel.Width, make sure to use render size as width property returns NaN on create
+ SwapChainDescription1 swapChainDescription = new SwapChainDescription1()
+ {
+ AlphaMode = AlphaMode.Ignore,
+ BufferCount = 2,
+ Format = Format.R8G8B8A8_UNorm,
+ Height = (int)(this.panel.RenderSize.Height),
+ Width = (int)(this.panel.RenderSize.Width),
+ SampleDescription = new SampleDescription(1, 0),
+ Scaling = SharpDX.DXGI.Scaling.Stretch,
+ Stereo = false,
+ SwapEffect = SwapEffect.FlipSequential,
+ Usage = Usage.RenderTargetOutput
+ };
+
+ using (SharpDX.DXGI.Device3 dxgiDevice3 = this.device.QueryInterface())
+ {
+ using (SharpDX.DXGI.Factory3 dxgiFactory3 = dxgiDevice3.Adapter.GetParent())
+ {
+ SharpDX.DXGI.SwapChain1 swapChain1 = new SharpDX.DXGI.SwapChain1(dxgiFactory3, this.device, ref swapChainDescription);
+ this.swapchain = swapChain1;
+ }
+ }
+
+ using (SharpDX.DXGI.ISwapChainPanelNative nativeObject = SharpDX.ComObject.As(this.panel))
+ {
+ nativeObject.SwapChain = this.swapchain;
+ }
+
+ this.backBufferTexture = this.swapchain.GetBackBuffer(0);
+ this.backBufferView = new RenderTargetView(this.device, this.backBufferTexture);
+
+ CompositionTarget.Rendering += CompositionTarget_Rendering;
+ Application.Current.Suspending += Current_Suspending;
+ }
+
+ private void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
+ {
+ //This is the only part where you will receive a "close event", you should serialize any state so app can resume correctly.
+
+ //Please note that this method has a time out (e.SuspendingOperation.Deadline), if you do not return prior to this time, application will terminate instead of being suspended.
+
+ if (this.swapchain != null)
+ {
+ this.deviceContext.ClearState();
+ using (SharpDX.DXGI.Device3 dxgiDevice3 = this.device.QueryInterface())
+ dxgiDevice3.Trim();
+ }
+
+
+ }
+
+ private void panel_Unloaded(object sender, RoutedEventArgs e)
+ {
+ //On uwp windows 10 , this is never called, quitting the app does not do anything on it
+ }
+
+ private void panel_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ /* Resize swap chain, to do it cleanly, we clear state (to ensure resources are not bound to pipeline, and
+ * dispose associated resources (eg : render view and texture object)
+ * Once done, we can call resizebuffers, and create direct3d11 objects again */
+ if (this.swapchain != null)
+ {
+ this.deviceContext.ClearState();
+
+ Size2 newSize = new Size2((int)e.NewSize.Width, (int)e.NewSize.Height);
+
+ Utilities.Dispose(ref this.backBufferView);
+ Utilities.Dispose(ref this.backBufferTexture);
+
+ this.swapchain.ResizeBuffers(this.swapchain.Description.BufferCount, (int)e.NewSize.Width, (int)e.NewSize.Height, swapchain.Description1.Format, swapchain.Description1.Flags);
+
+ this.backBufferTexture = this.swapchain.GetBackBuffer(0);
+ this.backBufferView = new RenderTargetView(this.device, this.backBufferTexture);
+
+ }
+ }
+ }
+}
diff --git a/WindowsUWP/Direct3D11/Swapchain/Package.appxmanifest b/WindowsUWP/Direct3D11/Swapchain/Package.appxmanifest
new file mode 100644
index 00000000..ac056a7d
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/Package.appxmanifest
@@ -0,0 +1,29 @@
+
+
+
+
+
+ TestUWPDX
+ vux
+ Assets\StoreLogo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WindowsUWP/Direct3D11/Swapchain/Properties/AssemblyInfo.cs b/WindowsUWP/Direct3D11/Swapchain/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..69864852
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/Properties/AssemblyInfo.cs
@@ -0,0 +1,29 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TestUWPDX")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TestUWPDX")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/WindowsUWP/Direct3D11/Swapchain/Properties/Default.rd.xml b/WindowsUWP/Direct3D11/Swapchain/Properties/Default.rd.xml
new file mode 100644
index 00000000..7c40ffeb
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/Properties/Default.rd.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WindowsUWP/Direct3D11/Swapchain/UWPSwapchain.csproj b/WindowsUWP/Direct3D11/Swapchain/UWPSwapchain.csproj
new file mode 100644
index 00000000..8ae59154
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/UWPSwapchain.csproj
@@ -0,0 +1,154 @@
+
+
+
+
+ Debug
+ x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}
+ AppContainerExe
+ Properties
+ TestUWPDX
+ TestUWPDX
+ en-US
+ UAP
+ 10.0.16299.0
+ 10.0.16299.0
+ 14
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ true
+ TestUWPDX_TemporaryKey.pfx
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\ARM\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\ARM\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+ true
+
+
+ bin\x64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+ true
+
+
+ PackageReference
+
+
+
+ App.xaml
+
+
+ MainPage.xaml
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+ 5.2.2
+
+
+ 4.0.1
+
+
+ 4.0.1
+
+
+ 4.0.1
+
+
+
+ 14.0
+
+
+
+
\ No newline at end of file