diff --git a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs index 9bb4f0ce..cd3942cc 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs @@ -334,7 +334,15 @@ namespace ANX.Framework.Windows.DX10 #region DrawUserPrimitives public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType { - throw new NotImplementedException(); + int vertexCount = vertexData.Length; + VertexBuffer_DX10 vb10 = new VertexBuffer_DX10(this.device, vertexDeclaration, vertexCount, BufferUsage.None); + vb10.SetData(null, vertexData); + + SharpDX.Direct3D10.VertexBufferBinding nativeVertexBufferBindings = new SharpDX.Direct3D10.VertexBufferBinding(vb10.NativeBuffer, vertexDeclaration.VertexStride, 0); + + device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + + DrawPrimitives(primitiveType, vertexOffset, primitiveCount); } #endregion // DrawUserPrimitives diff --git a/RenderSystems/ANX.Framework.Windows.DX10/VertexBuffer_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/VertexBuffer_DX10.cs index 630df546..f53c6025 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/VertexBuffer_DX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/VertexBuffer_DX10.cs @@ -65,13 +65,23 @@ namespace ANX.Framework.Windows.DX10 int vertexStride; public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; + SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; + + InitializeBuffer(device, vertexDeclaration, vertexCount, usage); + } + + internal VertexBuffer_DX10(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + InitializeBuffer(device, vertexDeclaration, vertexCount, usage); + } + + private void InitializeBuffer(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) { this.vertexStride = vertexDeclaration.VertexStride; //TODO: translate and use usage - - GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; - SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; if (device != null) { diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs index a2acf150..b0a4a3cd 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs @@ -338,7 +338,15 @@ namespace ANX.RenderSystem.Windows.DX11 #region DrawUserPrimitives public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType { - throw new NotImplementedException(); + int vertexCount = vertexData.Length; + VertexBuffer_DX11 vb11 = new VertexBuffer_DX11(this.deviceContext.Device, vertexDeclaration, vertexCount, BufferUsage.None); + vb11.SetData(null, vertexData); + + SharpDX.Direct3D11.VertexBufferBinding nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding(vb11.NativeBuffer, vertexDeclaration.VertexStride, 0); + + deviceContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + + DrawPrimitives(primitiveType, vertexOffset, primitiveCount); } #endregion // DrawUserPrimitives diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/VertexBuffer_DX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/VertexBuffer_DX11.cs index 2229a8ba..25ebb758 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/VertexBuffer_DX11.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/VertexBuffer_DX11.cs @@ -65,15 +65,25 @@ namespace ANX.RenderSystem.Windows.DX11 int vertexStride; public VertexBuffer_DX11(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11; + SharpDX.Direct3D11.DeviceContext context = gd11 != null ? gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext : null; + + InitializeBuffer(context.Device, vertexDeclaration, vertexCount, usage); + } + + internal VertexBuffer_DX11(SharpDX.Direct3D11.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + InitializeBuffer(device, vertexDeclaration, vertexCount, usage); + } + + private void InitializeBuffer(SharpDX.Direct3D11.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) { this.vertexStride = vertexDeclaration.VertexStride; //TODO: translate and use usage - GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11; - SharpDX.Direct3D11.DeviceContext context = gd11 != null ? gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext : null; - - if (context != null) + if (device != null) { BufferDescription description = new BufferDescription() { @@ -84,8 +94,7 @@ namespace ANX.RenderSystem.Windows.DX11 OptionFlags = ResourceOptionFlags.None }; - this.buffer = new SharpDX.Direct3D11.Buffer(context.Device, description); - //this.buffer.Unmap(); + this.buffer = new SharpDX.Direct3D11.Buffer(device, description); } }