LPDIRECT3DDEVICE9 d3ddev;
void initD3D(HWND hWnd)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&d3ddev);
}
void render_frame()
{
d3ddev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,40,100),1.0f,0);
d3ddev->BeginScene();
d3ddev->EndScene();
d3ddev->Present(NULL,NULL,NULL,NULL);
return;
}
void cleand3d()
{
d3ddev->Release();
d3d->Release();
return;
}
D3D device pointer somehow becomes invalid??
__vfptr = CXX0030: Error: expression cannot be evaluated
this is the error i'm getting when i call Clear() via my LPDIRECT3DDEVICE9
from what i've read this error has something to do with a pointer pointing to an invalid address
here is all the code that affects it or includes it in any way.
Check the return value of CreateDevice (as well as the other calls). It's a HRESULT that indicates whether there was an error or not.
Any value less than 0 is considered failure (HRESULTs are signed). FAILED(hr) is a macro that'll check the HRESULT and give you a boolean value.
oh ok thanks alot, and you were right to look at CreateDevice() , but i'm completly new to DirectX and i have no idea whats wrong with it, i've traced my
D3DPRESENT_PARAMETERS, LPDIRECT3D9 and LPDIRECT3DDEVICE9 all the way down the line and i can't see a problem
D3DPRESENT_PARAMETERS, LPDIRECT3D9 and LPDIRECT3DDEVICE9 all the way down the line and i can't see a problem
What number is the error? Did you look it up in the documentation?
Quote:DirectX SDK - IDirect3DDevice9::CreateDevice()
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_DEVICELOST, D3DERR_INVALIDCALL, D3DERR_NOTAVAILABLE, D3DERR_OUTOFVIDEOMEMORY.
thi may be a dumb question, but how would i check for the accual return value?
all i put was:
all i put was:
if(FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&d3ddev))) { MessageBox(NULL, "Didn't Work", "ERROR", MB_OK|MB_ICONINFORMATION); }
HRESULT hr = d3d->CreateDevice(...);
Set a breakpoint right after it in the debugger and check the value of hr.
Set a breakpoint right after it in the debugger and check the value of hr.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement