# Backbuffer crashes on resize

This topic is 1797 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to make the backbuffer get resized when the window gets resized.Here's the code:

case WM_SIZE:

int mClientWidth  = LOWORD(lParam);
int mClientHeight = HIWORD(lParam);

g_engine->setScreenHeight(mClientHeight);
g_engine->setScreenWidth(mClientWidth);
if(g_engine->p_device){
D3DDISPLAYMODE dm;
D3DPRESENT_PARAMETERS pa;

pa.Windowed = true;
pa.hDeviceWindow = g_engine->getWindowHandle();
pa.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
pa.BackBufferFormat = dm.Format;
pa.BackBufferCount = 1;
pa.MultiSampleType = D3DMULTISAMPLE_NONE;
pa.MultiSampleQuality = 0;
pa.EnableAutoDepthStencil = true;
pa.AutoDepthStencilFormat = D3DFMT_D16;

pa.FullScreen_RefreshRateInHz = 0;

pa.BackBufferWidth = mClientWidth;
pa.BackBufferHeight = mClientHeight;
g_engine->p_device->Reset(&pa);

}
break;
}



I can't understand what's wrong!

##### Share on other sites

I think your issue is more then likely that you are not calling  the OnResetDevice for your various Directx Objects.

"Before calling the IDirect3DDevice9::Reset method for a device, an application should release any explicit render targets, depth stencil surfaces, additional swap chains, state blocks, and D3DPOOL_DEFAULT resources associated with the device."

I actually call my OnResetDevice calls after I do the reset, and it doesnt seem to bother my app. However thats what the MSDN says...

##### Share on other sites

Aside from what Michael already said, have you tried setting breakpoints in Visual Studio?  If the above post is not the problem, try setting a breakpoint before you reset your Direct3D device and trace each step to find out where your crash occurs.  Also, are you running the debug or release version of Direct3D?  Try running in debug mode in Direct3D and Visual Studio, then check the debug output window for any Direct3D specific messages.

Shogun.

##### Share on other sites

g_engine->getSpriteHandler()->OnResetDevice();

g_engine->p_device->Reset(&pa);

I don't understand on which objects I should call onresetdevice,i mean I don't have any other dx objects except direct input,and that one doesn't have a onreset function!
Edited by noatom

##### Share on other sites

g_engine->getSpriteHandler()->OnResetDevice();

g_engine->p_device->Reset(&pa);

I don't understand on which objects I should call onresetdevice,i mean I don't have any other dx objects except direct input,and that one doesn't have a onreset function!

Anything that is created in D3DPOOL_DEFAULT needs to be reset as it is living on the GPU and isn't aware they you reset the device. This is why you mostly load textures in to D3DPOOL_MANAGED as the runtime can then reupload the image when a reset occurs. Edited by NightCreature83