Graphics Reference
In-Depth Information
workload can be performed. For our rendering application, this consists of clearing the
render targets, then performing the desired rendering operations, and finally presenting
the results to the window's client area. Each time these two processes are repeated repre-
sents one frame rendering. This will continue until the user requests the termination of the
application.
After the application exits the message loop, it performs a one-time shutdown rou-
tine. In this routine, all of the resources that have been created are released. After they have
been released, the device context, and the device itself, are released as well. At this point,
as long as all of the reference counts of the Direct3D 11 objects have been properly man-
aged, the application will have completely released all of its references to all objects. After
the shutdown process has completed, the application will end by exiting its main function.
Now that we have seen each of the steps that are performed, we can take a closer look
at how each of these steps involves Direct3D 11 and see what the actual code looks like
for using the API.
Application Initialization
The application initialization procedure begins with the application creating the Win32
window that will present the results of our rendering operations. Basic Win32 code for cre-
ating a window has been presented many, many times in numerous topics and tutorials and
won't be repeated here. However, the sample program rendering framework also includes
this type of code, and a quick reference to this code within the source distribution can be
found in the class files for the Win32RenderWindow class. For the purposes of this discus-
sion, we will assume that the window has been properly registered and created, and that a
window handle is available for it.
Device and context creation. After the window has been created, the next step is to obtain
a reference to the device. This process is performed with either the D3DllCreateDevice()
or the D3DllCreateDeviceAndSwapChain() functions. For this example, we will use the
latter function simply because it creates a swap chain from within the same function, in
addition to creating the device and device context.
The prototype for the function is shown in Listing 1.2. We will step through the
parameters to this function to gain an understanding of what is needed to create a device.
HRESULT D3DllCreateDeviceAndSwapChain(
IDXGIAdapter *pAdapter,
D3D_DRIVER_TYPE Driver-Type,
HMODULE Software,
UINT Flags,
const D3D_FEATURE_LEVEL *pFeatureLevels,
UINT FeatureLevels,
UINT SDKVersion,
Search WWH ::




Custom Search