Jump to content
  • Advertisement
Sign in to follow this  
xujiezhige

Why resizing window causes OnCreateDevice() to be invoked?

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

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 ?

Share this post


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

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

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!