EffectParameter Class

Represents an Effect parameter.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in microsoft.xna.framework.graphics.dll)

Syntax

public sealed class EffectParameter

Remarks

Creating and assigning a EffectParameter instance for each technique in your Effect is significantly faster than using the Parameters indexed property on Effect.

Example

To use a EffectParameter you must:

  1. Create a EffectParameter for each parameter in your Effect that you will be setting in Draw or Update.

    public EffectParameter mWorld;
    public EffectParameter mCameraView;
    public EffectParameter CameraPos;
    public EffectParameter mCameraProj;
    
  2. Assign an Effect parameter to your EffectParameter.

    mWorld = effect.Parameters["g_mWorld"];
    mCameraView = effect.Parameters["g_mCameraView"];
    CameraPos = effect.Parameters["g_CameraPos"];
    mCameraProj = effect.Parameters["g_mCameraProj"];
    
  3. Call SetValue on your EffectParameter to change the parameter value.

    MyEffect.CameraPos.SetValue(CameraPos);
    MyEffect.mCameraView.SetValue(view);
    MyEffect.mCameraProj.SetValue(projection);
    MyEffect.LightPos.SetValue(LightPos);
    MyEffect.mLightView.SetValue(Matrix.CreateLookAt(LightPos,
        bounds.Center, Vector3.Up));
    

See Also

Reference

EffectParameter Members
Effect.Parameters
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP