I am just beginning to learn how to program DirectX 9 applications in C++, so I'm still not very good, and I'm messing it around quite a bit.
When I reopen the program after it crashes, the D3D Device fails to create with the result being D3DERR_INVALIDCALL. I am compiling with G++ in MinGW, using the DirectX August 2009 SDK. I'm guessing it's because I didnt release all the Devices and Textures etc when it crashes, and it still thinks I'm using them. It re-opens on a restart. Would someone be able to point me in the right direction as to how to sortof "reset" DirectX?
Here is what I am using to create the device:
D3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS D3DPP;
ZeroMemory(&D3DPP, sizeof(D3DPP));
D3DPP.Windowed = TRUE;
D3DPP.SwapEffect = D3DSWAPEFFECT_DISCARD;
D3DPP.hDeviceWindow = hWnd;
D3DPP.BackBufferFormat = D3DFMT_X8R8G8B8;
D3DPP.BackBufferWidth = WIDTH;
D3DPP.BackBufferHeight = HEIGHT;
D3DDevice = 0; //Null pointer to make sure I can check it
HRESULT hr = D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &D3DPP, &D3DDevice);
if (!D3DDevice) {
MessageBox(NULL,"Device could not be created","error",0);
switch (hr) {
case D3DERR_DEVICELOST:
MessageBox(NULL,"1","error",0);
break;
case D3DERR_INVALIDCALL:
MessageBox(NULL,"2","error",0);
break;
case D3DERR_NOTAVAILABLE:
MessageBox(NULL,"3","error",0);
break;
case D3DERR_OUTOFVIDEOMEMORY:
MessageBox(NULL,"4","error",0);
break;
};
return 1;
};
return 0;
Thanks.