Domanda

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

È stato utile?

Soluzione

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 };
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top