I\'ve been following the Microsoft Direct3D11 tutorials but using C# and SlimDX. I\'m trying to set the constant buffer but am not sure how to either create or set it.
I
Something similar to this should work:
var buffer = new Buffer(device, new BufferDescription {
Usage = ResourceUsage.Default,
SizeInBytes = sizeof(ConstantBuffer),
BindFlags = BindFlags.ConstantBuffer
});
var cb = new ConstantBuffer();
cb.World = Matrix.Transpose(world);
cb.View = Matrix.Transpose(view);
cb.Projection = Matrix.Transpose(projection);
var data = new DataStream(sizeof(ConstantBuffer), true, true);
data.Write(cb);
data.Position = 0;
context.UpdateSubresource(new DataBox(0, 0, data), buffer, 0);