Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


Backbuffer crashes on resize


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 16 February 2013 - 02:10 PM

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!



Sponsor:

#2 MichaelNIII   Members   -  Reputation: 195

Like
0Likes
Like

Posted 16 February 2013 - 06:57 PM

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



#3 blueshogun96   Crossbones+   -  Reputation: 1050

Like
1Likes
Like

Posted 16 February 2013 - 07:32 PM

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.


Follow Shogun3D on the official website: http://shogun3d.net

 

blogger.png twitter.png tumblr_32.png facebook.png

 

"Yo mama so fat, she can't be frustum culled." - yoshi_lol


#4 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 17 February 2013 - 01:22 AM

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, 17 February 2013 - 03:38 AM.


#5 NightCreature83   Crossbones+   -  Reputation: 2933

Like
0Likes
Like

Posted 17 February 2013 - 03:09 PM

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, 17 February 2013 - 03:11 PM.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#6 mhagain   Crossbones+   -  Reputation: 8140

Like
1Likes
Like

Posted 17 February 2013 - 03:25 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS