Game Development Reference
In-Depth Information
enumeration, we have chosen a “safe” configuration that almost all
hardware devices will support.
1.4.2 Checking for Hardware Vertex Processing
When we create an IDirect3DDevice9 object to represent the pri-
mary display adapter, we must specify the type of vertex processing to
use with it. We want to use hardware vertex processing if we can, but
because not all cards support hardware vertex processing, we must
check if the card supports it first.
To do this, we must first initialize a D3DCAPS9 instance based on
the capabilities of the primary display adapter. We use the following
method:
HRESULT IDirect3D9::GetDeviceCaps(
UINT Adapter,
D3DDEVTYPE DeviceType,
D3DCAPS9 *pCaps
);
Adapter —Specifies the physical display adapter that we are going
to get the capabilities of
DeviceType —Specifies the device type to use (e.g., hardware
device ( D3DDEVTYPE_HAL ) or software device ( D3DDEVTYPE_
REF ))
pCaps —Returns the initialized capabilities structure
Then we can check the capabilities, as we did in section 1.3.8. The fol-
lowing code snippet illustrates this:
// Fill D3DCAPS9 structure with the capabilities of the
// primary display adapter.
D3DCAPS9 caps;
d3d9->GetDeviceCaps(
D3DADAPTER_DEFAULT, // Denotes primary display adapter.
deviceType, // Specifies the device type, usually D3DDEVTYPE_HAL.
&caps);
// Return filled D3DCAPS9 structure that contains
// the capabilities of the primary display adapter.
// Can we use hardware vertex processing?
int vp = 0;
if( caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT )
{
// yes, save in 'vp' the fact that hardware vertex
// processing is supported.
vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
else
{
// no, save in 'vp' the fact that we must use software
// vertex processing.
Search WWH ::




Custom Search