implemented DrawUserPrimitives for RenderSystem DX10 and DX11 (currently untested)
This commit is contained in:
parent
d982acdbfe
commit
060b732d1b
@ -334,7 +334,15 @@ namespace ANX.Framework.Windows.DX10
|
|||||||
#region DrawUserPrimitives<T>
|
#region DrawUserPrimitives<T>
|
||||||
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
|
public void DrawUserPrimitives<T>(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<T>(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<T>
|
#endregion // DrawUserPrimitives<T>
|
||||||
|
@ -65,13 +65,23 @@ namespace ANX.Framework.Windows.DX10
|
|||||||
int vertexStride;
|
int vertexStride;
|
||||||
|
|
||||||
public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
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;
|
this.vertexStride = vertexDeclaration.VertexStride;
|
||||||
|
|
||||||
//TODO: translate and use usage
|
//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)
|
if (device != null)
|
||||||
{
|
{
|
||||||
|
@ -338,7 +338,15 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
#region DrawUserPrimitives<T>
|
#region DrawUserPrimitives<T>
|
||||||
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
|
public void DrawUserPrimitives<T>(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<T>(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<T>
|
#endregion // DrawUserPrimitives<T>
|
||||||
|
@ -65,15 +65,25 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
int vertexStride;
|
int vertexStride;
|
||||||
|
|
||||||
public VertexBuffer_DX11(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
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;
|
this.vertexStride = vertexDeclaration.VertexStride;
|
||||||
|
|
||||||
//TODO: translate and use usage
|
//TODO: translate and use usage
|
||||||
|
|
||||||
GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11;
|
if (device != null)
|
||||||
SharpDX.Direct3D11.DeviceContext context = gd11 != null ? gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext : null;
|
|
||||||
|
|
||||||
if (context != null)
|
|
||||||
{
|
{
|
||||||
BufferDescription description = new BufferDescription()
|
BufferDescription description = new BufferDescription()
|
||||||
{
|
{
|
||||||
@ -84,8 +94,7 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
OptionFlags = ResourceOptionFlags.None
|
OptionFlags = ResourceOptionFlags.None
|
||||||
};
|
};
|
||||||
|
|
||||||
this.buffer = new SharpDX.Direct3D11.Buffer(context.Device, description);
|
this.buffer = new SharpDX.Direct3D11.Buffer(device, description);
|
||||||
//this.buffer.Unmap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user