Compartir a través de


Método ID3DXEffectCompiler::SetLiteral

Alterna el estado literal de un parámetro. Un parámetro literal tiene un valor que no cambia durante la vigencia de un efecto.

Sintaxis

HRESULT SetLiteral(
  [in] D3DXHANDLE hParameter,
  [in] BOOL       Literal
);

Parámetros

hParameter [in]

Tipo: D3DXHANDLE

Identificador único de un parámetro. Consulte Identificadores (Direct3D 9).

Literal [in]

Tipo: BOOL

Establezca en TRUE para convertir el parámetro en un literal y FALSE si el parámetro puede cambiar el valor durante la duración del sombreador.

Valor devuelto

Tipo: HRESULT

Si el método se realiza correctamente, el valor devuelto es D3D_OK. Si se produce un error en el método, el valor devuelto se puede D3DERR_INVALIDCALL.

Comentarios

Estos métodos solo cambian si el parámetro es un literal o no. Para cambiar el valor de un parámetro, use un método como ID3DXBaseEffect::SetBool o ID3DXBaseEffect::SetValue.

Se debe llamar a esta función antes de compilar el efecto. Este es un ejemplo de cómo podría usar esta función:

    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);
    }

Requisitos

Requisito Value
Encabezado
D3DX9Shader.h
Biblioteca
D3dx9.lib

Consulte también

ID3DXEffectCompiler

Usos y literales (Direct3D 9)

ID3DXEffectCompiler::GetLiteral