【发布时间】:2019-03-06 18:01:23
【问题描述】:
从 DirectX 开始,然后在 XMVECTORs 上玩转
(我知道我不会在上下文中使用它们,我只是好奇)
// Vectors.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <DirectXMath.h>
#include <DirectXPackedVector.h>
int main()
{
using namespace DirectX;
XMVECTOR vector = XMVectorSet(1, 2, 3, 1);
int x = XMVectorGetIntX(vector);
std::cout << "vector.x: " << x << std::endl;
system("pause");
return 0;
}
这会打印出 1065353216
的值虽然很有趣,但我想知道我做错了什么,或者这是否确实是预期的功能。
【问题讨论】:
-
如果你想存储整数数据,你应该使用
XMVectorSetInt。 -
1065353216是十六进制的0x3F800000,1.0f 的 IEEE754 表示形式是什么。 -
啊,我明白了!那么 XMVectorSet 的用途是什么?
-
不带 *Int 后缀的都是浮点数据。
标签: c++ vector graphics directx directx-12