Why resizing window causes OnCreateDevice() to be invoked?

Started by
3 comments, last by xujiezhige 12 years, 1 month ago
I'm very confused. Why?
I have built my project like the sample in DXSDK.

I find it does invoke OnCreateDevice() when I trace the path of the program.
Have you met it ?
Advertisement
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()?
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
There's no "hard", and "the impossible" takes just a little time.
Hi!

Maybe you would read this thread:
http://forums.create...ms/t/71798.aspx

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)
Thank you, [color="#284b72"]programci_84 and [color="#284b72"]kubera.smile.png

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

This topic is closed to new replies.

Advertisement