Question

I have a d3d9 proxy dll.

I need to save the D3DXMATRIX in the SetTransform function to use it in another function.

I declare them at beginning with

D3DXMATRIX view_matrix, proj_matrix, world_matrix;

in the SetTransform function i have:

HRESULT my_IDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix)
{
    if (State == D3DTS_VIEW)
    {
        &view_matrix = pMatrix;
    }
    if (State == D3DTS_PROJECTION)
    {
        &proj_matrix = pMatrix;
    }
    if (State == D3DTS_WORLD)
    {
        &world_matrix = pMatrix;
    }
    return(m_pIDirect3DDevice9->SetTransform(State,pMatrix));
}

Compiler error message:

my_IDirect3DDevice9.cpp
my_IDirect3DDevice9.cpp(838) : error C2440: '=' : cannot convert from 'const D3DMATRIX *' to 'D3DXMATRIX *'
        Cast from base to derived requires dynamic_cast or static_cast
my_IDirect3DDevice9.cpp(842) : error C2440: '=' : cannot convert from 'const D3DMATRIX *' to 'D3DXMATRIX *'
        Cast from base to derived requires dynamic_cast or static_cast
my_IDirect3DDevice9.cpp(846) : error C2440: '=' : cannot convert from 'const D3DMATRIX *' to 'D3DXMATRIX *'
        Cast from base to derived requires dynamic_cast or static_cast
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'

I need these 3 matrixes later for calculations:

m_pIDirect3DDevice9->GetTransform( D3DTS_VIEW, &view_matrix );
m_pIDirect3DDevice9->GetTransform( D3DTS_PROJECTION, &proj_matrix );
m_pIDirect3DDevice9->GetTransform( D3DTS_WORLD, &world_matrix );
m_pIDirect3DDevice9->GetViewport( &d3dvp );
D3DXVec3Project( &vector_2d, &vector_3d, &d3dvp, &proj_matrix, &view_matrix, &world_matrix );
D3DXVec3Unproject( &vector_3d, &vector_2d, &d3dvp, &proj_matrix, &view_matrix, &world_matrix );

since GetTransform is failing on Windows XP systems. So i need to get them already when they got set.

Was it helpful?

Solution

&view_matrix is the address of view_matrix, that's an r-value, you can't assign to r-value.

Try this:

if (State == D3DTS_VIEW)
{
    view_matrix = *pMatrix;
}
if (State == D3DTS_PROJECTION)
{
    proj_matrix = *pMatrix;
}
if (State == D3DTS_WORLD)
{
    world_matrix = *pMatrix;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top