本文整理汇总了C#中Buffer.Unmap方法的典型用法代码示例。如果您正苦于以下问题:C# Buffer.Unmap方法的具体用法?C# Buffer.Unmap怎么用?C# Buffer.Unmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Buffer
的用法示例。
在下文中一共展示了Buffer.Unmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnResourceLoad
protected override void OnResourceLoad()
{
using (Texture2D texture = Texture2D.FromSwapChain<Texture2D>(Context10.SwapChain, 0))
{
renderTargetView = new RenderTargetView(Context10.Device, texture);
}
effect = Effect.FromFile(Context10.Device, "SimpleTriangle10.fx", "fx_4_0");
technique = effect.GetTechniqueByIndex(0);
pass = technique.GetPassByIndex(0);
ShaderSignature signature = pass.Description.Signature;
inputLayout = new InputLayout(Context10.Device, signature, new[] {
new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 0, 0),
new InputElement("COLOR", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 16, 0)
});
vertexBuffer = new Buffer(
Context10.Device,
3 * 32,
ResourceUsage.Dynamic,
BindFlags.VertexBuffer,
CpuAccessFlags.Write,
ResourceOptionFlags.None
);
DataStream stream = vertexBuffer.Map(MapMode.WriteDiscard, MapFlags.None);
stream.WriteRange(new[] {
new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)
});
vertexBuffer.Unmap();
}