Game Development Reference
In-Depth Information
Initializing the Direct3D API
Direct3D is a rendering API that allows you to write your game without having to worry
about which graphics card or driver the user may have. By separating this concern
through the Component Object Model ( COM ) system, you can easily write once and
have your code run on the hardware from NVIDIA or AMD.
Now let's take a look at Direct3DBase.cpp , the class that we inherited from earlier.
This is where DirectX is set up and prepared for use. There are a few objects that we
need to create here to ensure we have everything required to start drawing.
Graphics device
The first is the graphics device, represented by an ID3D11Device object. The device
represents the physical graphics card and the link to a single adapter. It is primarily
used to create resources such as textures and shaders, and owns the device context
and swap chain.
Direct3D 11.1 also supports the use of feature levels to support older graphics cards
that may only support Direct3D 9.0 or Direct3D 10.0 features. When you create the
device, you should specify a list of feature levels that your game will support, and Dir-
ectX will handle all of the checks to ensure you get the highest feature level you want
that the graphics card supports.
You can find the code that creates the graphics device in the Direc-
t3DBase::CreateDeviceResources() method. Here we allow all possible fea-
ture levels, which will allow our game to run on older and weaker devices. The key
thing to remember here is that if you want to use any graphics features that were in-
troduced after Direct3D 9.0, you will need to either remove the older feature levels
from the list or manually check which level you have received and avoid using that
feature.
Once we have a list of feature levels, we just need a simple call to the
D3D11CreateDevice() method, which will provide us with the device and immedi-
ate device context.
Search WWH ::




Custom Search