PaulH
2007-01-18 22:28:02 UTC
I have a dialog app where I'd like to have a control that is direct3d
rendered. So, when this control's window is created I call an
CreateDevice() as below. But, it always fails with the error code
D3DERR_INVALIDCALL (0x8876086c).
I've essentially stolen this function from the Directx9 (December 2006)
SDK vertex tutorial sample. The SDK tutorial works perfectly. Why does
the same code fail in my program? I assume it's because the whole
dialog window isn't Direct3D, just one control. Is there something
special I need to do to make this work?
(I have also tried using D3DDEVTYPE_REF as suggested to people
reporting a similar problem in other forums, but that doesn't seem to
make any difference.)
Thanks,
PaulH
HRESULT InitD3D()
{
// Create the D3D object.
if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
ATLTRACE( _T( "Failed to Init Direct3D\n" ) );
return E_FAIL;
}
// Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp = { 0 };
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
// Create the D3DDevice
HRESULT hr = m_pD3D->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
m_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&m_pd3dDevice );
if( FAILED( hr ) )
{
ATLTRACE( _T( "Failed to create Direct3D device. %#08x\n"
), hr );
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
};
/// Used to create the D3DDevice
LPDIRECT3D9 m_pD3D;
/// Our rendering device
LPDIRECT3DDEVICE9 m_pd3dDevice;
rendered. So, when this control's window is created I call an
CreateDevice() as below. But, it always fails with the error code
D3DERR_INVALIDCALL (0x8876086c).
I've essentially stolen this function from the Directx9 (December 2006)
SDK vertex tutorial sample. The SDK tutorial works perfectly. Why does
the same code fail in my program? I assume it's because the whole
dialog window isn't Direct3D, just one control. Is there something
special I need to do to make this work?
(I have also tried using D3DDEVTYPE_REF as suggested to people
reporting a similar problem in other forums, but that doesn't seem to
make any difference.)
Thanks,
PaulH
HRESULT InitD3D()
{
// Create the D3D object.
if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
ATLTRACE( _T( "Failed to Init Direct3D\n" ) );
return E_FAIL;
}
// Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp = { 0 };
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
// Create the D3DDevice
HRESULT hr = m_pD3D->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
m_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&m_pd3dDevice );
if( FAILED( hr ) )
{
ATLTRACE( _T( "Failed to create Direct3D device. %#08x\n"
), hr );
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
};
/// Used to create the D3DDevice
LPDIRECT3D9 m_pD3D;
/// Our rendering device
LPDIRECT3DDEVICE9 m_pd3dDevice;