description | ms.assetid | title | ms.topic | ms.date | topic_type | api_name | api_type | api_location | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Toggles the literal status of a parameter. A literal parameter has a value that doesn't change during the lifetime of an effect. |
09ebf666-8a50-4604-abef-aed0d92a6d49 |
ID3DXEffectCompiler::SetLiteral method (D3DX9Shader.h) |
reference |
05/31/2018 |
|
|
|
|
Toggles the literal status of a parameter. A literal parameter has a value that doesn't change during the lifetime of an effect.
HRESULT SetLiteral(
[in] D3DXHANDLE hParameter,
[in] BOOL Literal
);
-
hParameter [in]
-
Type: D3DXHANDLE
Unique identifier to a parameter. See Handles (Direct3D 9).
-
Literal [in]
-
Type: BOOL
Set to TRUE to make the parameter a literal, and FALSE if the parameter can change value during the shader lifetime.
Type: HRESULT
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.
This methods only changes whether the parameter is a literal or not. To change the value of a parameter, use a method like ID3DXBaseEffect::SetBool or ID3DXBaseEffect::SetValue.
This function must be called before the effect is compiled. Here is an example of how one might use this function:
LPD3DXEFFECTCOMPILER pEffectCompiler;
char errors[1000];
HRESULT hr;
hr = D3DXCreateEffectCompilerFromFile("shader.fx",
NULL, NULL, 0,
&pEffectCompiler,
&errors);
//In the fx file, literalInt is declared as an int.
//By calling this function, the compiler will treat
//it as a literal (i.e. #define)
hr = pEffectCompiler->SetLiteral("literalInt", TRUE);
//create ten different variations of the same effect
LPD3DXBUFFER pEffects[10];
LPD3DXBUFFER pErrors;
for(int i = 0; i < 10; ++i)
{
hr = pEffectCompiler->SetInt("literalInt", i);
hr = pEffectCompiler->CompileEffect(0, &pEffects[i], &pErrors);
}
Requirement | Value |
---|---|
Header |
|
Library |
|