diff --git a/Desktop/Common/Direct3D10DemoApp.cs b/Desktop/Common/Direct3D10DemoApp.cs new file mode 100644 index 00000000..ca051233 --- /dev/null +++ b/Desktop/Common/Direct3D10DemoApp.cs @@ -0,0 +1,118 @@ +// 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 SharpDX.Direct3D; +using SharpDX.Direct3D10; +using SharpDX.DXGI; +using Device = SharpDX.Direct3D10.Device; +using Device1 = SharpDX.Direct3D10.Device1; +using DriverType = SharpDX.Direct3D10.DriverType; +using FeatureLevel = SharpDX.Direct3D10.FeatureLevel; + + +namespace SharpDX.Samples +{ + /// + /// Root class for Direct3D10(.1) Demo App + /// + public class Direct3D10DemoApp : DemoApp + { + Device1 _device; + SwapChain _swapChain; + Texture2D _backBuffer; + RenderTargetView _backBufferView; + + /// + /// Returns the device + /// + public Device1 Device + { + get + { + return _device; + } + } + + /// + /// Returns the backbuffer used by the SwapChain + /// + public Texture2D BackBuffer + { + get + { + return _backBuffer; + } + } + + /// + /// Returns the render target view on the backbuffer used by the SwapChain. + /// + public RenderTargetView BackBufferView + { + get + { + return _backBufferView; + } + } + + protected override void Initialize(DemoConfiguration demoConfiguration) + { + // SwapChain description + var desc = new SwapChainDescription() + { + BufferCount = 1, + ModeDescription = + new ModeDescription(demoConfiguration.Width, demoConfiguration.Height, + new Rational(60, 1), Format.R8G8B8A8_UNorm), + IsWindowed = true, + OutputHandle = DisplayHandle, + SampleDescription = new SampleDescription(1, 0), + SwapEffect = SwapEffect.Discard, + Usage = Usage.RenderTargetOutput + }; + + // Create Device and SwapChain + Device1.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, desc, FeatureLevel.Level_10_0, out _device, out _swapChain); + + // Ignore all windows events + Factory factory = _swapChain.GetParent(); + factory.MakeWindowAssociation(DisplayHandle, WindowAssociationFlags.IgnoreAll); + + // New RenderTargetView from the backbuffer + _backBuffer = Texture2D.FromSwapChain(_swapChain, 0); + + _backBufferView = new RenderTargetView(_device, _backBuffer); + + + } + + protected override void BeginDraw() + { + base.BeginDraw(); + Device.Rasterizer.SetViewports(new Viewport(0, 0, Config.Width, Config.Height)); + Device.OutputMerger.SetTargets(_backBufferView); + } + + + protected override void EndDraw() + { + _swapChain.Present(Config.WaitVerticalBlanking?1:0, PresentFlags.None); + } + } +} \ No newline at end of file diff --git a/Desktop/Common/SharpDX.Samples.csproj b/Desktop/Common/SharpDX.Samples.csproj index bc8e0ca8..96be8a8d 100644 --- a/Desktop/Common/SharpDX.Samples.csproj +++ b/Desktop/Common/SharpDX.Samples.csproj @@ -46,6 +46,9 @@ ..\..\..\Bin\Desktop\SharpDX.Direct2D1.dll + + ..\..\..\Bin\Desktop\SharpDX.Direct3D10.dll + ..\..\..\Bin\Desktop\SharpDX.Direct3D11.dll @@ -67,6 +70,7 @@ + diff --git a/Desktop/Direct3D10/DisplayFontApp/DisplayFontApp.csproj b/Desktop/Direct3D10/DisplayFontApp/DisplayFontApp.csproj new file mode 100644 index 00000000..5852f974 --- /dev/null +++ b/Desktop/Direct3D10/DisplayFontApp/DisplayFontApp.csproj @@ -0,0 +1,87 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {A0A13A2D-9D57-4057-AA8C-A46D18B99354} + WinExe + Properties + DisplayFontApp + DisplayFontApp + v4.5.1 + + + 512 + 10cd9ae8 + ..\..\ + + + true + bin\Debug\ + DEBUG;TRACE + full + AnyCPU + prompt + false + + + bin\Release\ + TRACE + true + pdbonly + AnyCPU + prompt + false + + + + + + + ..\..\..\..\Bin\Desktop\SharpDX.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.D3DCompiler.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Desktop.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Direct3D10.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.DXGI.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Mathematics.dll + + + + + + + + + + + + + + {93716298-9FA4-4002-AE0B-4C9F4705CCEA} + SharpDX.Samples + + + + + + + + \ No newline at end of file diff --git a/Desktop/Direct3D10/DisplayFontApp/Program.cs b/Desktop/Direct3D10/DisplayFontApp/Program.cs new file mode 100644 index 00000000..968aca91 --- /dev/null +++ b/Desktop/Direct3D10/DisplayFontApp/Program.cs @@ -0,0 +1,100 @@ +// 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; +using SharpDX; +using SharpDX.Direct3D10; +using SharpDX.Samples; + + +namespace DisplayFontApp +{ + /// + /// SharpDX Demo using D3D10 Font rendering. + /// Animates and draws a text, boucing on the screen limits. + /// + public class Program : Direct3D10DemoApp + { + private Font font; + private Rectangle fontDimension; + private float xDir, yDir; + private const string DisplayText = "SharpDX D3D10 Font"; + + protected override void Initialize(DemoConfiguration demoConfiguration) + { + base.Initialize(demoConfiguration); + + // Initialize the Font + FontDescription fontDescription = new FontDescription() + { + Height = 72, + Italic = false, + CharacterSet = FontCharacterSet.Ansi, + FaceName = "Arial", + MipLevels = 0, + OutputPrecision = FontPrecision.TrueType, + PitchAndFamily = FontPitchAndFamily.Default, + Quality = FontQuality.ClearType, + Weight = FontWeight.Bold + }; + + + font = new Font(Device, fontDescription); + + // Measure the text to display + fontDimension = font.MeasureText(null, DisplayText, new Rectangle(0, 0, 800, 600), FontDrawFlags.Center | FontDrawFlags.VerticalCenter); + + xDir = 1; + yDir = 1; + } + + protected override void Draw(DemoTime time) + { + base.Draw(time); + + Device.ClearRenderTargetView(BackBufferView, Color.White); + + // Make the text boucing on the screen limits + if ((fontDimension.Right + xDir) > Config.Width) + xDir = -1; + else if ((fontDimension.Left + xDir) <= 0) + xDir = 1; + + if ((fontDimension.Bottom + yDir) > Config.Height) + yDir = -1; + else if ((fontDimension.Top + yDir) <= 0) + yDir = 1; + + fontDimension.Left += (int)xDir; + fontDimension.Top += (int)yDir; + fontDimension.Bottom += (int)yDir; + fontDimension.Right += (int)xDir; + + // Draw the text + font.DrawText(null, DisplayText, fontDimension, FontDrawFlags.Center | FontDrawFlags.VerticalCenter, Color.Black); + } + + [STAThread] + static void Main(string[] args) + { + Program program = new Program(); + program.Run(new DemoConfiguration("SharpDX D3D10 Font Rendering Demo") { WaitVerticalBlanking = true }); + } + } +} \ No newline at end of file diff --git a/Desktop/Direct3D10/DisplayFontApp/Properties/AssemblyInfo.cs b/Desktop/Direct3D10/DisplayFontApp/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..cb087533 --- /dev/null +++ b/Desktop/Direct3D10/DisplayFontApp/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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("DisplayFontApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("DisplayFontApp")] +[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("2f297cfc-8862-458a-97dd-a8bafdb6eb94")] + +// 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/Desktop/Direct3D10/DisplayFontApp/app.config b/Desktop/Direct3D10/DisplayFontApp/app.config new file mode 100644 index 00000000..884f9844 --- /dev/null +++ b/Desktop/Direct3D10/DisplayFontApp/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Desktop/Direct3D10/DisplayFontApp/screenshot.png b/Desktop/Direct3D10/DisplayFontApp/screenshot.png new file mode 100644 index 00000000..20afaffd Binary files /dev/null and b/Desktop/Direct3D10/DisplayFontApp/screenshot.png differ diff --git a/Desktop/Direct3D10/DisplayFontApp/screenshot_small.png b/Desktop/Direct3D10/DisplayFontApp/screenshot_small.png new file mode 100644 index 00000000..2a06b9b1 Binary files /dev/null and b/Desktop/Direct3D10/DisplayFontApp/screenshot_small.png differ diff --git a/Desktop/Direct3D10/MiniCube/MiniCube.csproj b/Desktop/Direct3D10/MiniCube/MiniCube.csproj new file mode 100644 index 00000000..ee44593d --- /dev/null +++ b/Desktop/Direct3D10/MiniCube/MiniCube.csproj @@ -0,0 +1,108 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {3177A431-E344-4395-A5E7-F54DE5A1D397} + WinExe + Properties + MiniCube + MiniCube + v4.5.1 + + + 512 + 155db97a + ..\..\ + + + true + bin\Debug\ + DEBUG;TRACE + true + full + AnyCPU + prompt + false + + + bin\Release\ + TRACE + true + pdbonly + AnyCPU + prompt + false + + + true + bin\Win8Debug\ + DEBUG;TRACE + true + full + AnyCPU + prompt + false + false + false + false + + + bin\Win8Release\ + TRACE + true + pdbonly + AnyCPU + prompt + false + false + false + false + + + + ..\..\..\..\Bin\Desktop\SharpDX.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.D3DCompiler.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Desktop.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Direct3D10.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.DXGI.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Mathematics.dll + + + + + + + + + + + + + PreserveNewest + + + + + + + + \ No newline at end of file diff --git a/Desktop/Direct3D10/MiniCube/MiniCube.fx b/Desktop/Direct3D10/MiniCube/MiniCube.fx new file mode 100644 index 00000000..c6064ea5 --- /dev/null +++ b/Desktop/Direct3D10/MiniCube/MiniCube.fx @@ -0,0 +1,47 @@ +// 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. +struct VS_IN +{ + float4 pos : POSITION; + float4 col : COLOR; +}; + +struct PS_IN +{ + float4 pos : SV_POSITION; + float4 col : COLOR; +}; + +float4x4 worldViewProj; + +PS_IN VS( VS_IN input ) +{ + PS_IN output = (PS_IN)0; + + output.pos = mul(input.pos, worldViewProj); + output.col = input.col; + + return output; +} + +float4 PS( PS_IN input ) : SV_Target +{ + return input.col; +} diff --git a/Desktop/Direct3D10/MiniCube/Program.cs b/Desktop/Direct3D10/MiniCube/Program.cs new file mode 100644 index 00000000..402b54e0 --- /dev/null +++ b/Desktop/Direct3D10/MiniCube/Program.cs @@ -0,0 +1,211 @@ +// 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; +using System.Diagnostics; + +using SharpDX; +using SharpDX.D3DCompiler; +using SharpDX.Direct3D; +using SharpDX.Direct3D10; +using SharpDX.DXGI; +using SharpDX.Windows; +using Buffer = SharpDX.Direct3D10.Buffer; +using Device = SharpDX.Direct3D10.Device; +using DriverType = SharpDX.Direct3D10.DriverType; + +namespace MiniCube +{ + /// + /// SharpDX MiniCube Direct3D 10 Sample + /// + internal static class Program + { + [STAThread] + private static void Main() + { + var form = new RenderForm("SharpDX - MiniCube Direct3D 10 Sample"); + + // SwapChain description + var desc = new SwapChainDescription() + { + BufferCount = 1, + ModeDescription= + new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, + new Rational(60, 1), Format.R8G8B8A8_UNorm), + IsWindowed = true, + OutputHandle = form.Handle, + SampleDescription = new SampleDescription(1, 0), + SwapEffect = SwapEffect.Discard, + Usage = Usage.RenderTargetOutput + }; + + // Create Device and SwapChain + Device device; + SwapChain swapChain; + Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain); + var context = device; + + // Ignore all windows events + var factory = swapChain.GetParent(); + factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll); + + // New RenderTargetView from the backbuffer + var backBuffer = Texture2D.FromSwapChain(swapChain, 0); + var renderView = new RenderTargetView(device, backBuffer); + + // Compile Vertex and Pixel shaders + var vertexShaderByteCode = ShaderBytecode.CompileFromFile("MiniCube.fx", "VS", "vs_4_0"); + var vertexShader = new VertexShader(device, vertexShaderByteCode); + + var pixelShaderByteCode = ShaderBytecode.CompileFromFile("MiniCube.fx", "PS", "ps_4_0"); + var pixelShader = new PixelShader(device, pixelShaderByteCode); + + // Layout from VertexShader input signature + var layout = new InputLayout(device, ShaderSignature.GetInputSignature(vertexShaderByteCode), new[] + { + new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), + new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) + }); + + // Instantiate Vertex buiffer from vertex data + var vertices = Buffer.Create(device, BindFlags.VertexBuffer, new[] + { + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), // Front + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + + new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), // BACK + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), // Top + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + + new Vector4(-1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), // Bottom + new Vector4( 1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), // Left + new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + + new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), // Right + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + }); + + // Create Constant Buffer + var contantBuffer = new Buffer(device, Utilities.SizeOf(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None); + + // Create Depth Buffer & View + var depthBuffer = new Texture2D(device, new Texture2DDescription() + { + Format = Format.D32_Float_S8X24_UInt, + ArraySize = 1, + MipLevels = 1, + Width = form.ClientSize.Width, + Height = form.ClientSize.Height, + SampleDescription = new SampleDescription(1, 0), + Usage = ResourceUsage.Default, + BindFlags = BindFlags.DepthStencil, + CpuAccessFlags = CpuAccessFlags.None, + OptionFlags = ResourceOptionFlags.None + }); + + var depthView = new DepthStencilView(device, depthBuffer); + + // Prepare All the stages + context.InputAssembler.InputLayout = layout; + context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; + context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices, Utilities.SizeOf() * 2, 0)); + context.VertexShader.SetConstantBuffer(0, contantBuffer); + context.VertexShader.Set(vertexShader); + context.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f)); + context.PixelShader.Set(pixelShader); + + // Prepare matrices + var view = Matrix.LookAtLH(new Vector3(0, 0, -5), new Vector3(0, 0, 0), Vector3.UnitY); + var proj = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, form.ClientSize.Width / (float)form.ClientSize.Height, 0.1f, 100.0f); + var viewProj = Matrix.Multiply(view, proj); + + // Use clock + var clock = new Stopwatch(); + clock.Start(); + + // Main loop + RenderLoop.Run(form, () => + { + var time = clock.ElapsedMilliseconds / 1000.0f; + + // Clear views + context.OutputMerger.SetTargets(depthView, renderView); + + context.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0); + context.ClearRenderTargetView(renderView, Color.Black); + + // Update WorldViewProj Matrix + var worldViewProj = Matrix.RotationX(time) * Matrix.RotationY(time * 2) * Matrix.RotationZ(time * .7f) * viewProj; + worldViewProj.Transpose(); + context.UpdateSubresource(ref worldViewProj, contantBuffer); + + // Draw the cube + context.Draw(36, 0); + + // Present! + swapChain.Present(0, PresentFlags.None); + }); + + // Release all resources + vertexShaderByteCode.Dispose(); + vertexShader.Dispose(); + pixelShaderByteCode.Dispose(); + pixelShader.Dispose(); + vertices.Dispose(); + layout.Dispose(); + renderView.Dispose(); + backBuffer.Dispose(); + context.ClearState(); + context.Flush(); + device.Dispose(); + context.Dispose(); + swapChain.Dispose(); + factory.Dispose(); + } + } +} \ No newline at end of file diff --git a/Desktop/Direct3D10/MiniCube/Properties/AssemblyInfo.cs b/Desktop/Direct3D10/MiniCube/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..de42f5a1 --- /dev/null +++ b/Desktop/Direct3D10/MiniCube/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("MiniCube")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("MiniCube")] +[assembly: AssemblyCompany("Alexandre Mutel")] +[assembly: AssemblyCopyright("Copyright © 2010-2011 Alexandre Mutel")] +[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("3e6b3234-906e-4119-a237-9d4634545d63")] + +// 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/Desktop/Direct3D10/MiniCube/app.config b/Desktop/Direct3D10/MiniCube/app.config new file mode 100644 index 00000000..884f9844 --- /dev/null +++ b/Desktop/Direct3D10/MiniCube/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Desktop/Direct3D10/MiniTri/MiniTri.csproj b/Desktop/Direct3D10/MiniTri/MiniTri.csproj new file mode 100644 index 00000000..70628aec --- /dev/null +++ b/Desktop/Direct3D10/MiniTri/MiniTri.csproj @@ -0,0 +1,82 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {F54F5361-F0E1-4D8E-8AB9-56A6EBFF1DBB} + WinExe + Properties + MiniTri + MiniTri + v4.5.1 + + + 512 + 67081415 + ..\..\ + + + true + bin\Debug\ + DEBUG;TRACE + false + full + AnyCPU + prompt + false + + + bin\Release\ + TRACE + true + pdbonly + AnyCPU + prompt + false + + + + ..\..\..\..\Bin\Desktop\SharpDX.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.D3DCompiler.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Desktop.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Direct3D10.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.DXGI.dll + + + ..\..\..\..\Bin\Desktop\SharpDX.Mathematics.dll + + + + + + + + + + + + PreserveNewest + + + + + + + + \ No newline at end of file diff --git a/Desktop/Direct3D10/MiniTri/MiniTri.fx b/Desktop/Direct3D10/MiniTri/MiniTri.fx new file mode 100644 index 00000000..be84e533 --- /dev/null +++ b/Desktop/Direct3D10/MiniTri/MiniTri.fx @@ -0,0 +1,62 @@ +// ----------------------------------------------------------------------------- +// Original code from SlimDX project. +// Greetings to SlimDX Group. Original code published with the following license: +// ----------------------------------------------------------------------------- +/* +* Copyright (c) 2007-2011 SlimDX Group +* +* 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. +*/ + +struct VS_IN +{ + float4 pos : POSITION; + float4 col : COLOR; +}; + +struct PS_IN +{ + float4 pos : SV_POSITION; + float4 col : COLOR; +}; + +PS_IN VS( VS_IN input ) +{ + PS_IN output = (PS_IN)0; + + output.pos = input.pos; + output.col = input.col; + + return output; +} + +float4 PS( PS_IN input ) : SV_Target +{ + return input.col; +} + +technique10 Render +{ + pass P0 + { + SetGeometryShader( 0 ); + SetVertexShader( CompileShader( vs_4_0, VS() ) ); + SetPixelShader( CompileShader( ps_4_0, PS() ) ); + } +} \ No newline at end of file diff --git a/Desktop/Direct3D10/MiniTri/Program.cs b/Desktop/Direct3D10/MiniTri/Program.cs new file mode 100644 index 00000000..2eb91c9e --- /dev/null +++ b/Desktop/Direct3D10/MiniTri/Program.cs @@ -0,0 +1,155 @@ +// 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. +// ----------------------------------------------------------------------------- +// Original code from SlimDX project. +// Greetings to SlimDX Group. Original code published with the following license: +// ----------------------------------------------------------------------------- +/* +* Copyright (c) 2007-2011 SlimDX Group +* +* 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.D3DCompiler; +using SharpDX.Diagnostics; +using SharpDX.Direct3D; +using SharpDX.Direct3D10; +using SharpDX.DXGI; +using SharpDX.Windows; + +using Buffer = SharpDX.Direct3D10.Buffer; +using Device = SharpDX.Direct3D10.Device; +using DriverType = SharpDX.Direct3D10.DriverType; + +namespace MiniTri +{ + /// + /// SharpDX port of SlimDX-MiniTri Direct3D 10 Sample + /// + internal static class Program + { + [STAThread] + private static void Main() + { + var form = new RenderForm("SharpDX - MiniTri Direct3D 10 Sample"); + + Configuration.EnableObjectTracking = true; + + // SwapChain description + var desc = new SwapChainDescription() + { + BufferCount = 1, + ModeDescription = + new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, + new Rational(60, 1), Format.R8G8B8A8_UNorm), + IsWindowed = true, + OutputHandle = form.Handle, + SampleDescription = new SampleDescription(1, 0), + SwapEffect = SwapEffect.Discard, + Usage = Usage.RenderTargetOutput + }; + + // Create Device and SwapChain + Device device; + SwapChain swapChain; + Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain); + + // Ignore all windows events + var factory = swapChain.GetParent(); + factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll); + + // New RenderTargetView from the backbuffer + var backBuffer = Texture2D.FromSwapChain(swapChain, 0); + var renderView = new RenderTargetView(device, backBuffer); + + // Compile Vertex and Pixel shaders + var effectByteCode = ShaderBytecode.CompileFromFile("MiniTri.fx", "fx_4_0", ShaderFlags.None, EffectFlags.None); + var effect = new Effect(device, effectByteCode); + var technique = effect.GetTechniqueByIndex(0); + var pass = technique.GetPassByIndex(0); + + // Layout from VertexShader input signature + var passSignature = pass.Description.Signature; + var layout = new InputLayout(device, passSignature, new[] + { + new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), + new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) + }); + + // Instantiate Vertex buiffer from vertex data + var vertices = Buffer.Create(device, BindFlags.VertexBuffer, new[] + { + new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f) + }); + + // Prepare All the stages + device.InputAssembler.InputLayout = layout; + device.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; + device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices, 32, 0)); + device.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f)); + device.OutputMerger.SetTargets(renderView); + + // Main loop + RenderLoop.Run(form, () => + { + device.ClearRenderTargetView(renderView, Color.Black); + for (int i = 0; i < technique.Description.PassCount; ++i) + { + pass.Apply(); + device.Draw(3, 0); + } + swapChain.Present(0, PresentFlags.None); + }); + + // Release all resources + passSignature.Dispose(); + effect.Dispose(); + effectByteCode.Dispose(); + vertices.Dispose(); + layout.Dispose(); + renderView.Dispose(); + backBuffer.Dispose(); + device.ClearState(); + device.Flush(); + device.Dispose(); + swapChain.Dispose(); + factory.Dispose(); + } + } +} \ No newline at end of file diff --git a/Desktop/Direct3D10/MiniTri/ProgramWithNoEffect.cs b/Desktop/Direct3D10/MiniTri/ProgramWithNoEffect.cs new file mode 100644 index 00000000..51f55ec5 --- /dev/null +++ b/Desktop/Direct3D10/MiniTri/ProgramWithNoEffect.cs @@ -0,0 +1,129 @@ +// 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; +using SharpDX; +using SharpDX.D3DCompiler; +using SharpDX.Direct3D; +using SharpDX.Direct3D10; +using SharpDX.DXGI; +using SharpDX.Windows; + +using Buffer = SharpDX.Direct3D10.Buffer; +using Device = SharpDX.Direct3D10.Device; +using DriverType = SharpDX.Direct3D10.DriverType; + +namespace MiniTri +{ + /// + /// SharpDX port of SlimDX-MiniTri Direct3D 10 Sample + /// + internal static class ProgramWithNoEffect + { + [STAThread] + private static void Main2() + { + var form = new RenderForm("SharpDX - MiniTri Direct3D 10 Sample"); + + // SwapChain description + var desc = new SwapChainDescription() + { + BufferCount = 1, + ModeDescription = + new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, + new Rational(60, 1), Format.R8G8B8A8_UNorm), + IsWindowed = true, + OutputHandle = form.Handle, + SampleDescription = new SampleDescription(1, 0), + SwapEffect = SwapEffect.Discard, + Usage = Usage.RenderTargetOutput + }; + + // Create Device and SwapChain + Device device; + SwapChain swapChain; + Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain); + + + // Ignore all windows events + Factory factory = swapChain.GetParent(); + factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll); + + // New RenderTargetView from the backbuffer + Texture2D backBuffer = Texture2D.FromSwapChain(swapChain, 0); + var renderView = new RenderTargetView(device, backBuffer); + + // Compile Vertex and Pixel shaders + var vertexShaderByteCode = ShaderBytecode.CompileFromFile("MiniTri.fx", "VS", "vs_4_0", ShaderFlags.None, + EffectFlags.None); + var vertexShader = new VertexShader(device, vertexShaderByteCode); + + var pixelShaderByteCode = ShaderBytecode.CompileFromFile("MiniTri.fx", "PS", "ps_4_0", ShaderFlags.None, + EffectFlags.None); + var pixelShader = new PixelShader(device, pixelShaderByteCode); + + // Layout from VertexShader input signature + var layout = new InputLayout(device, ShaderSignature.GetInputSignature(vertexShaderByteCode), new[] { + new InputElement("POSITION",0,Format.R32G32B32A32_Float,0,0), + new InputElement("COLOR",0,Format.R32G32B32A32_Float,16,0) + }); + + // Instantiate Vertex buiffer from vertex data + var vertices = Buffer.Create(device, BindFlags.VertexBuffer, new[] + { + new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f) + }); + + // Prepare All the stages + device.InputAssembler.InputLayout = layout; + device.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; + device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices, 32, 0)); + device.VertexShader.Set(vertexShader); + device.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f)); + device.PixelShader.Set(pixelShader); + device.OutputMerger.SetTargets(renderView); + + // Main loop + RenderLoop.Run(form, () => + { + device.ClearRenderTargetView(renderView, Color.Black); + device.Draw(3, 0); + swapChain.Present(0, PresentFlags.None); + }); + + // Release all resources + vertexShaderByteCode.Dispose(); + vertexShader.Dispose(); + pixelShaderByteCode.Dispose(); + pixelShader.Dispose(); + vertices.Dispose(); + layout.Dispose(); + renderView.Dispose(); + backBuffer.Dispose(); + device.ClearState(); + device.Flush(); + device.Dispose(); + device.Dispose(); + swapChain.Dispose(); + factory.Dispose(); + } + } +} \ No newline at end of file diff --git a/Desktop/Direct3D10/MiniTri/Properties/AssemblyInfo.cs b/Desktop/Direct3D10/MiniTri/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..0e11d20f --- /dev/null +++ b/Desktop/Direct3D10/MiniTri/Properties/AssemblyInfo.cs @@ -0,0 +1,56 @@ +// 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; +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("MiniTri")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("MiniTri")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: Obfuscation(Feature = "string encryption", Exclude = true)] + +// 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("3e6b3234-906e-4119-a237-9d4634545d63")] + +// 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/Desktop/Direct3D10/MiniTri/app.config b/Desktop/Direct3D10/MiniTri/app.config new file mode 100644 index 00000000..884f9844 --- /dev/null +++ b/Desktop/Direct3D10/MiniTri/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Desktop/Direct3D10/MiniTri/screenshot.png b/Desktop/Direct3D10/MiniTri/screenshot.png new file mode 100644 index 00000000..066fdd2d Binary files /dev/null and b/Desktop/Direct3D10/MiniTri/screenshot.png differ diff --git a/Desktop/Direct3D10/MiniTri/screenshot_small.png b/Desktop/Direct3D10/MiniTri/screenshot_small.png new file mode 100644 index 00000000..8bb5c4c9 Binary files /dev/null and b/Desktop/Direct3D10/MiniTri/screenshot_small.png differ diff --git a/Desktop/Direct3D10/WPFHost/App.xaml b/Desktop/Direct3D10/WPFHost/App.xaml new file mode 100644 index 00000000..2f9661f5 --- /dev/null +++ b/Desktop/Direct3D10/WPFHost/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Desktop/Direct3D10/WPFHost/App.xaml.cs b/Desktop/Direct3D10/WPFHost/App.xaml.cs new file mode 100644 index 00000000..b41bdba2 --- /dev/null +++ b/Desktop/Direct3D10/WPFHost/App.xaml.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Windows; + +namespace WPFHost +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Desktop/Direct3D10/WPFHost/DPFCanvas.cs b/Desktop/Direct3D10/WPFHost/DPFCanvas.cs new file mode 100644 index 00000000..82118aa8 --- /dev/null +++ b/Desktop/Direct3D10/WPFHost/DPFCanvas.cs @@ -0,0 +1,266 @@ +// 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. +namespace WPFHost +{ + using System; + using System.ComponentModel; + using System.Diagnostics; + using System.Windows; + using System.Windows.Controls; + using System.Windows.Media; + using SharpDX; + using SharpDX.Direct3D10; + using SharpDX.DXGI; + using Device = SharpDX.Direct3D10.Device1; + + public partial class DPFCanvas : Image, ISceneHost + { + private Device Device; + private Texture2D RenderTarget; + private Texture2D DepthStencil; + private RenderTargetView RenderTargetView; + private DepthStencilView DepthStencilView; + private DX10ImageSource D3DSurface; + private Stopwatch RenderTimer; + private IScene RenderScene; + private bool SceneAttached; + + public Color4 ClearColor = SharpDX.Color.Black; + + public DPFCanvas() + { + this.RenderTimer = new Stopwatch(); + this.Loaded += this.Window_Loaded; + this.Unloaded += this.Window_Closing; + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + if (DPFCanvas.IsInDesignMode) + return; + + this.StartD3D(); + this.StartRendering(); + } + + private void Window_Closing(object sender, RoutedEventArgs e) + { + if (DPFCanvas.IsInDesignMode) + return; + + this.StopRendering(); + this.EndD3D(); + } + + private void StartD3D() + { + this.Device = new Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0); + + this.D3DSurface = new DX10ImageSource(); + this.D3DSurface.IsFrontBufferAvailableChanged += OnIsFrontBufferAvailableChanged; + + this.CreateAndBindTargets(); + + this.Source = this.D3DSurface; + } + + private void EndD3D() + { + if (this.RenderScene != null) + { + this.RenderScene.Detach(); + this.SceneAttached = false; + } + + this.D3DSurface.IsFrontBufferAvailableChanged -= OnIsFrontBufferAvailableChanged; + this.Source = null; + + Disposer.RemoveAndDispose(ref this.D3DSurface); + Disposer.RemoveAndDispose(ref this.RenderTargetView); + Disposer.RemoveAndDispose(ref this.DepthStencilView); + Disposer.RemoveAndDispose(ref this.RenderTarget); + Disposer.RemoveAndDispose(ref this.DepthStencil); + Disposer.RemoveAndDispose(ref this.Device); + } + + private void CreateAndBindTargets() + { + this.D3DSurface.SetRenderTargetDX10(null); + + Disposer.RemoveAndDispose(ref this.RenderTargetView); + Disposer.RemoveAndDispose(ref this.DepthStencilView); + Disposer.RemoveAndDispose(ref this.RenderTarget); + Disposer.RemoveAndDispose(ref this.DepthStencil); + + int width = Math.Max((int)base.ActualWidth, 100); + int height = Math.Max((int)base.ActualHeight, 100); + + Texture2DDescription colordesc = new Texture2DDescription + { + BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, + Format = Format.B8G8R8A8_UNorm, + Width = width, + Height = height, + MipLevels = 1, + SampleDescription = new SampleDescription(1, 0), + Usage = ResourceUsage.Default, + OptionFlags = ResourceOptionFlags.Shared, + CpuAccessFlags = CpuAccessFlags.None, + ArraySize = 1 + }; + + Texture2DDescription depthdesc = new Texture2DDescription + { + BindFlags = BindFlags.DepthStencil, + Format = Format.D32_Float_S8X24_UInt, + Width = width, + Height = height, + MipLevels = 1, + SampleDescription = new SampleDescription(1, 0), + Usage = ResourceUsage.Default, + OptionFlags = ResourceOptionFlags.None, + CpuAccessFlags = CpuAccessFlags.None, + ArraySize = 1, + }; + + this.RenderTarget = new Texture2D(this.Device, colordesc); + this.DepthStencil = new Texture2D(this.Device, depthdesc); + this.RenderTargetView = new RenderTargetView(this.Device, this.RenderTarget); + this.DepthStencilView = new DepthStencilView(this.Device, this.DepthStencil); + + this.D3DSurface.SetRenderTargetDX10(this.RenderTarget); + } + + private void StartRendering() + { + if (this.RenderTimer.IsRunning) + return; + + CompositionTarget.Rendering += OnRendering; + this.RenderTimer.Start(); + } + + private void StopRendering() + { + if (!this.RenderTimer.IsRunning) + return; + + CompositionTarget.Rendering -= OnRendering; + this.RenderTimer.Stop(); + } + + private void OnRendering(object sender, EventArgs e) + { + if (!this.RenderTimer.IsRunning) + return; + + this.Render(this.RenderTimer.Elapsed); + this.D3DSurface.InvalidateD3DImage(); + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + this.CreateAndBindTargets(); + base.OnRenderSizeChanged(sizeInfo); + } + + void Render(TimeSpan sceneTime) + { + SharpDX.Direct3D10.Device device = this.Device; + if (device == null) + return; + + Texture2D renderTarget = this.RenderTarget; + if (renderTarget == null) + return; + + int targetWidth = renderTarget.Description.Width; + int targetHeight = renderTarget.Description.Height; + + device.OutputMerger.SetTargets(this.DepthStencilView, this.RenderTargetView); + device.Rasterizer.SetViewports(new Viewport(0, 0, targetWidth, targetHeight, 0.0f, 1.0f)); + + device.ClearRenderTargetView(this.RenderTargetView, this.ClearColor); + device.ClearDepthStencilView(this.DepthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); + + if (this.Scene != null) + { + if (!this.SceneAttached) + { + this.SceneAttached = true; + this.RenderScene.Attach(this); + } + + this.Scene.Update(this.RenderTimer.Elapsed); + this.Scene.Render(); + } + + device.Flush(); + } + + private void OnIsFrontBufferAvailableChanged(object sender, DependencyPropertyChangedEventArgs e) + { + // this fires when the screensaver kicks in, the machine goes into sleep or hibernate + // and any other catastrophic losses of the d3d device from WPF's point of view + if(this.D3DSurface.IsFrontBufferAvailable) + { + CreateAndBindTargets(); + this.StartRendering(); + } + else + this.StopRendering(); + } + + /// + /// Gets a value indicating whether the control is in design mode + /// (running in Blend or Visual Studio). + /// + public static bool IsInDesignMode + { + get + { + DependencyProperty prop = DesignerProperties.IsInDesignModeProperty; + bool isDesignMode = (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + return isDesignMode; + } + } + + public IScene Scene + { + get { return this.RenderScene; } + set + { + if (ReferenceEquals(this.RenderScene, value)) + return; + + if (this.RenderScene != null) + this.RenderScene.Detach(); + + this.SceneAttached = false; + this.RenderScene = value; + } + } + + SharpDX.Direct3D10.Device ISceneHost.Device + { + get { return this.Device; } + } + } +} diff --git a/Desktop/Direct3D10/WPFHost/DX10ImageSource.cs b/Desktop/Direct3D10/WPFHost/DX10ImageSource.cs new file mode 100644 index 00000000..a9867507 --- /dev/null +++ b/Desktop/Direct3D10/WPFHost/DX10ImageSource.cs @@ -0,0 +1,178 @@ +// 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. +// ----------------------------------------------------------------------------- +// Original code from SlimMath project. http://code.google.com/p/slimmath/ +// Greetings to SlimDX Group. Original code published with the following license: +// ----------------------------------------------------------------------------- +/* +* Copyright (c) 2007-2011 SlimDX Group +* +* 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. +*/ +namespace WPFHost +{ + using System; + using System.Runtime.InteropServices; + using System.Windows; + using System.Windows.Interop; + using SharpDX.Direct3D9; + + class DX10ImageSource : D3DImage, IDisposable + { + [DllImport("user32.dll", SetLastError = false)] + private static extern IntPtr GetDesktopWindow(); + private static int ActiveClients; + private static Direct3DEx D3DContext; + private static DeviceEx D3DDevice; + private Texture RenderTarget; + + public DX10ImageSource() + { + this.StartD3D(); + DX10ImageSource.ActiveClients++; + } + + public void Dispose() + { + this.SetRenderTargetDX10(null); + Disposer.RemoveAndDispose(ref this.RenderTarget); + + DX10ImageSource.ActiveClients--; + this.EndD3D(); + } + + public void InvalidateD3DImage() + { + if (this.RenderTarget != null) + { + base.Lock(); + base.AddDirtyRect(new Int32Rect(0, 0, base.PixelWidth, base.PixelHeight)); + base.Unlock(); + } + } + + public void SetRenderTargetDX10(SharpDX.Direct3D10.Texture2D renderTarget) + { + if (this.RenderTarget != null) + { + this.RenderTarget = null; + + base.Lock(); + base.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero); + base.Unlock(); + } + + if (renderTarget == null) + return; + + if (!IsShareable(renderTarget)) + throw new ArgumentException("Texture must be created with ResourceOptionFlags.Shared"); + + Format format = DX10ImageSource.TranslateFormat(renderTarget); + if (format == Format.Unknown) + throw new ArgumentException("Texture format is not compatible with OpenSharedResource"); + + IntPtr handle = GetSharedHandle(renderTarget); + if (handle == IntPtr.Zero) + throw new ArgumentNullException("Handle"); + + this.RenderTarget = new Texture(DX10ImageSource.D3DDevice, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, format, Pool.Default, ref handle); + using (Surface surface = this.RenderTarget.GetSurfaceLevel(0)) + { + base.Lock(); + base.SetBackBuffer(D3DResourceType.IDirect3DSurface9, surface.NativePointer); + base.Unlock(); + } + } + + private void StartD3D() + { + if (DX10ImageSource.ActiveClients != 0) + return; + + D3DContext = new Direct3DEx(); + + PresentParameters presentparams = new PresentParameters(); + presentparams.Windowed = true; + presentparams.SwapEffect = SwapEffect.Discard; + presentparams.DeviceWindowHandle = GetDesktopWindow(); + presentparams.PresentationInterval = PresentInterval.Default; + + DX10ImageSource.D3DDevice = new DeviceEx(D3DContext, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve, presentparams); + } + + private void EndD3D() + { + if (DX10ImageSource.ActiveClients != 0) + return; + + Disposer.RemoveAndDispose(ref this.RenderTarget); + Disposer.RemoveAndDispose(ref DX10ImageSource.D3DDevice); + Disposer.RemoveAndDispose(ref DX10ImageSource.D3DContext); + } + + private IntPtr GetSharedHandle(SharpDX.Direct3D10.Texture2D Texture) + { + SharpDX.DXGI.Resource resource = Texture.QueryInterface(); + IntPtr result = resource.SharedHandle; + resource.Dispose(); + return result; + } + + private static Format TranslateFormat(SharpDX.Direct3D10.Texture2D Texture) + { + switch (Texture.Description.Format) + { + case SharpDX.DXGI.Format.R10G10B10A2_UNorm: + return SharpDX.Direct3D9.Format.A2B10G10R10; + + case SharpDX.DXGI.Format.R16G16B16A16_Float: + return SharpDX.Direct3D9.Format.A16B16G16R16F; + + case SharpDX.DXGI.Format.B8G8R8A8_UNorm: + return SharpDX.Direct3D9.Format.A8R8G8B8; + + default: + return SharpDX.Direct3D9.Format.Unknown; + } + } + + private static bool IsShareable(SharpDX.Direct3D10.Texture2D Texture) + { + return (Texture.Description.OptionFlags & SharpDX.Direct3D10.ResourceOptionFlags.Shared) != 0; + } + } +} diff --git a/Desktop/Direct3D10/WPFHost/Disposer.cs b/Desktop/Direct3D10/WPFHost/Disposer.cs new file mode 100644 index 00000000..1f8d5337 --- /dev/null +++ b/Desktop/Direct3D10/WPFHost/Disposer.cs @@ -0,0 +1,52 @@ +// 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; + +namespace WPFHost +{ + public static class Disposer + { + /// + /// Dispose an object instance and set the reference to null + /// + /// The type of object to dispose + /// A reference to the instance for disposal + /// This method hides any thrown exceptions that might occur during disposal of the object (by design) + public static void RemoveAndDispose(ref TypeName resource) where TypeName : class + { + if (resource == null) + return; + + IDisposable disposer = resource as IDisposable; + if (disposer != null) + { + try + { + disposer.Dispose(); + } + catch + { + } + } + + resource = null; + } + } +} diff --git a/Desktop/Direct3D10/WPFHost/IScene.cs b/Desktop/Direct3D10/WPFHost/IScene.cs new file mode 100644 index 00000000..c7c6d273 --- /dev/null +++ b/Desktop/Direct3D10/WPFHost/IScene.cs @@ -0,0 +1,37 @@ +// 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. +namespace WPFHost +{ + using System; + using SharpDX.Direct3D10; + + public interface ISceneHost + { + Device Device { get; } + } + + public interface IScene + { + void Attach(ISceneHost host); + void Detach(); + void Update(TimeSpan timeSpan); + void Render(); + } +} diff --git a/Desktop/Direct3D10/WPFHost/MainWindow.xaml b/Desktop/Direct3D10/WPFHost/MainWindow.xaml new file mode 100644 index 00000000..f5154428 --- /dev/null +++ b/Desktop/Direct3D10/WPFHost/MainWindow.xaml @@ -0,0 +1,11 @@ + + + +