Jump to content
  • Advertisement
Sign in to follow this  
dtanh

How to fix D3DERR_SCENE_IN_SCENE?

This topic is 3905 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

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.

Share this post


Link to post
Share on other sites
Advertisement
I think I should call EndScene() right before the screen solution changes but I can not find any windows message related to that event.

Share this post


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

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...

Share this post


Link to post
Share on other sites
Thank you, but my problem is


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 :(

Share this post


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

Share this post


Link to post
Share on other sites
Yeah, you're right! There's something in my loop that interrupts the EndScene() call when I change the screen solution.
Thank you very much for your suggestion. :)

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!