Share via


XMVectorSwizzle

Swizzles a vector.

Syntax

XMVECTOR XMVectorSwizzle(
         XMVECTOR V,
         UINT E0,
         UINT E1,
         UINT E2,
         UINT E3
)

Parameters

  • V
    [in] Vector to swizzle.
  • E0
    [in] Index that describes which component of V to place in the x-component of the swizzled vector. A value of 0 selects the x-component, 1 selects the y-component, 2 selects the z-component, and 3 selects the w-component.
  • E1
    [in] Index that describes which component of V to place in the y-component of the swizzled vector. A value of 0 selects the x-component, 1 selects the y-component, 2 selects the z-component, and 3 selects the w-component.
  • E2
    [in] Index that describes which component of V to place in the z-component of the swizzled vector. A value of 0 selects the x-component, 1 selects the y-component, 2 selects the z-component, and 3 selects the w-component.
  • E3
    [in] Index that describes which component of V to place in the w-component of the swizzled vector. A value of 0 selects the x-component, 1 selects the y-component, 2 selects the z-component, and 3 selects the w-component.

Return Value

Returns the swizzled XMVECTOR.

Remarks

The following code demonstrates how this function might be used.

XMVECTOR v = XMVectorSet( 10.0f, 20.0f, 30.0f, 40.0f );
XMVECTOR result = XMVectorSwizzle(v, 3, 3, 0, 2 );

The swizzled vector (result) will be <40.0f, 40.0f, 10.0f, 30.0f>.

For efficiency XMVectorSwizzle is implemented as a #define on the Xbox 360 VMX128 target. Therefore E0, E1, E2, and E3 must be literals and not runtime variables.

Requirements

Header: Declared in xnamath.h.

See Also

XMVectorPermute