Skip to main content
GameDev.net gamedev.net
🔒 Locked

window freezes after minimizing

Started by clowkun Oct 22, 2009 at 12:59 AM 7 replies 2k views
Original Post
clowkun
clowkun
Hello, I am experiencing a problem with my simple wrapper of DirectX June 2007. I can render textures but if I minimize the window the program crashes. This problem only happens once I've cleared my render target before drawing and also with using my swap buffers function. Can anyone tell me why my window decides to lag when I start to render? The code I'm using besides it being in a class is exactly copied from the Wendy Jones book I am using. Any help would be greatly appreciated.
Cal State Fullerton,Computer Science Student-----Just want to learn.
Armadon
Armadon
Are you handling null reference exceptions?
Meaning, if the texture/model or any asset is null, are you still trying to render the object?
The most common problem is that you might not be handling a lost device, whereby assets such as texture/models might bave been lost and have to be re-created.
clowkun
clowkun
As far as I know, I am only working with just one texture that is being used properly I believe. This is my code:

Game::Game(GameGraphics *myG){	myGraphics = myG;	background = NULL;}Game::~Game(){	delete background;}void Game::LoadGame(){	// code for loading the gameplay components needed	background = new GameTexture(640, 480);}void Game::InitializeGame(){	// code to begin giving gameplay components actual value		int i = background->GetTexture2DFromFile(&(myGraphics->getD3DDevice()), texture1);	if(i == 1)	{		exit(0);	}	}void Game::UpdateGame(){	// updates gameplay components, based on a number of parameters}void Game::DrawGame(){	// a place for gameplay components to render themselves to the screen	background->ViewTexture(&(myGraphics->getD3DDevice()), &(myGraphics->getSwapChain()), (myGraphics->getAppWidth()), (myGraphics->getAppHeight()));}
Cal State Fullerton,Computer Science Student-----Just want to learn.
clowkun
clowkun
I am also getting this strange message from the debugger about my HWND used in the swap_chain_desc structure:

mainhWnd	0x000d05f0 {unused=??? }


wondering if maybe that is a problem
Cal State Fullerton,Computer Science Student-----Just want to learn.
clowkun
clowkun
looking at:

http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2007-07/msg01220.html

started me thinking and looking at the debugger for my current program
and an older version has helped me find a more specific problem, my window handle has the property unused=??? or junk and not some number when other programs do.

i don't get it because it seems like i'm doing everything right like the other program, any suggestions on fixing this?
Cal State Fullerton,Computer Science Student-----Just want to learn.
munawar
munawar
Hi,
I'm not sure if this would apply to C++, but in .NET you get this problem if you don't run a message loop on the GUI form. If you are using C++.NET, try calling your form using
System.Windows.Forms.Application.Run(System.Windows.Forms.Form);


The only disadvantage to doing this is that the message loop starts in the main thread, so you'll need to spawn a new thread to continue the program and have the message loop run at the same time if there's more code beyond your initialization code. Either way, this call will prevent the form (and thus the window handle) from being destroyed when you push focus of the window into the background.
Evil Steve
Evil Steve
Quote:
Original post by clowkun
I am also getting this strange message from the debugger about my HWND used in the swap_chain_desc structure:

mainhWnd	0x000d05f0 {unused=??? }


wondering if maybe that is a problem
That's normal. You're seeing a side effect of the way the SDK has handles defined (They're structs with a pointer sized member), it's nothing to worry about.

When you say your app crashes, what is the exact error? What line of code does the debugger point to? What do the Debug Runtimes say?
clowkun
clowkun
The debugger doesn't give me an error. The program runs, but it is only when I minimize the window and then try to bring the window back, then the program stalls and the title bar of the window says (Not Responding).
Cal State Fullerton,Computer Science Student-----Just want to learn.
clowkun
clowkun
Just in case anyone else is looking into this subject. I did not really find a good solution but what I did do was just not wrap the creation of the ID3D10Device and everything else with it. I just used functions and everything now seems to run a bit faster. I am continuing asking questions about runtime speeds and windows minimization lagging in this post here:

http://www.gamedev.net/community/forums/topic.asp?topic_id=552614
Cal State Fullerton,Computer Science Student-----Just want to learn.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.