Creating device-dependent resources
In this recipe, we will see how the included sample framework deals with the initialization of device-dependent Direct3D resources and how our custom classes can make use of this throughout this book.
Getting ready
We continue from where we left off in the Using the sample rendering framework recipe.
How to do it…
We will review the base class's implementation of the CreateDeviceDependentResources
function, and then look at how to implement overrides within the descending classes.
The following protected virtual
D3DApplicationBase.CreateDeviceDependentResources
implementation is assigned as an event-handler to theDeviceManager.OnInitialize
event.protected virtual void CreateDeviceDependentResources(DeviceManager deviceManager) { if (_swapChain != null) { // Release the swap chain RemoveAndDispose(ref _swapChain); // Force reinitialize size dependent resources SizeChanged(true); } }
Within your class descending from...