Graphics Reference
In-Depth Information
current scene, any two-dimensional screen elements such as user interfaces, and any text
that might be needed for a given frame. Once again, our sample application won't perform
any actual rendering. Instead, it simply uses the method shown in Listing 1.12 to clear the
render target to the color specified in our update phase.
Presenting results to the window. After all of the rendering for a given frame has been
completed, its contents can be presented to the window's client area. This is done quite sim-
ply, using a single method call from the swap chain interface. This is shown in Listing 1.13.
pSwapChain->Present( 0 , 0 );
Listing 1.13. Presenting the contents of the swap buffer resource to its window.
When this method is called, the contents of the render target are presented to the cli-
ent area of the window. The application doesn't need to perform any manual render target
manipulation if multiple buffers are used within the swap chain. Instead, this is managed by
the swap chain itself, which simplifies the application's responsibilities. After this method
has completed, the user will be able to see the render target contents in the window.
After the rendered output has been displayed, the application loop starts over and
checks for any pending Windows messages. This looping sequence repeats until the user
decides to terminate the application. This is normally done by pressing the escape key or
selecting a "quit" option from an application user interface.
Application Shutdown
Before an application can terminate, it needs to clean up all of the open references that it
has acquired. With respect to Direct3D 11 objects, this typically means calling the Release
method for each reference that the application has used. One point to also consider is that
the pipeline itself will keep references to some of the objects that have been bound to it.
To ensure that these pipeline references are released, the application can call the ClearState
method of the device context. This will clear any references from the pipeline and put it into
the default state. The shutdown code for our sample application is shown in Listing 1.14.
pContext ->ClearState();
SAFE_RELEASE( pView );
SAFE_RELEASE( pDepthView );
SAFE_RELEASE( pDepthStencilBuffer );
SAFE_RELEASE( pSwapChainBuffer );
SAFE_RELEASE( pSwapChain );
SAFE_RELEASE( pContext );
Search WWH ::




Custom Search