Question

I am using this to initialize Directx vectors.

LPD3DXVECTOR3 sat_map[] = 
{
    { -1.5f,  0.0f,  1.5f},
    {  1.5f, -1.5f,  1.5f},
};

Even when I try without doing an array, I always get the same error:

error C2440: 'initializing' : cannot convert from 'float' to 'LPD3DXVECTOR3'

I tried doing doubles, but I got a similar error

Was it helpful?

Solution

LPD3DXVECTOR3 is a pointer to a D3DXVECTOR3, and you can't initialize a pointer with a structure (only with a pointer to a structure). Therefore, you just want

D3DXVECTOR3 sat_map[] = 
{
    { -1.5f,  0.0f,  1.5f},
    {  1.5f, -1.5f,  1.5f},
};

or

D3DXVECTOR3 v1 = { -1.5f,  0.0f,  1.5f};
D3DXVECTOR3 v2 = {  1.5f, -1.5f,  1.5f};
LPD3DXVECTOR3 sat_map[] = { &v1, &v2 };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top