cgD3D9SetUniformMatrix
Keywords: cgD3D9SetUniformMatrix, NVIDIA, NVIDIA Cg Toolkit, Cg Toolkit, Shader, Shader Programming, GPU Shader Programming, GPU Program

> ## Name

> cgD3D9SetUniformMatrix - set the values of a uniform matrix parameter

> ## Synopsis

>     #include <Cg/cgD3D9.h>

>     HRESULT cgD3D9SetUniformMatrix( CGparameter param,
>                                     const D3DMATRIX * matrix );

> ## Parameters

> param
>   The parameter whose values are to be set. It must be a uniform matrix parameter.
> matrix
>   The matrix to set for the parameter. The upper-left portion of the matrix is extracted to fit the size of param.

> ## Return Values

> Returns D3D_OK if the function succeeds.

> Returns the D3D failure code if the function fails due to a D3D call.

> ## Description

> cgD3D9SetUniformMatrix sets the values of a uniform matrix parameter.

> ## Examples

>     // matrixParam is a CGparameter handle of type float3x2
>     // arrayParam is a CGparameter handle of type float4x4[2]
>     ...
>     // intialize the data for each parameter
>     D3DXMATRIX matTexTransform(
>         0.5f,    0, 0, 0,
>            0, 0.5f, 0, 0,
>         0.5f, 0.5f, 0, 0,
>            0,    0, 0, 0
>     );
>     D3DXMATRIX matRot[2];
>     D3DXMatrixRotationAxis(&matRot[0], &D3DXVECTOR3(0,0,1), D3DX_PI*0.5f);
>     D3DXMatrixRotationAxis(&matRot[1], &D3DXVECTOR3(0,1,0), D3DX_PI*0.5f);
>     ...
>     // only use the upper-left portion
>     cgD3D9SetUniform(matrixParam, &matTexTransform);
>     // you can use arrays, but you must set the entire array
>     cgD3D9SetUniform(arrayParam, matRot);

> ## Errors

> cgD3D9Failed is generated if a D3D function returns an error.

> CGD3D9ERR_NODEVICE is returned if a required D3D device is NULL. This usually occurs when an expanded interface routine is called but a D3D device has not been set with cgD3D9SetDevice.

> CGD3D9ERR_NOTLOADED is returned if program was not loaded with the cgD3D9LoadProgram.

> CGD3D9ERR_NOTMATRIX is returned if param is not a matrix.

> CGD3D9ERR_NOTUNIFORM is returned if param is not a uniform parameter.

> CGD3D9ERR_INVALIDPARAM is returned if the parameter fails to set for any other reason.

> ## History

> cgD3D9SetUniformMatrix was introduced in Cg 1.1.

> ## See Also

> cgD3D9SetUniform, cgD3D9SetUniformMatrixArray, cgD3D9TypeToSize