Game Development Reference
In-Depth Information
Note
nullptr
is a new C++11 keyword that gives us a strongly-defined null pointer.
Previously NULL was just an alias for zero, which prevented the compiler from
supporting us with extra error-checking.
D3D11CreateDevice(
nullptr,
D3D_DRIVER_TYPE_HARDWARE,
nullptr,
D3D11_CREATE_DEVICE_BGRA_SUPPORT,
featureLevels,
ARRAYSIZE(featureLevels),
D3D11_SDK_VERSION,
&device,
&m_featureLevel,
&context
);
Most of this is pretty simple: we request a hardware device with BGRA format layout
support (see the
Swap chain
section for more details on texture formats) and provide
a list of feature levels that we can support. The magic of COM and Direct3D will
provide us with an
ID3D11Device
and
ID3D11DeviceContext
that we can use
for rendering.
Device context
The device context is probably the most useful item that you're going to create. This
is where you will issue all draw calls and state changes to the graphics hardware.
The device context works together with the graphics device to provide 99 percent of
the commands you need to use Direct3D.
By default we get an
immediate context
along with our graphics device. One of
the main benefits provided by a context system is the ability to issue commands
from worker threads using
deferred contexts
. These deferred contexts can then be