Sign in to follow this  
xujiezhige

Why resizing window causes OnCreateDevice() to be invoked?

Recommended Posts

I solve it!

I move a CloneMesh() function which is in OnCreateDevice() originally to OnResetDevice(), and release it in OnLostDevice().

Is that because not all memory in POOL_DEFAULT are released, then DXUT will return to call OnDestroyDevice() and OnCreateDevice()?

Share this post


Link to post
Share on other sites
Basically, if you change some properties defined in D3DPRESENT_PARAMETERS object (like auto depth buffer usage, window dimensions etc.), it's recommended to reset your device. You don't have to do that for resizing, but, for example, if you resize the window in windowed mode and if you don't reset the device, rendered image may be distorted each time you resized the window. If you want to change device properties (e.g. Vertex Processing: like switching from H/W to Pure HW, Device Type: like switching HAL to REF), you must release your device then recreate.

Before you reset or release the device, you must release all the memory but in D3DPOOL_MANAGED (e.g. D3DXLoadMeshFromX function creates meshes in D3DPOOL_MANAGED). After resetting or recreating, you must recreate corresponding memory.

hth.
-R

Share this post


Link to post
Share on other sites
[b]Hi![/b]

Maybe you would read this thread:
[url="http://forums.create.msdn.com/forums/t/71798.aspx"]http://forums.create...ms/t/71798.aspx[/url]

Another reason for recreating the device would be an unreleased interface from previous device state.
(simply something was not released on LostDevice callback and D3D forces recreation because of the invalid state)

Share this post


Link to post
Share on other sites
Thank you, [url="http://www.gamedev.net/user/151330-programci_84/"][color="#284b72"]programci_84[/color][/url] and [url="http://www.gamedev.net/user/195749-kubera/"][color="#284b72"]kubera[/color][/url].[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I think the circumstance presented by kubrea is same to mine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this