Share via


Effect.CurrentTechnique Property

Gets or sets the active technique.

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

Syntax

public EffectTechnique CurrentTechnique { get; set; }

Property Value

The current technique.

Exceptions

Exception type Condition
ArgumentNullException

CurrentTechnique is null. CurrentTechnique cannot be null.

Remarks

Note

The BasicEffect class, which is derived from Effect and inherits the Techniques collection, contains only one available technique to set as the active technique. The active technique applies the settings that have been set as the properties of the BasicEffect.

Example

In this example, an effect file is shown that defines a single technique called TransformTechnique.

uniform extern float4x4 WorldViewProj : WORLDVIEWPROJECTION;

struct VS_OUTPUT
{
    float4 position : POSITION;
    float4 color : COLOR0;
};

VS_OUTPUT Transform(
    float4 Pos  : POSITION, 
    float4 Color : COLOR0 )
{
    VS_OUTPUT Out = (VS_OUTPUT)0;

    Out.position = mul(Pos, WorldViewProj);
    Out.color = Color;

    return Out;
}

float4 PixelShader( VS_OUTPUT vsout ) : COLOR
{
    return vsout.color;
}

technique TransformTechnique
{
    pass P0
    {
        vertexShader = compile vs_2_0 Transform();
        pixelShader = compile ps_1_1 PixelShader();
    }
}

When this effect file is loaded as an Effect by the ContentManager, this technique may be set as the active technique by setting CurrentTechnique to effect.Techniques["TransformTechnique"].

See Also

Tasks

How to: Create and Apply Custom Effects
How to: Create Custom Texture Effects

Reference

Effect.Techniques Property
Effect Class
Effect Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista