共用方式為


XMStoreShort4 函式 (directxpackedvector.h)

XMVECTOR 儲存在 XMSHORT4中。

語法

void XM_CALLCONV XMStoreShort4(
  [out] XMSHORT4  *pDestination,
  [in]  FXMVECTOR V
) noexcept;

參數

[out] pDestination

要儲存數據的位址。

[in] V

包含要儲存之數據的向量。

傳回值

無。

備註

此函式接受向量,將它固定在範圍 -32767.0f 到 32767.0f、將元件轉換成帶正負號、標準化的整數格式,並將結果寫入指定位址的四個短整數值。 最重要的元件會寫入位址的前兩個字節,下一個最重要的元件會寫入位址的下一個兩個字節,依此類傳。

下列虛擬程式代碼示範函式的作業。

static const XMVECTOR  Min = {-32767.0f, -32767.0f, -32767.0f, -32767.0f};
static const XMVECTOR  Max = {32767.0f, 32767.0f, 32767.0f, 32767.0f};
XMVECTOR               N;
N = XMVectorClamp(V, Min, Max);
N = XMVectorRound(N);

pDestination->x = (int16_t)N.x; // 2 bytes to address pDestination
pDestination->y = (int16_t)N.y; // 2 bytes to address (uint8_t*)pDestination + 2
pDestination->z = (int16_t)N.z; // 2 bytes to address (uint8_t*)pDestination + 4
pDestination->w = (int16_t)N.w; // 2 bytes to address (uint8_t*)pDestination + 6

平臺需求

Microsoft Visual Studio 2010 或 Microsoft Visual Studio 2012 搭配 Windows SDK for Windows 8。 支援 Win32 傳統型應用程式、Windows 市集應用程式和 Windows Phone 8 個應用程式。

規格需求

需求
目標平台 Windows
標頭 directxpackedvector.h (包含 DirectXPackedVector.h)

另請參閱

DirectXMath 連結庫向量存放區函式