Graphics Reference
In-Depth Information
flow used in a generic application. This is intended to be a basic introduction with a focus
on what actions are needed for using Direct3D 11, and hence it will not explain all of the
details of Win32 programming. At the end of this section, we will discuss the application
framework that will be used for the sample applications provided with this topic, which
abstracts most of the direct Win32 interactions away from the developer.
1.5.1 Interacting with Direct3D 11
Before getting to the actual application details, we first need to cover a few basic Direct3D 11
concepts. This includes the COM based framework in which Direct3D resides, as well as
understanding how to call, and evaluate the success of the various API functions that an
application must use.
COM-Based Interfaces
Direct3D 11 is implemented as a series of component object model (COM) interfaces in
the same way that the previous versions of Direct3D have been. If you are not familiar with
COM, it may seem like an unnecessary complication to the API. However, once you un-
derstand some of the design implications of using COM, it becomes clear why it has been
chosen for implementing Direct3D 11. We won't dig too deeply into COM, but we will
cover a few of the most visible details that an application will likely use. COM provides
an object model that defines a basic set of interface methods that all COM objects must
implement. This includes methods for performing reference counting of the COM objects,
as well as methods that allow an object to be inspected at runtime to discover which inter-
faces it implements.
Reference counting. An application will primarily be interested in the reference counting
behavior of the COM objects, since it is used to manage their lifetime. When a Direct3D-
based COM object is created with by a function, a reference to that object is returned, typi-
cally in a pointer provided by the application, as an argument to the function call. Instead
of directly creating an instance of a class with the "new" operator, the objects are always
created through a function or an interface method and returned in this way.
When the object reference is returned, it will usually have a reference count of 1.
When the application is finished using the object, it will call the object's Release method,
which indicates that the object's reference count should be decremented. This is performed
instead of directly freeing the object with the "delete" operator. After calling the Release
method, the application should erase the pointer reference and treat it as if it were directly
deleted. As long as the application accurately releases all of its references to the objects
that it creates, the COM framework will manage the creation and destruction of the objects.
Search WWH ::




Custom Search