Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Plague1392

Surface Restore Error - Please Help

This topic is 5883 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’ve recently started DirectX programming and have just written my first game. It works fine apart from when I Alt-Tab and restore the game, at which point it crashes. I searched the forum for similar posts to see if anyone had had a similar problem but unfortunately my problem seems different to the many other issues people have had with this. I’m using the WM_SIZE message to see if the game has been minimised:
  
case WM_SIZE:
{	
	if (wparam == SIZE_MINIMIZED)  
	{
		RunGameMain = false;
	}
	else if ((wparam == SIZE_MAXIMIZED) || (wparam == SIZE_RESTORED))
	{
		RunGameMain = true;
		ReloadSurfacaes = true;
		if (lpDDSurfacePrimary && lpDDSurfacePrimary->IsLost())
			lpDDSurfacePrimary->Restore();
		if (lpDDSurfaceBack && lpDDSurfaceBack->IsLost())
			lpDDSurfaceBack->Restore();
	}
	return(0);
}break;
  
I’ve got the below code to stop the GameMain() being run when it’s minimised: if (RunGameMain) GameMain(); At the top of GameMain() I’ve got some code to restore the off screen surfaces used in the introduction, title screen and game:
  
if (ReloadSurfacaes)
{
	if (Game)
		Game->RestoreSurfaces();
	else if (Title)
		Title->RestoreSurfaces();
	else if (Intro)
		Intro->RestoreSurfaces();

	ReloadSurfacaes = false;
}
  
Finally, here’s an example of one of the functions called to restore the surfaces:
  
void CTitle::RestoreSurfaces()
{
	if (PressStartSurfance && PressStartSurfance->IsLost())
	{
		PressStartSurfance->Restore();
		DDReLoadBitmap(PressStartSurfance, 
			       MAKEINTRESOURCE(F_TITLESC_PRESS_ST_TXT));
	}
	if (SnowManSurface && SnowManSurface->IsLost())
	{
		SnowManSurface->Restore();
		DDReLoadBitmap(SnowManSurface, 
			       MAKEINTRESOURCE(F_TITLESC_SMAN))
	}
	if (TextTitleSurface && TextTitleSurface->IsLost())
	{
		TextTitleSurface->Restore();
		DDReLoadBitmap(TextTitleSurface, 
			       MAKEINTRESOURCE(F_TITLESC_TEXT_TITLE))
	}
}
  
When I Alt-Tab to minimise the application the game stops running and everything seems fine, but unfortunately when I maximise the application I just get a black screen. In debug I get the following output. Direct3D8: (ERROR) :Cannot restore surface, in the middle of a mode change Direct3D8: (ERROR) :Can''t restore implicitly created surfaces Direct3D8: (INFO) :NOT Setting DDCAPS_BANKSWITCHED Direct3D8: (INFO) :Mode was never changed by this app Direct3D8: (WARN) :Cannot restore surface, not in original mode Direct3D8: (ERROR) :Can''t restore implicitly created surfaces Direct3D8: (WARN) :Cannot restore surface, not in original mode Direct3D8: (WARN) :Cannot restore surface, not in original mode ddcopybitmap failed I thought it might be a problem with the primary and back buffer surfaces being restored before the application had maximized so I moved the code to restore these two surfaces to the if (ReloadSurfacaes) bit in GameMain. This changed the debug output slightly (the first two errors go) but it’s still producing a similar problem. Direct3D8: (INFO) :NOT Setting DDCAPS_BANKSWITCHED Direct3D8: (INFO) :Mode was never changed by this app Direct3D8: (WARN) :Cannot restore surface, not in original mode Direct3D8: (ERROR) :Can''t restore implicitly created surfaces Direct3D8: (WARN) :Cannot restore surface, not in original mode Direct3D8: (WARN) :Cannot restore surface, not in original mode ddcopybitmap failed Any idea what I’m doing wrong? I can’t work it out at all. Thanks a lot for any help you can offer. -- Plague1392

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!