HRESULT InitD3D()
{
Write2Log("Initializing D3D...") ;
if (NULL==(g_pD3D=Direct3DCreate9(D3D_SDK_VERSION)))
{
Write2Log("Failed to get right SDK version!") ;
return E_FAIL ;
}
Write2Log("D3D object received.") ;
ZeroMemory (&d3dpp, sizeof(d3dpp)) ;
d3dpp.Windowed = FALSE ;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD ;
d3dpp.BackBufferFormat = D3DFMT_R5G6B5 ;
d3dpp.BackBufferWidth = g_nScreenX ;
d3dpp.BackBufferHeight = g_nScreenY ;
HRESULT hresult ;
hresult=g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
g_hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&g_pd3dDevice) ;
if (hresult=D3DERR_INVALIDCALL)
{
Write2Log("Incorrect parameter in CreateDevice function") ;
return E_FAIL ;
}
if (hresult=D3DERR_NOTAVAILABLE)
{
Write2Log("Device not available.") ;
return E_FAIL ;
}
if (hresult=D3DERR_OUTOFVIDEOMEMORY)
{
Write2Log("Graphic adapter is out of memory.") ;
return E_FAIL ;
}
return D3D_OK ;
} // end of HRESULT InitD3D()
failing to initialize D3D9
What could be wrong with my function :
In my log file I get the following error : Incorrect parameter in CreateDevice function
So is there something wrong in my d3dpp paramters or in my parameters in my CreateDevice() function?
thanx in advance
use == instead of = in your if block
if (hresult=D3DERR_INVALIDCALL) //error
if (hresult==D3DERR_INVALIDCALL) //correct
The Wild Wild West - Desperado!
if (hresult=D3DERR_INVALIDCALL) //error
if (hresult==D3DERR_INVALIDCALL) //correct
The Wild Wild West - Desperado!
No, that isn''t the reason.
In
hresult=g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
One of the parameters passed is either missing, spelled incorrectly or need to be casted.
In
hresult=g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
One of the parameters passed is either missing, spelled incorrectly or need to be casted.
Wildwest is right tho. doing
if (hresult=D3DERR_INVALIDCALL)
{
}
will always execute the code inside. it''s because the = actually returns the value. so HRESULT becomes D3DERR_INVALIDCALL, and that is returned to the IF, evaluates to true, and writes to the log..
so change those too while you''re at it
if (hresult=D3DERR_INVALIDCALL)
{
}
will always execute the code inside. it''s because the = actually returns the value. so HRESULT becomes D3DERR_INVALIDCALL, and that is returned to the IF, evaluates to true, and writes to the log..
so change those too while you''re at it
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement