Jump to content
  • Advertisement
Sign in to follow this  
godsenddeath

D3D device pointer somehow becomes invalid??

This topic is 3938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

__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;

}




Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);
}






Share this post


Link to post
Share on other sites
HRESULT hr = d3d->CreateDevice(...);

Set a breakpoint right after it in the debugger and check the value of hr.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!