void RenderReset()
{
HRESULT hr;
if(Run) RenderFreeResource();
if(FAILED(hr = Direct3DDevice->Reset(&D3DPresentParam)))
{
if(hr == D3DERR_DEVICELOST)
{
DeviceLost = true;
return;
} else Error("Direct 3D reset failed", hr, true);
return;
}
if(Run) RenderLoadResource();
}
IDirect3DDevice9::Reset question
Hi gamedevelopers,
I've programmed a little application in DX9 and I want to manage a possible change in window width/height.
In order to achieve this I catch WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE and make a call to my RenderChangeSize routine.
I calculate the new client RECT and I change these values in my D3DPRESENT_PARAMETERS struct:
D3DPresentParam.BackBufferWidth = WindowClientRect.right - WindowClientRect.left;
D3DPresentParam.BackBufferHeight = WindowClientRect.bottom - WindowClientRect.top;
obviously.
Now I call the Reset routine that is something like:
I've released prior of the calling all the D3DPOOL_DEFAULT resource (a vertex buffer and an index buffer) through RenderFreeResource() and ->Reset gives me this error:
D3DERR_INVALIDCALL
why in earth it could be an invalid call? the D3DPRESENT_PARAMETERS hasn't changed at all (only the width/height wich are valid values) nor the window handle.
I need to do something else other than releasing D3DPOOL_DEFAULT item? These are all the actions I've taken over the graphic driver during initialization time:
->CreateVertexShader(...)
->CreateVertexDeclaration(...)
->SetVertexDeclaration(...)
->SetVertexShader(...)
->SetStreamSource(...)
->SetIndices(...)
->SetVertexShaderConstantF(...)
Quoting msdn:
Before calling the IDirect3DDevice9::Reset method for a device, an application should release any explicit render targets, depth stencil surfaces, additional swap chains, state blocks, and D3DPOOL_DEFAULT resources associated with the device.
I've done all these things? I'm desperated... Sorry for this (for sure) stupid question
Hi there bjogio,
How are you doing?
[What error is the D3DERR_INVALIDCALL?]
The method call is invalid. For example, a method's parameter may have an invalid value.
This might also happen cause you are not allowed to reset the device at this time.
[What can I do?]
1) You might want to check if all your presentParameters are correct.
2) IDirect3DDevice9::TestCooperativeLevel(), check the cooperativelevel until you find D3DERR_DEVICENOTRESET: "The device has been lost but can be reset at this time."
I hope this helps a bit.
If you have any more problems, please dont hesitate to ask and maybe paste a little more of your code.
How are you doing?
[What error is the D3DERR_INVALIDCALL?]
The method call is invalid. For example, a method's parameter may have an invalid value.
This might also happen cause you are not allowed to reset the device at this time.
[What can I do?]
1) You might want to check if all your presentParameters are correct.
2) IDirect3DDevice9::TestCooperativeLevel(), check the cooperativelevel until you find D3DERR_DEVICENOTRESET: "The device has been lost but can be reset at this time."
I hope this helps a bit.
If you have any more problems, please dont hesitate to ask and maybe paste a little more of your code.
Quote:
D3DERR_INVALIDCALL
why in earth it could be an invalid call? the D3DPRESENT_PARAMETERS hasn't changed at all
It didn't say D3DERR_INVALIDPARAMETER it said D3DERR_INVALIDCALL. The parameter is fine only the call is not okay.
A device reset proceeds as follows:
1. Release all device-bound resources you are currently using.
2. Call reset on the device.
3. Wait for the device to become lost; this can be tested using TestSomething() (cannot remember the right name).
4. Recreate the device.
5. Reload the lost resources.
I think you are missing out on step (3) because you immediately recreate the device. Unless this is different in managed DX you should wait a little.
Greetz,
Illco
PS: and because I looked so long for the right call TestSomething() while thinking it was TestCooperativeLevel() I got beaten to it.
When you say the width and height are valid values does it mean you also include this conditional check: (WindowClientRect.right - WindowClientRect.left) > 0 && (WindowClientRect.bottom - WindowClientRect.top) > 0 before you attempt to reset the device?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement