Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Xeno

Problems in Reseting D3D8 Device

This topic is 6143 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! Im try to reset my D3d8 device when my full-screen app going out of focus , but for some reason im getting an error message that the D3D8 DLL produce , im using the code below , anyone can think whats wrong in the code? Just to note that the d3dpp stracture is the D3DPRESENT_PARAMETERS stracture i used to create the device , then , i dont believe theres a problem with that. Thanks.
    
	hr = lp_d3d8_device->Present(NULL,NULL,NULL,NULL);

	if(hr == D3DERR_DEVICELOST)
	{
		hr = lp_d3d8_device->TestCooperativeLevel();
		while(hr == D3DERR_DEVICELOST)
			hr = lp_d3d8_device->TestCooperativeLevel();
		

		hr = lp_d3d8_device->Reset(&d3dpp);
		if(FAILED(hr))
			return hr;
        }
    
Edited by - xeno on November 20, 2001 4:35:50 PM

Share this post


Link to post
Share on other sites
Advertisement
Not sure but I think you can only call reset if the following is true.

(DXDisplay->TestCooperativeLevel() == D3DERR_DEVICENOTRESET)

And you should test this before doing present. ie

  
BOOL OK=TRUE;
////////////////////////////////////////////////////

// lost device, see if ok to reset

if( (DXDisplay->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) )
{
OK = SUCCEEDED(DXDisplay->Reset(&DisplayParams));
}

//////////////////////////////////////////////////////

// Clear the back buffer to a blue/rand colour

if( FALSE == OK ) return;

// now do your drawing.



see if this fixes it?

[The views stated herein do not necessarily represent the view of the company Eurocom ]

Eurocom Entertainment Software
www.Eurocom.co.uk

The Jackal

Share this post


Link to post
Share on other sites
.-In your application loop do this:
//PSEUDOCODE:

HRESULT hr=Device->TestCooperativeLevel();
if(hr==DEVICE_LOST)
{
ReleaseDeViceObjects();
Pause();
m_bActive=false;
return;
}
if(hr==DEVICENOTRESET)
{
Device->Reset(d3dpp);
RestoreDeviceObjects();
UnPause();
m_bActive=true;
}

.-The thing is: when the device is lost->Release the device objects. When the device is notreset->reset it ans restore the device objects.



What the hells!

Share this post


Link to post
Share on other sites
Grugnorr , i tried what you have said , and it works when im creare my vertex buffer with D3DPOOL_MANAGED , but when i change it to D3DPOOL_DEFAULT , and its gives me the error message , whats wrong?

Share this post


Link to post
Share on other sites
quote:
Original post by Xeno
Grugnorr , i tried what you have said , and it works when im creare my vertex buffer with D3DPOOL_MANAGED , but when i change it to D3DPOOL_DEFAULT , and its gives me the error message , whats wrong?


You must release the memory used in your objects allocated by D3DPOOL_DEFAULT before calling reset. That explains your error message.

D3DPOOL_MANAGED always assume that D3D will release all object allocated to it automatically before reset.

Hope it helps.

Share this post


Link to post
Share on other sites
Thats the weird thing , im doing it! .
the only object that uses D3DPOOL_DEFAULT in my app is the vertex buffer , and im releasing it before i call Reset , but it still gives the error message.

im just release it with the ->Release method:
vertex_buffer->Release();

its enough no?

Edited by - xeno on November 21, 2001 6:40:33 PM

Share this post


Link to post
Share on other sites
Trace the output using the debugger message and check which line failed. Was it the Reset () or Release () call?

Did you put your VB as a dynamic or static object. You can''t put as a it managed resource if it''s a dynamic object.

Share this post


Link to post
Share on other sites
.-ReleaseDeviceObjects(), as in the CommonFiles , releases objects from the DEFAULT POOL. I do create everything I can in MANAGED, so the only device objects are: dynamic VB and render targets(as a render target texture).

.-Releasing these objects should be enough, are you sure all of them are released BEFORE calling Reset()?

What the hells!

Share this post


Link to post
Share on other sites

  • 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!