From 72c4ddff1ce27afdc1d1f35c340e3b2460b69593 Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Mon, 7 Nov 2011 13:18:30 +0000 Subject: [PATCH] finished handling of RenderTarget in GraphicsDevice (anx side only) --- .../GraphicsDeviceWindowsDX10.cs | 11 ------ .../GraphicsDeviceWindowsGL3.cs | 10 ------ ANX.Framework/Graphics/GraphicsDevice.cs | 12 +++++-- ANX.Framework/Graphics/RenderTargetBinding.cs | 36 +++++++++++++++++++ .../RenderSystem/INativeGraphicsDevice.cs | 8 ----- .../GraphicsDeviceWindowsDX11_1.cs | 12 ------- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs index 7ab25e9d..26f155bc 100644 --- a/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs +++ b/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs @@ -329,17 +329,6 @@ namespace ANX.Framework.Windows.DX10 return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0); } - - public void SetRenderTarget(RenderTarget2D renderTarget) - { - throw new NotImplementedException(); - } - - public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace) - { - throw new NotImplementedException(); - } - public void SetRenderTargets(params RenderTargetBinding[] renderTargets) { throw new NotImplementedException(); diff --git a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs index 3e3e2a66..472caecb 100644 --- a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs +++ b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs @@ -219,16 +219,6 @@ namespace ANX.Framework.Windows.GL3 #endregion - public void SetRenderTarget(RenderTarget2D renderTarget) - { - throw new NotImplementedException(); - } - - public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace) - { - throw new NotImplementedException(); - } - public void SetRenderTargets(params RenderTargetBinding[] renderTargets) { throw new NotImplementedException(); diff --git a/ANX.Framework/Graphics/GraphicsDevice.cs b/ANX.Framework/Graphics/GraphicsDevice.cs index 01f10bb8..4980ba0f 100644 --- a/ANX.Framework/Graphics/GraphicsDevice.cs +++ b/ANX.Framework/Graphics/GraphicsDevice.cs @@ -72,6 +72,7 @@ namespace ANX.Framework.Graphics private bool isDisposed; private GraphicsProfile graphicsProfile; private VertexBufferBinding[] currentVertexBufferBindings; + private RenderTargetBinding[] currentRenderTargetBindings; #endregion // Private Members @@ -195,16 +196,21 @@ namespace ANX.Framework.Graphics public void SetRenderTarget(RenderTarget2D renderTarget) { - nativeDevice.SetRenderTarget(renderTarget); + RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget) }; + this.currentRenderTargetBindings = renderTargetBindings; + nativeDevice.SetRenderTargets(renderTargetBindings); } public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace) { - nativeDevice.SetRenderTarget(renderTarget, cubeMapFace); + RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget, cubeMapFace) }; + this.currentRenderTargetBindings = renderTargetBindings; + nativeDevice.SetRenderTargets(renderTargetBindings); } public void SetRenderTargets(params RenderTargetBinding[] renderTargets) { + this.currentRenderTargetBindings = renderTargets; nativeDevice.SetRenderTargets(renderTargets); } @@ -230,7 +236,7 @@ namespace ANX.Framework.Graphics public RenderTargetBinding[] GetRenderTargets() { - throw new NotImplementedException(); + return this.currentRenderTargetBindings; } public void Reset() diff --git a/ANX.Framework/Graphics/RenderTargetBinding.cs b/ANX.Framework/Graphics/RenderTargetBinding.cs index 0ac1f0e1..6f5c3301 100644 --- a/ANX.Framework/Graphics/RenderTargetBinding.cs +++ b/ANX.Framework/Graphics/RenderTargetBinding.cs @@ -54,6 +54,42 @@ namespace ANX.Framework.Graphics { public struct RenderTargetBinding { + #region Private Members + private Texture renderTarget; + private CubeMapFace cubeMapFace; + #endregion // Private Members + public RenderTargetBinding(RenderTarget2D renderTarget) + { + this.renderTarget = renderTarget; + this.cubeMapFace = Graphics.CubeMapFace.PositiveX; + } + + public RenderTargetBinding(RenderTargetCube renderTargetCube, CubeMapFace face) + { + this.renderTarget = renderTargetCube; + this.cubeMapFace = face; + } + + public static implicit operator RenderTargetBinding(RenderTarget2D renderTarget) + { + return new RenderTargetBinding(renderTarget); + } + + public Texture RenderTarget + { + get + { + return this.renderTarget; + } + } + + public CubeMapFace CubeMapFace + { + get + { + return this.cubeMapFace; + } + } } } diff --git a/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs b/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs index d4728d52..0a908245 100644 --- a/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs +++ b/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs @@ -63,20 +63,12 @@ namespace ANX.Framework.NonXNA void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount); - //void SetVertexBuffer(VertexBuffer vertexBuffer); - - //void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset); - void SetVertexBuffers(VertexBufferBinding[] vertexBuffers); void SetIndexBuffer(IndexBuffer indexBuffer); void SetViewport(Viewport viewport); - void SetRenderTarget(RenderTarget2D renderTarget); - - void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace); - void SetRenderTargets(params RenderTargetBinding[] renderTargets); } } diff --git a/ANX.RenderSystem.Windows.DX11.1/GraphicsDeviceWindowsDX11_1.cs b/ANX.RenderSystem.Windows.DX11.1/GraphicsDeviceWindowsDX11_1.cs index ce4d74ec..682ba9f2 100644 --- a/ANX.RenderSystem.Windows.DX11.1/GraphicsDeviceWindowsDX11_1.cs +++ b/ANX.RenderSystem.Windows.DX11.1/GraphicsDeviceWindowsDX11_1.cs @@ -589,18 +589,6 @@ namespace ANX.RenderSystem.Windows.DX11_1 return Comparison.Always; } - - - public void SetRenderTarget(Framework.Graphics.RenderTarget2D renderTarget) - { - throw new NotImplementedException(); - } - - public void SetRenderTarget(Framework.Graphics.RenderTargetCube renderTarget, Framework.Graphics.CubeMapFace cubeMapFace) - { - throw new NotImplementedException(); - } - public void SetRenderTargets(params Framework.Graphics.RenderTargetBinding[] renderTargets) { throw new NotImplementedException();