Graphics Reference
In-Depth Information
With this approach it is important to ensure that any resources that wrap a native COM object
are passed to ToDispose , so that they are correctly registered to be released when our class
instance is disposed.
SharpDX classes that wrap COM objects all descend from SharpDX.
ComObject . This class provides access to the native pointer and also
a number of helpful variations on the native IUnknown interface's
QueryInterface method.
Creating size-dependent resources
In this recipe, we will look at how the included sample framework deals with the initialization
of size-dependent Direct3D resources within the base Direct3D application class. We review
the base class's implementation, and then implement an override for a descending class.
We also review two important graphics pipeline preparation steps that are dependent upon
the render target size: creating the viewport for the Rasterizer Stage (RS) and creating a
depth/stencil buffer and view for the Output Merger (OM) stage.
Getting ready
We continue on from where we left off in the Using the sample rendering framework recipe.
How to do it…
The application base class D3DApplicationBase initializes the swap chain buffers
and render targets within the CreateSizeDependentResources method, which is
an event-handler attached to the D3DApplicationBase.OnSizeChanged event.
This method has been implemented as follows:
1.
The base implementation is a protected virtual method that allows the descending
classes to extend the default behavior.
protected virtual void CreateSizeDependentResources(D3DApplication
Base app)
{ ... }
Unless completely overriding the base class's implementation, it is
important to always call base.CreateSizeDependentResources(
this) within your overridden implementation.
 
Search WWH ::




Custom Search