How to fix D3DERR_SCENE_IN_SCENE?
Hi all, when I change my screen solution and then call IDirect3DDevice7::BeginScene method, it returns D3DERR_SCENE_IN_SCENE error. I think that this problem is caused when the previous scene is not ended properly but I don't know how to end a scene just before the screen solution changes.
Please help me with this.
Thank you very much.
I think I should call EndScene() right before the screen solution changes but I can not find any windows message related to that event.
There's no way you should be able to change screen resolution from with the BeginScene..EndScene block, because you shouldn't be calling Present or TestCooperativeLevel to check if the device needs reset, and you shouldn't be calling Reset either.
The only calls you should be making in a BeginScene..EndScene block are rendering related. You shouldn't be doing anything else at all.
Your render loop should look like:
EDIT: Also, is there any reason you're using DX7? It's over 8 years old...
The only calls you should be making in a BeginScene..EndScene block are rendering related. You shouldn't be doing anything else at all.
Your render loop should look like:
HRESULT hResult = pDevice->TestCooperativeLevel();if(FAILED(hResult)){ // Handle lost device, device not reset, and any other errors}else{ if(SUCCEEDED(pDevice->BeginScene())) { // Rendering here pDevice->EndScene(); hResult = pDevice->Present(); if(FAILED(hResult)) { // Handle lost device, device not reset, and any other errors } }}
EDIT: Also, is there any reason you're using DX7? It's over 8 years old...
Thank you, but my problem is
Since the project I'm working on is very old so I must still use DirectX 7 :(
HRESULT hr = pDevice->BeginScene();if(SUCCEEDED(hr)){...}else if (hr == D3DERR_SCENE_IN_SCENE){ // This happen when I change the screen solution and // what should I do here?}
Since the project I'm working on is very old so I must still use DirectX 7 :(
The only reason you'll get D3DERR_SCENE_IN_SCENE is if you call BeginScene() twice without an EndScene() between them. That means that in your code, you must have not called EndScene() before that call to BeginScene(). You should (Usually) have one BeginScene()..EndScene() block, which makes me think you're not finishing a frame properly.
If your render loop looks like the one I posted, it's not possible to miss an EndScene().
Can we see your entire render loop (With the actual rendering and any other irrelevant stuff removed)?
If your render loop looks like the one I posted, it's not possible to miss an EndScene().
Can we see your entire render loop (With the actual rendering and any other irrelevant stuff removed)?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement