Jump to content
  • Advertisement
Sign in to follow this  
Milla.M

The drawing is lost when window is minimized

This topic is 2262 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

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. ><

Share this post


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

  • 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!