如何在DirectX 9中转换XMVECTOR到d3vector和D3DCOLORVALUE
how to convert XMVECTOR to D3DVECTOR and to D3DCOLORVALUE in DirectX 9?
我从www.directxtutorial.com学习DirectX (DirectX 9),并在windows 8中使用visual studio 2012。d3dx9 (d3dx)替换为其他头如DirectXMath,因此我替换了所有需要的,但有一个问题-将XMVECTOR转换为D3DVECTOR和D3DCOLORVALUE。
问题代码(The problem written -/problem!/):
void init_light(void) {
D3DLIGHT9 light; // create the light struct
D3DMATERIAL9 material; // create the material struct
ZeroMemory(&light, sizeof(light)); // clear out the light struct for use
light.Type = D3DLIGHT_DIRECTIONAL; // make the light type 'directional light'
light.Diffuse = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); /*problem!*/ // set the light's color
light.Direction = D3DXVECTOR3(-1.0f, -0.3f, -1.0f); /*problem!*/
d3ddev->SetLight(0, &light); // send the light struct properties to light #0
d3ddev->LightEnable(0, TRUE); // turn on light #0
ZeroMemory(&material, sizeof(D3DMATERIAL9)); // clear out the struct for use
material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); /*problem!*/ // set diffuse color to white
material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); /*problem!*/ // set ambient color to white
d3ddev->SetMaterial(&material); /*set the globably-used material to &material*/ }
你应该用XMVECTOR替换所有的d3vector,用XMCOLOR替换所有的d3dxcolor。
相关文章:
- 如何在 DirectX 中初始化 XMVECTOR?
- DirectX :: XMVector函数XMVectorSetByIndex()未设置Float(C )
- XMVECTOR weird values
- 二进制 '-' : 'DirectX::XMVECTOR' 没有定义这个运算符或转换(从 xnamath 迁移到 DirectXMath 并不容易)
- 使用XMVector时的内存访问异常
- 使用 XMVECTOR 作为类成员
- 不能将 XMVECTOR 与浮点数相乘
- 如何在构造函数中正确初始化XMVECTOR
- 如何在DirectX 9中转换XMVECTOR到d3vector和D3DCOLORVALUE
- 使用DirectXMath中的XMVECTOR作为类成员只会在发布模式下导致崩溃
- 如何正确使用XMVECTOR成员变量