• Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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;
		      g_engine->p_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm);
              D3DPRESENT_PARAMETERS pa;
              
              pa.Windowed = true;
              pa.hDeviceWindow = g_engine->getWindowHandle();
              pa.SwapEffect = D3DSWAPEFFECT_DISCARD;
              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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
Share on other sites

Damn..still doesn't work.I added this:

 

 

 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 this post


Link to post
Share on other sites

Damn..still doesn't work.I added this:
 
 
 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

Share this post


Link to post
Share on other sites
You need to call the objects OnLostDevice before running the Reset, then OnResetDevice after. Also Release and recreate any stateblocks you may be using, and reset all your render/texture stage/sampler states to their defaults too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement