Game Development Reference
In-Depth Information
example, if the variable that we wish to set is a vector array, the
method name would be SetVectorArray .
The general syntax of the ID3DXConstantTable::SetXXX
methods is of the form:
HRESULT ID3DXConstantTable::SetXXX(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
XXX value
);
pDevice —Pointer to the device that is associated with the con-
stant table
hConstant —A handle that refers to the variable that we are
setting
value —The value that we are setting the variable to, where XXX
is replaced with the variable type name we are setting. For some
types ( bool , int , float ), we pass a copy of the value, and for
other types ( vectors , matrices , structures ), we pass a
pointer to the value.
When we set arrays, the SetXXX method takes an additional fourth
parameter that specifies the number of elements in the array. For
example, the method to set an array of 4D vectors is prototyped as:
HRESULT ID3DXConstantTable::SetVectorArray(
LPDIRECT3DDEVICE9 pDevice, // associated device
D3DXHANDLE hConstant, // handle to shader variable
CONST D3DXVECTOR4* pVector, // pointer to array
UINT Count
// number of elements in array
);
The following list describes the types that we can set with the
ID3DXConstantTable interface. Assume that we have a valid device
( Device ) and a valid handle to the variable that we are setting
( handle ).
SetBool —Used to set a Boolean value. Sample call:
bool b = true;
ConstTable->SetBool(Device, handle, b);
SetBoolArray —Used to set a Boolean array. Sample call:
bool b[3] = {true, false, true};
ConstTable->SetBoolArray(Device, handle, b, 3);
SetFloat —Used to set a float. Sample call:
float f = 3.14f;
ConstTable->SetFloat(Device, handle, f);
Search WWH ::




Custom Search