XMVectorSwizzle

Swizzles a vector.

Overload list

Name Description
XMVectorSwizzle (XMVECTOR) Swizzles a vector.
XMVectorSwizzle (XMVECTOR, uint32_t, uint32_t, uint32_t, uint32_t) Swizzles a vector.

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>.

XM_SWIZZLE_X, XM_SWIZZLE_Y, XM_SWIZZLE_Z, and XM_SWIZZLE_W are constants which evaluate to 0, 1, 2, and 3 respectively for use with XMVectorSwizzle. This is identical to XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0Z, and XM_PERMUTE_0W.

For the case of constant indices (E0, E1, E2, E3), it is much more efficient to use the template form of XMVectorSwizzle:

template<uint32_t SwizzleX, uint32_t SwizzleY, uint32_t SwizzleZ, uint32_t SwizzleW>
    XMVECTOR XMVectorSwizzle(FXMVECTOR V)

Example: XMVectorSwizzle< 3, 3, 0, 2>(v);