From 705edf47e18f39b0561b03287c987eaf2f73cc51 Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Thu, 10 Nov 2011 15:22:44 +0000 Subject: [PATCH] finished clear functions in GraphicsDeviceWindowsDX10 --- .../GraphicsDeviceWindowsDX10.cs | 50 ++++++++++++++++--- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs index 4a0676ae..181e09f1 100644 --- a/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs +++ b/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs @@ -99,6 +99,7 @@ namespace ANX.Framework.Windows.DX10 private Device device; private SwapChain swapChain; private RenderTargetView renderView; + private DepthStencilView depthStencilView; private SharpDX.Direct3D10.Texture2D backBuffer; internal Effect_DX10 currentEffect; private VertexBuffer currentVertexBuffer; @@ -154,8 +155,49 @@ namespace ANX.Framework.Windows.DX10 clearColor.Blue = color.B * ColorMultiplier; clearColor.Alpha = color.A * ColorMultiplier; } - device.ClearRenderTargetView(renderView, clearColor); + + this.device.ClearRenderTargetView(this.renderView, this.clearColor); } + + public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) + { + if ((options & ClearOptions.Target) == ClearOptions.Target) + { + // Clear a RenderTarget (or BackBuffer) + + this.clearColor.Red = color.X; + this.clearColor.Green = color.Y; + this.clearColor.Blue = color.Z; + this.clearColor.Alpha = color.W; + + this.device.ClearRenderTargetView(this.renderView, this.clearColor); + } + + if (this.depthStencilView != null) + { + if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options) + { + // Clear the stencil buffer + device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, depth, (byte)stencil); + } + else if ((options | ClearOptions.Stencil) == options) + { + device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Stencil, depth, (byte)stencil); + } + else + { + device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth, depth, (byte)stencil); + } + } + + if ((options & ClearOptions.Target) == ClearOptions.Target) + { + // Clear a RenderTarget + + throw new NotImplementedException(); + } + } + #endregion public void Present() @@ -377,12 +419,6 @@ namespace ANX.Framework.Windows.DX10 throw new NotImplementedException(); } - - public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) - { - throw new NotImplementedException(); - } - public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount) { throw new NotImplementedException();