Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Runtime / CgD3D9 / cgD3D9SetUniformArray

Name

cgD3D9SetUniformArray - set the elements of an array of uniform parameters

Synopsis

#include <Cg/cgD3D9.h>

HRESULT cgD3D9SetUniformArray( CGparameter param,
                               DWORD offset,
                               DWORD numItems,
                               const void * values );

Parameters

param
The parameter whose array elements are to be set. It must be a uniform parameter that is not a sampler.
offset
The offset at which to start setting array elements.
numItems
The number of array elements to set.
values
An array of floats, the elements in the array to set for param. The amount of data required depends on the type of parameter, but is always specified as an array of one or more floating point values. The type is void* so a compatible user-defined structure can be passed in without type-casting. Use cgD3D9TypeToSize to determine how many values are required for a particular type. This size multiplied by numItems is the number of values this function expects.

Return Values

Returns D3D_OK if the function succeeds.

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

Description

cgD3D9SetUniformArray sets the elements for an array of uniform parameters. All values should be of type float. There is assumed to be enough values to set all specified elements of the array.

Examples

// param is a CGparameter handle of type float3
// arrayParam is a CGparameter handle of type float2x2[3]
...
// intialize the data for each parameter
D3DXVECTOR3 paramData(1,2,3);
float arrayData[2][2][2] =
{
    0,1,
    2,3,
    4,5,
    6,7
};
...
// non-arrays can be set, but only when offset=0 and numItems=1.
cgD3D9SetUniformArray(param, paramData, 0, 1);
// set the 2nd and 3rd elements of the array
cgD3D9SetUniform(arrayParam, arrayData, 1, 2);

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_NOTUNIFORM is returned if param is not a uniform parameter.

CGD3D9ERR_NULLVALUE is returned if values is NULL.

CGD3D9ERR_OUTOFRANGE is returned if offset plus numItems is out of the range of param.

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

History

cgD3D9SetUniformArray was introduced in Cg 1.1.

See Also

cgD3D9SetUniform, cgD3D9SetUniformMatrix, cgD3D9SetUniformMatrixArray, cgD3D9TypeToSize


Cg Toolkit | Cg Toolkit | Download | Release Archive | Profiles | Reference | Books | Discussions |


Cg Runtime CgD3D9

cgD3D9BindProgram
cgD3D9EnableDebugTracing
cgD3D9EnableParameterShadowing
cgD3D9GetDevice
cgD3D9GetLastError
cgD3D9GetLatestPixelProfile
cgD3D9GetLatestVertexProfile
cgD3D9GetManageTextureParameters
cgD3D9GetOptimalOptions
cgD3D9GetTextureParameter
cgD3D9GetVertexDeclaration
cgD3D9IsParameterShadowingEnabled
cgD3D9IsProfileSupported
cgD3D9IsProgramLoaded
cgD3D9LoadProgram
cgD3D9RegisterStates
cgD3D9ResourceToDeclUsage
cgD3D9SetDevice
cgD3D9SetManageTextureParameters
cgD3D9SetSamplerState
cgD3D9SetTextureParameter
cgD3D9SetTexture
cgD3D9SetTextureWrapMode
cgD3D9SetUniformArray
cgD3D9SetUniformMatrixArray
cgD3D9SetUniformMatrix
cgD3D9SetUniform
cgD3D9TranslateCGerror
cgD3D9TranslateHRESULT
cgD3D9TypeToSize
cgD3D9UnbindProgram
cgD3D9UnloadAllPrograms
cgD3D9UnloadProgram
cgD3D9ValidateVertexDeclaration