D3D device pointer somehow becomes invalid??

Started by
13 comments, last by legalize 16 years, 6 months ago
__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.



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;

}




--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
Advertisement
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.
Ra
what would the return be if there's an error? a non-zero number?

--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
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.
Ra
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


--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
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.
Ra
thi may be a dumb question, but how would i check for the accual return value?

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);	}



--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
HRESULT hr = d3d->CreateDevice(...);

Set a breakpoint right after it in the debugger and check the value of hr.
Ra
the result was hr -2005530516 HRESULT

--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
0x8876086c

the corresponding constant is D3DERR_INVALIDCALL which means nothing to me :s
--------------------------------------Not All Martyrs See Divinity, But At Least You Tried

This topic is closed to new replies.

Advertisement