mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 16:19:41 +00:00
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
|
// update input
|
||||||
mEnvironment.getInputManager()->update(frametime, false);
|
mEnvironment.getInputManager()->update(frametime, false);
|
||||||
|
|
||||||
// When the window is minimized, pause everything. Currently this *has* to be here to work around a MyGUI bug.
|
// 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.
|
// 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),
|
||||||
//if (!mOgre->getWindow()->isActive() || !mOgre->getWindow()->isVisible())
|
// and destroyed widgets will not be deleted (not fixed yet, https://github.com/MyGUI/mygui/issues/21)
|
||||||
// return true;
|
if (!mEnvironment.getInputManager()->isWindowVisible())
|
||||||
|
return;
|
||||||
|
|
||||||
// sound
|
// sound
|
||||||
if (mUseSound)
|
if (mUseSound)
|
||||||
|
@ -689,9 +690,16 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
frame(dt);
|
frame(dt);
|
||||||
|
|
||||||
mViewer->eventTraversal();
|
if (!mEnvironment.getInputManager()->isWindowVisible())
|
||||||
mViewer->updateTraversal();
|
{
|
||||||
mViewer->renderingTraversals();
|
OpenThreads::Thread::microSleep(5000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mViewer->eventTraversal();
|
||||||
|
mViewer->updateTraversal();
|
||||||
|
mViewer->renderingTraversals();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save user settings
|
// Save user settings
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace MWBase
|
||||||
|
|
||||||
virtual ~InputManager() {}
|
virtual ~InputManager() {}
|
||||||
|
|
||||||
|
virtual bool isWindowVisible() = 0;
|
||||||
|
|
||||||
virtual void update(float dt, bool disableControls, bool disableEvents=false) = 0;
|
virtual void update(float dt, bool disableControls, bool disableEvents=false) = 0;
|
||||||
|
|
||||||
virtual void changeInputMode(bool guiMode) = 0;
|
virtual void changeInputMode(bool guiMode) = 0;
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace MWInput
|
||||||
const std::string& userFile, bool userFileExists,
|
const std::string& userFile, bool userFileExists,
|
||||||
const std::string& controllerBindingsFile, bool grab)
|
const std::string& controllerBindingsFile, bool grab)
|
||||||
: mWindow(window)
|
: mWindow(window)
|
||||||
|
, mWindowVisible(true)
|
||||||
, mViewer(viewer)
|
, mViewer(viewer)
|
||||||
, mJoystickLastUsed(false)
|
, mJoystickLastUsed(false)
|
||||||
, mPlayer(NULL)
|
, mPlayer(NULL)
|
||||||
|
@ -156,6 +157,11 @@ namespace MWInput
|
||||||
delete mVideoWrapper;
|
delete mVideoWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InputManager::isWindowVisible()
|
||||||
|
{
|
||||||
|
return mWindowVisible;
|
||||||
|
}
|
||||||
|
|
||||||
void InputManager::setPlayerControlsEnabled(bool enabled)
|
void InputManager::setPlayerControlsEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
int nPlayerChannels = 17;
|
int nPlayerChannels = 17;
|
||||||
|
@ -850,7 +856,7 @@ namespace MWInput
|
||||||
|
|
||||||
void InputManager::windowVisibilityChange(bool visible)
|
void InputManager::windowVisibilityChange(bool visible)
|
||||||
{
|
{
|
||||||
//TODO: Pause game?
|
mWindowVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManager::windowResized(int x, int y)
|
void InputManager::windowResized(int x, int y)
|
||||||
|
|
|
@ -83,6 +83,8 @@ namespace MWInput
|
||||||
|
|
||||||
virtual ~InputManager();
|
virtual ~InputManager();
|
||||||
|
|
||||||
|
virtual bool isWindowVisible();
|
||||||
|
|
||||||
/// Clear all savegame-specific data
|
/// Clear all savegame-specific data
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
|
@ -153,6 +155,7 @@ namespace MWInput
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Window* mWindow;
|
SDL_Window* mWindow;
|
||||||
|
bool mWindowVisible;
|
||||||
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
||||||
|
|
||||||
bool mJoystickLastUsed;
|
bool mJoystickLastUsed;
|
||||||
|
|
Loading…
Reference in a new issue