Jump to content
  • Advertisement
Sign in to follow this  

g_pd3dDevice-Reset doesn't work ???

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

Hello, I made a program in which I treat the loss of the device in the event of ALT+TAB for example. But in this precise case that does not work. Perhaps is this due to the fact that the object is created dynamically? -- Bloc * blocJ1enCours; void render() { p_Application->g_pd3dDevice->BeginScene(); p_Application->g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(169,171,255), 1.0f, 0 ); if (blocJ1enCours!=NULL) { blocJ1enCours->texture->Release(); delete blocJ1enCours; }; blocJ1enCours = new Bloc; blocJ1enCours->setLetterTexture(&p_Application->g_pd3dDevice, menu.theme); ( call create sprite and createtexturefromfile) blocJ1enCours->translation.x = TableauJoueurs[j]->translation.x + 16; blocJ1enCours->translation.y = TableauJoueurs[j]->translation.y + 8; if (blocJ1enCours!=NULL) { blocJ1enCours->Draw(false); }; p_Application->g_pd3dDevice->EndScene(); if (p_Application->g_pd3dDevice->Present( NULL, NULL, NULL, NULL ) == D3DERR_DEVICELOST ) { Sleep( 100 ); HRESULT hr; if( FAILED( hr = p_Application->g_pd3dDevice->TestCooperativeLevel() ) ) { if( hr == D3DERR_DEVICELOST ) return; // Le device est perdu mais il peut-être réinitialisé if( hr == D3DERR_DEVICENOTRESET ) { if (blocJ1enCours->texture != NULL) { blocJ1enCours->texture->Release(); blocJ1enCours->texture=NULL; delete blocJ1enCours; }; hr = p_Application->g_pd3dDevice->Reset(&p_Application->d3dpp); if( FAILED(hr ) ) return; }; }; } but if I remove the call to Draw it works????? Thank you for your assistance, I am really blocked...

Share this post


Link to post
Share on other sites
Advertisement
Have you tried using the debug runtimes? (see NeXe: Debugging) usually for this sort of thing it'll throw you a warning/error message telling you why it couldn't reset the device.

At a guess, it might be because the target window hasn't fully restored yet (after an alt-tab)?

hth
Jack

Share this post


Link to post
Share on other sites
Hi,

Switch on the Debug DirectX in the Control Panel set logging to maximum and the other options on, and then look at the debug output when you call Reset(). It usually tells you why isn't it working. (I don't Release() something in most cases, maybe you do the same)

Peter

Share this post


Link to post
Share on other sites
Thank for your answers,

I will test the debug mode. What is odd it is that I have really the impression that it is because of the new... Because with static objects it goes...

I will update the post if I find

Share this post


Link to post
Share on other sites
Sorry but I am really too bad...

1 - I believe that my SDK does not have the debug runtime.
2 - I'm unable of debug anything with my application in fullscreen mode
3 - My wife leaves me one day to find the Bug.

The positive point it is that I succeeded in seeing that my function reset return a d3derr_invalidcall.

Share this post


Link to post
Share on other sites
Okay first of all before resetting device you must release all device objects if you aren't using D3DPOOL_MANAGED with your resources. When using MANAGED flag the DirectX will handle it for you, but if you use D3DPOOL_DEFAULT you must first release the objects (vertex buffer, index buffers, textures, etc.) and then restart, after restarting you also have to restore them, so I suggest that you use D3DPOOL_MANAGED.

Share this post


Link to post
Share on other sites
Not directly a bug, but:

Check, if BeginScene succeeds, and only if it does actually render something and call EndScene.
Also, before releasing the texture make sure it's not set in one of the stages.

Share this post


Link to post
Share on other sites
All my resources use D3DPOOL_MANAGED like

D3DXCreateSprite( *d3dDevice, &sprite );

D3DXCreateTextureFromFileEx( *d3dDevice, nomfic, 0, 0, 1, 0,
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_DEFAULT,
couleurTrans, &imageInfo, NULL, &texture);

Share this post


Link to post
Share on other sites
I release texture after the call of EndScene

p_Application->g_pd3dDevice->EndScene();

if (p_Application->g_pd3dDevice->Present( NULL, NULL, NULL, NULL ) == D3DERR_DEVICELOST )
{
Sleep( 100 );

HRESULT hr;
if( FAILED( hr = p_Application->g_pd3dDevice->TestCooperativeLevel() ) )
{
if( hr == D3DERR_DEVICELOST )
return;

if( hr == D3DERR_DEVICENOTRESET )
{
hr = p_Application->g_pd3dDevice->Reset(&p_Application->d3dpp);
if( FAILED(hr) )
{
return;
}
}
}

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!