forked from mirror/openmw-tes3mp
Stop rendering when the window is minimized
This commit is contained in:
parent
7a96a04b75
commit
d11952c48a
4 changed files with 27 additions and 8 deletions
|
@ -92,10 +92,11 @@ void OMW::Engine::frame(float frametime)
|
|||
// update input
|
||||
mEnvironment.getInputManager()->update(frametime, false);
|
||||
|
||||
// When the window is minimized, pause everything. Currently this *has* to be here to work around a MyGUI bug.
|
||||
// If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures.
|
||||
//if (!mOgre->getWindow()->isActive() || !mOgre->getWindow()->isVisible())
|
||||
// return true;
|
||||
// When the window is minimized, pause the game. Currently this *has* to be here to work around a MyGUI bug.
|
||||
// If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures (fixed in MyGUI 3.3.2),
|
||||
// and destroyed widgets will not be deleted (not fixed yet, https://github.com/MyGUI/mygui/issues/21)
|
||||
if (!mEnvironment.getInputManager()->isWindowVisible())
|
||||
return;
|
||||
|
||||
// sound
|
||||
if (mUseSound)
|
||||
|
@ -689,9 +690,16 @@ void OMW::Engine::go()
|
|||
|
||||
frame(dt);
|
||||
|
||||
mViewer->eventTraversal();
|
||||
mViewer->updateTraversal();
|
||||
mViewer->renderingTraversals();
|
||||
if (!mEnvironment.getInputManager()->isWindowVisible())
|
||||
{
|
||||
OpenThreads::Thread::microSleep(5000);
|
||||
}
|
||||
else
|
||||
{
|
||||
mViewer->eventTraversal();
|
||||
mViewer->updateTraversal();
|
||||
mViewer->renderingTraversals();
|
||||
}
|
||||
}
|
||||
|
||||
// Save user settings
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace MWBase
|
|||
|
||||
virtual ~InputManager() {}
|
||||
|
||||
virtual bool isWindowVisible() = 0;
|
||||
|
||||
virtual void update(float dt, bool disableControls, bool disableEvents=false) = 0;
|
||||
|
||||
virtual void changeInputMode(bool guiMode) = 0;
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace MWInput
|
|||
const std::string& userFile, bool userFileExists,
|
||||
const std::string& controllerBindingsFile, bool grab)
|
||||
: mWindow(window)
|
||||
, mWindowVisible(true)
|
||||
, mViewer(viewer)
|
||||
, mJoystickLastUsed(false)
|
||||
, mPlayer(NULL)
|
||||
|
@ -156,6 +157,11 @@ namespace MWInput
|
|||
delete mVideoWrapper;
|
||||
}
|
||||
|
||||
bool InputManager::isWindowVisible()
|
||||
{
|
||||
return mWindowVisible;
|
||||
}
|
||||
|
||||
void InputManager::setPlayerControlsEnabled(bool enabled)
|
||||
{
|
||||
int nPlayerChannels = 17;
|
||||
|
@ -850,7 +856,7 @@ namespace MWInput
|
|||
|
||||
void InputManager::windowVisibilityChange(bool visible)
|
||||
{
|
||||
//TODO: Pause game?
|
||||
mWindowVisible = visible;
|
||||
}
|
||||
|
||||
void InputManager::windowResized(int x, int y)
|
||||
|
|
|
@ -83,6 +83,8 @@ namespace MWInput
|
|||
|
||||
virtual ~InputManager();
|
||||
|
||||
virtual bool isWindowVisible();
|
||||
|
||||
/// Clear all savegame-specific data
|
||||
virtual void clear();
|
||||
|
||||
|
@ -153,6 +155,7 @@ namespace MWInput
|
|||
|
||||
private:
|
||||
SDL_Window* mWindow;
|
||||
bool mWindowVisible;
|
||||
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
||||
|
||||
bool mJoystickLastUsed;
|
||||
|
|
Loading…
Reference in a new issue