Graphics Reference
In-Depth Information
In addition, if we created the device with the debug layer installed, we need to acquire
the debug interface from the device itself in the same manner. This is shown in Listing 1.7.
m_pDebugger = 0;
hr = pDevice->QueryInterface(
uuidof( ID3DllDebug ), (void **)&pDebugger );
Listing 1.7. Acquiring the debug interface from the device using the query interface method.
After these interfaces have been acquired, we can consider Direct3D 11 to be initial-
ized and can move on to the next application phase.
Resource creation. After the application has initialized and acquired the device and device
context and also has a swap chain to render into, it should then create any resources, shader
objects, and state objects that will be used during the rendering portion of the application.
It is the best practice to acquire as many of these objects at startup time as possible, since
acquiring them during rendering operations can introduce momentary delays in rendering.
These glitches can be mostly alleviated with multithreaded rendering, but acquiring the
resource during initialization eliminates the problem completely.
Since we haven't yet examined the available resources, or the components of the ren-
dering pipeline, it would not be useful to describe the creation of these objects here. Both
of these topics have an entire chapter devoted to them (Chapters 2 and 3), so we will not
attempt to provide a glossed-over description here. However, in order to use the texture in-
terface that we acquired from the swap chain, we will need an object called a resource view
to bind the texture as a render target for the pipeline. The particular type of resource view
that is needed is called a render target view. As is the case for most objects in Direct3D 11,
it is created with the device interface and then used with the device context to perform
some action. Listing 1.8 shows a code listing for creating a render target view when the
texture resource is already available.
ID3DllRenderTargetView* pView = 0;
HRESULT hr = m_pDevice->CreateRenderTargetView( pSwapChainBuffer,
0, &pView );
Listing 1.8. Creating a render target view to allow binding the swap chain texture to the pipeline for rendering.
In this case, we pass the texture resource as the first parameter, and instead of a view
description, we simply pass NULL to use a default view description. Resource views are
reference counted as well, so the application must be sure to properly release the reference
when it is finished with it. With the resource view acquired, we are now ready to use our
swap chain texture resource.
Search WWH ::




Custom Search