Graphics Reference
In-Depth Information
While(running)
{
... Process messages
... Render frame
Present();
}
}
5.
For desktop applications, SharpDX provides a helper class SharpDX.Windows.
RenderLoop that implements the rendering loop and processes any
window messages for us. The following code demonstrates its use within
a D3DApplicationDesktop.Run implementation:
public override void Run()
{
SharpDX.Windows.RenderLoop.Run(Window, () => {
... Render frame
Present();
});
}
6.
To take advantage of the lifecycle management built into the Common.
DeviceManager class and the Common.D3DApplicationBase abstract base
class, we can optionally override the following methods in our D3DApp implementation:
// Override / extend the default SwapChainDescription1
protected override SwapChainDescription1
CreateSwapChainDescription()
{ ... }
// Event-handler for DeviceManager.OnInitialize
protected override void CreateDeviceDependentResources(DeviceManag
er deviceManager)
{ ... }
// Event-handler for D3DApplicationBase.OnSizeChanged
protected override void CreateSizeDependentResources(D3DApplicatio
nBase app)
{ ... }
7.
We are now able to create an instance of D3DApp , initialize the Direct3D device and
resources, and then start the application loop. To ensure all resources are correctly
released, we can use a using code block. The following code snippet shows how this
might be done:
using (var app = new D3DApp(form) )
{
// Only render frames at the maximum rate the
 
Search WWH ::




Custom Search