Jump to content

  • Log In with Google      Sign In   
  • Create Account


The drawing is lost when window is minimized


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
6 replies to this topic

#1 Milla.M   Members   -  Reputation: 125

Like
0Likes
Like

Posted 13 July 2012 - 02:45 AM

Hi
I am drawing with directx9, windowed mode. The drawing is in dialog box . The drawing is a simple animation, and the user have option to pause the animation from button click. The problem is following:

1) The animation is paused
2) User minimizes main application
3) when main application window is restored , the drawing is lost i.e the dialog is empty

The drawing is like this ( pseudo code) :
OnBtnClikedPause()
{
	paused = true;
}
bool isRunning= true;
while (isRunning)
{
	MSG msg;
	if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
	{
		if (msg.message == WM_QUIT)
		{
			isRunning= false;
			continue;
		}
	}
	else
	{
		if( ! paused )
		{
			scene.Update();
			BeginScene();
			ClearBuffers();
			Draw();
			EndScene();
			Present();
		}
	}
}  
The updating and drawing of the scenegraph is only if the animation is not paused.

If I change the code , so that I am drawing all the time and only updating if not paused , then I am no longer seeing this problem when restoring back :
if( !paused )
{
   scene.Update();
}
BeginScene();
ClearBuffers();
Draw();
EndScene();
Present();


So I don't get it why the rendering in the dialog is lost ?
anyone have idea how to solve the problem without drawing all the time

Sponsor:

#2 Mussi   Crossbones+   -  Reputation: 1578

Like
0Likes
Like

Posted 13 July 2012 - 05:25 AM

You're dealing with a lost device, you'll need to draw at least once to get something back up on the screen next to reloading specific resources. You can find more info on the topic here.

#3 Milla.M   Members   -  Reputation: 125

Like
0Likes
Like

Posted 13 July 2012 - 05:46 AM

You're dealing with a lost device, you'll need to draw at least once to get something back up on the screen next to reloading specific resources. You can find more info on the topic here.


I don't get lost device cause I am checking the return value of Present and throwing exception if it returns that the device is lost, and I don't get exception at all

#4 Mussi   Crossbones+   -  Reputation: 1578

Like
0Likes
Like

Posted 13 July 2012 - 05:54 AM

May have jumped to a conclusion too soon. You could try rendering your scene once after the window gets restored by handling the WM_SIZE message.

#5 Milla.M   Members   -  Reputation: 125

Like
0Likes
Like

Posted 13 July 2012 - 06:06 AM

Thank you for the suggestion I will do that. But I still don't get why this re-rendering in WM_SIZE is needed at all. Once the drawing is displayed in the window it should stay on the window right ?

#6 Mussi   Crossbones+   -  Reputation: 1578

Like
0Likes
Like

Posted 13 July 2012 - 06:54 AM

If the device is not lost I'd assume it would. Maybe it's the window that needs to repaint, you could try UpdateWindow whenever you detect the window is being restored.

#7 Interminable   Members   -  Reputation: 127

Like
0Likes
Like

Posted 13 July 2012 - 07:17 AM

I don't claim to be too knowledgeable here and this may be a dumb question but...when you restore your window, you say it's not drawing anything with your first piece of pseudo code (where functions like Draw(), etc are in the if(!paused) braces). Have you tried debugging it line by line? Is that paused variable still set to true when you restore it? If paused is still set to true then it won't redraw anything until you change that paused flag to false.

I hope this helps. ><




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