private void SetShaderLineColor(ColorRgba color) { LineColorBufferElement bufElem = new LineColorBufferElement { LineColor = color }; if (lcBuffer == null) { lcBuffer = device.CreateBuffer( new BufferDescription { BindingOptions = BindingOptions.ConstantBuffer, CpuAccessOptions = CpuAccessOptions.Write, MiscellaneousResourceOptions = MiscellaneousResourceOptions.None, Usage = Usage.Dynamic, ByteWidth = (uint)Marshal.SizeOf(bufElem) }); } MappedSubresource mappedResource = (MappedSubresource)deviceContext.Map(lcBuffer, 0, Map.WriteDiscard, WindowsAPICodePack.DirectX.Direct3D11.MapOptions.None); Marshal.StructureToPtr(bufElem, mappedResource.Data, true); deviceContext.Unmap(lcBuffer, 0); deviceContext.PS.SetConstantBuffers(0, new D3DBuffer[] { lcBuffer }); }
private void SetShaderLineColor(ColorRgba color) { LineColorBufferElement bufElem = new LineColorBufferElement { LineColor = color }; if (lcBuffer == null) { lcBuffer = device.CreateBuffer( new BufferDescription { BindFlags = BindFlag.ConstantBuffer, CpuAccessFlags = CpuAccessFlag.Write, MiscFlags = ResourceMiscFlag.Undefined, Usage = Usage.Dynamic, ByteWidth = (uint)Marshal.SizeOf(bufElem) }); } MappedSubresource mappedResource = (MappedSubresource)deviceContext.Map(lcBuffer, 0, Map.WriteDiscard, MapFlag.Unspecified); Marshal.StructureToPtr(bufElem, mappedResource.Data, true); deviceContext.Unmap(lcBuffer, 0); deviceContext.PS.SetConstantBuffers(0, new D3DBuffer[] { lcBuffer }); }