Closed HppZ closed 5 years ago
Yes, that is exactly what I mean.
The basic reason for organizing it this way is that some things don't depend on a Direct3D device, such as creating your audio graph. My audio samples therefore initialize the XAudio2 engine in Initialize
which only called once for a given program instance.
Lots of Direct3D resources require the Direct3D device: textures, vertex buffers, index buffers, etc. In my samples, I typically do model loading, creating spritebatch instances, etc. in CreateDeviceDependentResources
.
Some resources depend on both the Direct3D device and is based on the presentation window size. This includes the size of the swap chain, render targets, offscreen render targets, etc. In my samples, I typically handle font loading here if it depends on resolution (on Xbox it would be 1080p vs. 4k), but mostly it's the swapchain and this is done in CreateWindowSizeDependentResources
.
When the user changes the size of the presentation window (resizing the window, maximize/restore), then CreateWindowSizeDependentResources
is called to re-create any size-dependent resources.
If the system encounters a 'lost device' scenario (i.e. getting DXGI_ERROR_DEVICE_REMOVED
from DXGI Present), then both CreateDeviceDependentResources
and CreateWindowSizeDependentResources
will get called again.
I think you are asking if something should be created in
Initialize
, inCreateDevice
/CreateDeviceDependentResources
, -or- insideCreateResources
/CreateWindowSizeDependentResources
in the directx-vs-templates?Or do you mean something else?