public ConstantBuffer(GraphicsDevice graphicsDevice, Graphics.ResourceUsage usage, DataArray data) : base(graphicsDevice, new StackTrace(1)) { if (data.IsNull) { throw new ArgumentNullException("data.Pointer"); } if (data.Size <= 0) { throw new ArgumentOutOfRangeException("data.Size", data.Size, "Size must be bigger than 0."); } this.Usage = usage; this.SizeBytes = data.Size; if (!data.IsNull) { BufferDescription bufferDescription = new BufferDescription(SizeBytes, (SharpDX.Direct3D11.ResourceUsage)EnumConverter.Convert(usage), BindFlags.ConstantBuffer, EnumConverter.ConvertToAccessFlag(Usage), ResourceOptionFlags.None, 0); this.Buffer = new SharpDX.Direct3D11.Buffer(graphicsDevice.Device, data.Pointer, bufferDescription); } }
public VertexBuffer(GraphicsDevice graphicsDevice, int vertexCount, VertexDescription description, Graphics.ResourceUsage usage) : base(graphicsDevice, new StackTrace(1)) { if (vertexCount <= 0) { throw new ArgumentException("vertexCount must not be smaller than/ equal to zero.", "vertexCount"); } if (usage == ResourceUsage.Immutable) { throw new ArgumentException("data", "Immutable buffers must be initialized with data."); } this.Description = description; int descriptionSize = graphicsDevice.GetSizeOf(description); this.SizeBytes = descriptionSize * vertexCount; this.Usage = usage; BufferDescription bufferDescription = new BufferDescription(SizeBytes, (SharpDX.Direct3D11.ResourceUsage)EnumConverter.Convert(Usage), BindFlags.VertexBuffer, EnumConverter.ConvertToAccessFlag(Usage), ResourceOptionFlags.None, 0); this.Buffer = new SharpDX.Direct3D11.Buffer(graphicsDevice.Device, bufferDescription); Binding = new VertexBufferBinding(Buffer, descriptionSize, 0); }
public ConstantBuffer(GraphicsDevice graphicsDevice, Graphics.ResourceUsage usage, int sizeBytes) : base(graphicsDevice, new StackTrace(1)) { if (usage == ResourceUsage.Immutable) { throw new ArgumentException("data", "Immutable buffers must be initialized with data."); } if (sizeBytes <= 0) { throw new ArgumentOutOfRangeException("sizeBytes", sizeBytes, "Size must be bigger than 0."); } this.SizeBytes = sizeBytes; this.Usage = usage; BufferDescription bufferDescription = new BufferDescription(SizeBytes, (SharpDX.Direct3D11.ResourceUsage)EnumConverter.Convert(Usage), BindFlags.ConstantBuffer, EnumConverter.ConvertToAccessFlag(Usage), ResourceOptionFlags.None, 0); this.Buffer = new SharpDX.Direct3D11.Buffer(graphicsDevice.Device, bufferDescription); }
public IndexBuffer(GraphicsDevice graphicsDevice, IndexFormat format, Graphics.ResourceUsage usage, int indexCount) : base(graphicsDevice, new StackTrace(1)) { if (indexCount <= 0) { throw new ArgumentOutOfRangeException("indexCount", indexCount, "indexCount must be bigger than zero."); } if (usage == ResourceUsage.Immutable) { throw new ArgumentException("data", "Immutable buffers must be initialized with data."); } this.Format = format; this.SizeBytes = indexCount * graphicsDevice.GetSizeOf(format); this.Usage = usage; BufferDescription bufferDescription = new BufferDescription(SizeBytes, (SharpDX.Direct3D11.ResourceUsage)EnumConverter.Convert(Usage), BindFlags.IndexBuffer, EnumConverter.ConvertToAccessFlag(Usage), ResourceOptionFlags.None, 0); this.Buffer = new SharpDX.Direct3D11.Buffer(graphicsDevice.Device, bufferDescription); }