OSDN Git Service

WPF版もDirectX11に対応させた
authorkonekoneko <test2214@hotmail.co.jp>
Sat, 5 Nov 2016 05:00:13 +0000 (10:30 +0530)
committerkonekoneko <test2214@hotmail.co.jp>
Sat, 5 Nov 2016 05:00:13 +0000 (10:30 +0530)
Libs/SharpDX.Direct3D10.dll [deleted file]
Libs/SharpDX.Direct3D11.dll [new file with mode: 0644]
WPF/FooEditEngine/Direct2D/D2DRender.cs
WPF/FooEditEngine/FooEditEngine.csproj

diff --git a/Libs/SharpDX.Direct3D10.dll b/Libs/SharpDX.Direct3D10.dll
deleted file mode 100644 (file)
index bf721e0..0000000
Binary files a/Libs/SharpDX.Direct3D10.dll and /dev/null differ
diff --git a/Libs/SharpDX.Direct3D11.dll b/Libs/SharpDX.Direct3D11.dll
new file mode 100644 (file)
index 0000000..9ca96b6
Binary files /dev/null and b/Libs/SharpDX.Direct3D11.dll differ
index 7446053..cfa3f16 100644 (file)
@@ -24,7 +24,7 @@ using DotNetTextStore.UnmanagedAPI.WinDef;
 using SharpDX;
 using D2D = SharpDX.Direct2D1;
 using DW = SharpDX.DirectWrite;
-using D3D10 = SharpDX.Direct3D10;
+using D3D11 = SharpDX.Direct3D11;
 using D3D9 = SharpDX.Direct3D9;
 using DXGI = SharpDX.DXGI;
 
@@ -33,9 +33,9 @@ namespace FooEditEngine.WPF
     sealed class D2DRender : D2DRenderCommon, IEditorRender
     {
         DotNetTextStore.TextStore store;
-        D3D10.Texture2D texture;
+        D3D11.Texture2D texture;
         DXGI.Surface surface;
-        D3D10.Device device;
+        D3D11.Device device;
         D3D9.Device device9;
         D3D9.Surface surface9;
         new D2D.RenderTarget render;
@@ -159,7 +159,7 @@ namespace FooEditEngine.WPF
                 else
                     this.FillBackground(updateRect);
                 base.EndDraw();
-                this.device.Flush();
+                this.device.ImmediateContext.Flush();
 
                 this.imageSource.AddDirtyRect(new Int32Rect(0, 0, (int)this.imageSource.Width, (int)this.imageSource.Height));
                 this.imageSource.Unlock();
@@ -286,16 +286,18 @@ namespace FooEditEngine.WPF
 
         void CreateDevice()
         {
-            D3D10.FeatureLevel[] levels = new D3D10.FeatureLevel[]{D3D10.FeatureLevel.Level_10_1,
-                D3D10.FeatureLevel.Level_10_0,
-                D3D10.FeatureLevel.Level_9_3,
-                D3D10.FeatureLevel.Level_9_2,
-                D3D10.FeatureLevel.Level_9_1};
-            foreach (D3D10.FeatureLevel level in levels)
+            SharpDX.Direct3D.FeatureLevel[] levels = new SharpDX.Direct3D.FeatureLevel[]{
+                SharpDX.Direct3D.FeatureLevel.Level_11_0,
+                SharpDX.Direct3D.FeatureLevel.Level_10_1,
+                SharpDX.Direct3D.FeatureLevel.Level_10_0,
+                SharpDX.Direct3D.FeatureLevel.Level_9_3,
+                SharpDX.Direct3D.FeatureLevel.Level_9_2,
+                SharpDX.Direct3D.FeatureLevel.Level_9_1};
+            foreach (var level in levels)
             {
                 try
                 {
-                    this.device = new D3D10.Device1(D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.BgraSupport,level);
+                    this.device = new D3D11.Device(SharpDX.Direct3D.DriverType.Hardware, D3D11.DeviceCreationFlags.BgraSupport, level);
                     break;
                 }
                 catch
@@ -372,18 +374,18 @@ namespace FooEditEngine.WPF
 
         protected override D2D.RenderTarget ConstructRender(D2D.Factory factory, D2D.RenderTargetProperties prop, double width, double height)
         {
-            D3D10.Texture2DDescription desc = new D3D10.Texture2DDescription();
+            D3D11.Texture2DDescription desc = new D3D11.Texture2DDescription();
             desc.Width = (int)width;
             desc.Height = (int)height;
             desc.MipLevels = 1;
             desc.ArraySize = 1;
             desc.Format = DXGI.Format.B8G8R8A8_UNorm;
             desc.SampleDescription = new DXGI.SampleDescription(1, 0);
-            desc.Usage = D3D10.ResourceUsage.Default;
-            desc.BindFlags = D3D10.BindFlags.RenderTarget | D3D10.BindFlags.ShaderResource;
-            desc.CpuAccessFlags = D3D10.CpuAccessFlags.None;
-            desc.OptionFlags = D3D10.ResourceOptionFlags.Shared;
-            this.texture = new D3D10.Texture2D(this.device, desc);
+            desc.Usage = D3D11.ResourceUsage.Default;
+            desc.BindFlags = D3D11.BindFlags.RenderTarget | D3D11.BindFlags.ShaderResource;
+            desc.CpuAccessFlags = D3D11.CpuAccessFlags.None;
+            desc.OptionFlags = D3D11.ResourceOptionFlags.Shared;
+            this.texture = new D3D11.Texture2D(this.device, desc);
 
             this.surface = this.texture.QueryInterface<DXGI.Surface>();
 
index fdce970..f9d62b6 100644 (file)
@@ -46,8 +46,8 @@
     <Reference Include="SharpDX.Direct2D1">
       <HintPath>..\..\Libs\SharpDX.Direct2D1.dll</HintPath>
     </Reference>
-    <Reference Include="SharpDX.Direct3D10">
-      <HintPath>..\..\Libs\SharpDX.Direct3D10.dll</HintPath>
+    <Reference Include="SharpDX.Direct3D11">
+      <HintPath>..\..\Libs\SharpDX.Direct3D11.dll</HintPath>
     </Reference>
     <Reference Include="SharpDX.Direct3D9">
       <HintPath>..\..\Libs\SharpDX.Direct3D9.dll</HintPath>