Graphics Reference
In-Depth Information
OutputHandle = form.Handle,
SwapEffect = SwapEffect.Discard,
},
out device, out swapChain
);
// Create references for backBuffer and renderTargetView
var backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain,
0);
var renderTargetView = new RenderTargetView(device,
backBuffer);
#endregion
...
}
9.
Within the same Main() function, we now create a simple render loop using
a SharpDX utility class SharpDX.Windows.RenderLoop that clears the render
target with a light blue color.
#region Render loop
// Create and run the render loop
RenderLoop.Run(form, () =>
{
// Clear the render target with light blue
device.ImmediateContext.ClearRenderTargetView(
renderTargetView,
Color.LightBlue);
// Execute rendering commands here...
// Present the frame
swapChain.Present(0, PresentFlags.None);
});
#endregion
10. And finally, after the render loop we have our code to clean up the Direct3D
COM references.
#region Direct3D Cleanup
// Release the device and any other resources created
renderTargetView.Dispose();
backBuffer.Dispose();
device.Dispose();
swapChain.Dispose();
#endregion
 
Search WWH ::




Custom Search