diff --git a/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs index ed1046b4..7ab25e9d 100644 --- a/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs +++ b/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs @@ -251,35 +251,32 @@ namespace ANX.Framework.Windows.DX10 } } - public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset) - { - if (vertexBuffer == null) - { - throw new ArgumentNullException("vertexBuffer"); - } - - this.currentVertexBuffer = vertexBuffer; - - VertexBuffer_DX10 nativeVertexBuffer = vertexBuffer.NativeVertexBuffer as VertexBuffer_DX10; - - if (nativeVertexBuffer != null) - { - device.InputAssembler.SetVertexBuffers(0, new SharpDX.Direct3D10.VertexBufferBinding(nativeVertexBuffer.NativeBuffer, vertexBuffer.VertexDeclaration.VertexStride, vertexOffset)); - } - else - { - throw new Exception("couldn't fetch native DirectX10 VertexBuffer"); - } - } - - public void SetVertexBuffer(VertexBuffer vertexBuffer) - { - SetVertexBuffer(vertexBuffer, 0); - } - public void SetVertexBuffers(Graphics.VertexBufferBinding[] vertexBuffers) { - throw new NotImplementedException(); + if (vertexBuffers == null) + { + throw new ArgumentNullException("vertexBuffers"); + } + + this.currentVertexBuffer = vertexBuffers[0].VertexBuffer; //TODO: hmmmmm, not nice :-) + + SharpDX.Direct3D10.VertexBufferBinding[] nativeVertexBufferBindings = new SharpDX.Direct3D10.VertexBufferBinding[vertexBuffers.Length]; + for (int i = 0; i < vertexBuffers.Length; i++) + { + ANX.Framework.Graphics.VertexBufferBinding anxVertexBufferBinding = vertexBuffers[i]; + VertexBuffer_DX10 nativeVertexBuffer = anxVertexBufferBinding.VertexBuffer.NativeVertexBuffer as VertexBuffer_DX10; + + if (nativeVertexBuffer != null) + { + nativeVertexBufferBindings[i] = new SharpDX.Direct3D10.VertexBufferBinding(nativeVertexBuffer.NativeBuffer, anxVertexBufferBinding.VertexBuffer.VertexDeclaration.VertexStride, anxVertexBufferBinding.VertexOffset); + } + else + { + throw new Exception("couldn't fetch native DirectX10 VertexBuffer"); + } + } + + device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); } public void SetViewport(Graphics.Viewport viewport) @@ -331,5 +328,21 @@ 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.DX10/Properties/AssemblyInfo.cs b/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs index d4dfaa42..e62d79c4 100644 --- a/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs +++ b/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.7.0.0")] -[assembly: AssemblyFileVersion("0.7.0.0")] +[assembly: AssemblyVersion("0.7.1.0")] +[assembly: AssemblyFileVersion("0.7.1.0")] diff --git a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs index da9d713f..3e3e2a66 100644 --- a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs +++ b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs @@ -168,16 +168,6 @@ namespace ANX.Framework.Windows.GL3 throw new NotImplementedException(); } - public void SetVertexBuffer(VertexBuffer vertexBuffer) - { - throw new NotImplementedException(); - } - - public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset) - { - throw new NotImplementedException(); - } - public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers) { throw new NotImplementedException(); @@ -227,5 +217,21 @@ namespace ANX.Framework.Windows.GL3 nativeContext.SwapBuffers(); } #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.Windows.GL3/Properties/AssemblyInfo.cs b/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs index 59ba575b..7650a9ca 100644 --- a/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs +++ b/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.5.0.0")] -[assembly: AssemblyFileVersion("0.5.0.0")] +[assembly: AssemblyVersion("0.5.1.0")] +[assembly: AssemblyFileVersion("0.5.1.0")] diff --git a/ANX.Framework/Graphics/GraphicsDevice.cs b/ANX.Framework/Graphics/GraphicsDevice.cs index ae28eae9..01f10bb8 100644 --- a/ANX.Framework/Graphics/GraphicsDevice.cs +++ b/ANX.Framework/Graphics/GraphicsDevice.cs @@ -71,6 +71,7 @@ namespace ANX.Framework.Graphics private PresentationParameters currentPresentationParameters; private bool isDisposed; private GraphicsProfile graphicsProfile; + private VertexBufferBinding[] currentVertexBufferBindings; #endregion // Private Members @@ -174,32 +175,37 @@ namespace ANX.Framework.Graphics public void SetVertexBuffer(VertexBuffer vertexBuffer) { - nativeDevice.SetVertexBuffer(vertexBuffer); + VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer) }; + this.currentVertexBufferBindings = bindings; + this.nativeDevice.SetVertexBuffers(bindings); } public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset) { - nativeDevice.SetVertexBuffer(vertexBuffer, vertexOffset); + VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer, vertexOffset) }; + this.currentVertexBufferBindings = bindings; + this.nativeDevice.SetVertexBuffers(bindings); } public void SetVertexBuffers(Graphics.VertexBufferBinding[] vertexBuffers) { + this.currentVertexBufferBindings = vertexBuffers; nativeDevice.SetVertexBuffers(vertexBuffers); } public void SetRenderTarget(RenderTarget2D renderTarget) { - throw new NotImplementedException(); + nativeDevice.SetRenderTarget(renderTarget); } public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace) { - throw new NotImplementedException(); + nativeDevice.SetRenderTarget(renderTarget, cubeMapFace); } public void SetRenderTargets(params RenderTargetBinding[] renderTargets) { - throw new NotImplementedException(); + nativeDevice.SetRenderTargets(renderTargets); } public void GetBackBufferData(Nullable rect, T[] data, int startIndex, int elementCount) where T : struct @@ -219,7 +225,7 @@ namespace ANX.Framework.Graphics public VertexBufferBinding[] GetVertexBuffers() { - throw new NotImplementedException(); + return this.currentVertexBufferBindings; } public RenderTargetBinding[] GetRenderTargets() diff --git a/ANX.Framework/Graphics/VertexBufferBinding.cs b/ANX.Framework/Graphics/VertexBufferBinding.cs index 6d4837a2..b8a425b5 100644 --- a/ANX.Framework/Graphics/VertexBufferBinding.cs +++ b/ANX.Framework/Graphics/VertexBufferBinding.cs @@ -54,6 +54,60 @@ namespace ANX.Framework.Graphics { public struct VertexBufferBinding { + #region Private Members + private VertexBuffer vertexBuffer; + private int instanceFrequency; + private int vertexOffset; + #endregion // Private Members + public VertexBufferBinding(VertexBuffer vertexBuffer) + { + this.vertexBuffer = vertexBuffer; + this.vertexOffset = 0; + this.instanceFrequency = 0; + } + + public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset) + { + this.vertexBuffer = vertexBuffer; + this.vertexOffset = vertexOffset; + this.instanceFrequency = 0; + } + + public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset, int instanceFrequency) + { + this.vertexBuffer = vertexBuffer; + this.vertexOffset = vertexOffset; + this.instanceFrequency = instanceFrequency; + } + + public static implicit operator VertexBufferBinding(VertexBuffer vertexBuffer) + { + return new VertexBufferBinding(vertexBuffer); + } + + public VertexBuffer VertexBuffer + { + get + { + return this.vertexBuffer; + } + } + + public int InstanceFrequency + { + get + { + return this.instanceFrequency; + } + } + + public int VertexOffset + { + get + { + return this.vertexOffset; + } + } } } diff --git a/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs b/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs index a3ca2249..d4728d52 100644 --- a/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs +++ b/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs @@ -63,14 +63,20 @@ namespace ANX.Framework.NonXNA void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount); - void SetVertexBuffer(VertexBuffer vertexBuffer); + //void SetVertexBuffer(VertexBuffer vertexBuffer); - void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset); + //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 63783d43..ce4d74ec 100644 --- a/ANX.RenderSystem.Windows.DX11.1/GraphicsDeviceWindowsDX11_1.cs +++ b/ANX.RenderSystem.Windows.DX11.1/GraphicsDeviceWindowsDX11_1.cs @@ -245,34 +245,6 @@ namespace ANX.RenderSystem.Windows.DX11_1 //} } - public void SetVertexBuffer(VertexBuffer vertexBuffer) - { - if (vertexBuffer == null) - { - throw new ArgumentNullException("vertexBuffer"); - } - - throw new NotImplementedException(); - - //this.currentVertexBuffer = vertexBuffer; - - //VertexBuffer_DX10 nativeVertexBuffer = vertexBuffer.NativeVertexBuffer as VertexBuffer_DX10; - - //if (nativeVertexBuffer != null) - //{ - // device.InputAssembler.SetVertexBuffers(0, new SharpDX.Direct3D10.VertexBufferBinding(nativeVertexBuffer.NativeBuffer, vertexBuffer.VertexDeclaration.VertexStride, 0)); - //} - //else - //{ - // throw new Exception("couldn't fetch native DirectX10 VertexBuffer"); - //} - } - - public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset) - { - throw new NotImplementedException(); - } - public void SetVertexBuffers(ANX.Framework.Graphics.VertexBufferBinding[] vertexBuffers) { throw new NotImplementedException(); @@ -617,5 +589,21 @@ 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(); + } } } diff --git a/ANX.RenderSystem.Windows.DX11.1/Properties/AssemblyInfo.cs b/ANX.RenderSystem.Windows.DX11.1/Properties/AssemblyInfo.cs index b1cfeef6..91a5d86a 100644 --- a/ANX.RenderSystem.Windows.DX11.1/Properties/AssemblyInfo.cs +++ b/ANX.RenderSystem.Windows.DX11.1/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Buildnummer // Revision // -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")]