-1

I learn DirectX (DirectX 9) from www.directxtutorial.com and using visual studio 2012 in windows 8. d3dx9 (d3dx) replace by other header like DirectXMath, therefore I replaced all that is needed, but there is a problem - convert XMVECTOR to D3DVECTOR and to D3DCOLORVALUE.

The problem code (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*/ }
Arlu
  • 41
  • 2
  • 9
  • Could you give some details on what exactly the problem is? As I am reading the question you have an XMVECTOR and you want a D3DVECTOR right? What compiler error do you get? – Daniel Retief Fourie Jun 20 '13 at 14:35
  • IntelliSense: no suitable user-defined conversion from "DirectX::XMVECTOR" to "D3DCOLORVALUE" exists. IntelliSense: no suitable user-defined conversion from "DirectX::XMVECTOR" to "D3DVECTOR" exists. – Arlu Jun 20 '13 at 16:15
  • Hmmm. I'll do some more digging, but as far as I've read, it may be possible to do a simple cast to the correct type. Have you tried something like material.Diffuse = (D3DXCOLOR)xm_vector; ? – Daniel Retief Fourie Jun 21 '13 at 04:50
  • d3dx9 (d3dx) replace by other header like DirectXMath... – Arlu Jun 21 '13 at 11:02
  • I'm looking into it. It's now 14:00 my time, and I'll only be able to investigate further around 20:00 tonight, but I'll see if I can manage something. You can always include d3dx9.h in your project as well. There seems to be no reason that you can't use both DX9 and DX11 headers at the same time. I'll try and come up with a more elegant solution than mixing the two though. – Daniel Retief Fourie Jun 21 '13 at 12:00
  • d3dx9 (d3dx) no exist! It replace by DirectXMath and other headers. I want use replace headers. – Arlu Jun 23 '13 at 11:08
  • possible duplicate of [how to convert XMMATRIX to D3DMATRIX in DirectX 9?](http://stackoverflow.com/questions/17173925/how-to-convert-xmmatrix-to-d3dmatrix-in-directx-9) – McGarnagle Jan 14 '14 at 22:31
  • It isn't like to "how to convert XMMATRIX to D3DMATRIX in DirectX 9?", but slightly similar. – Arlu Mar 10 '14 at 13:53

1 Answers1

0

You should replace all D3DVECTOR with XMVECTOR and D3DXCOLOUR with XMCOLOR.

alanw
  • 645
  • 6
  • 10