Only enable syncing after the first frame due to high initialization load

This commit is contained in:
Alexander Bock
2016-09-24 09:07:15 +02:00
parent e1b2877525
commit 8cf39cdd29
2 changed files with 17 additions and 1 deletions

View File

@@ -172,6 +172,10 @@ private:
// The current state of the countdown; if it reaches '0', the application will close
float _shutdownCountdown;
// The first frame might take some more time in the update loop, so we need to know to
// disable the synchronization; otherwise a hardware sync will kill us after 1 sec
bool _isFirstRenderingFirstFrame;
static OpenSpaceEngine* _engine;
};

View File

@@ -151,6 +151,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
, _isInShutdownMode(false)
, _shutdownCountdown(0.f)
, _shutdownWait(0.f)
, _isFirstRenderingFirstFrame(true)
{
_interactionHandler->setPropertyOwner(_globalPropertyNamespace.get());
_globalPropertyNamespace->addPropertySubOwner(_interactionHandler.get());
@@ -837,6 +838,10 @@ void OpenSpaceEngine::setRunTime(double d){
void OpenSpaceEngine::preSynchronization() {
FileSys.triggerFilesystemEvents();
if (_isFirstRenderingFirstFrame) {
_windowWrapper->setSynchronization(false);
}
_syncEngine->presync(_isMaster);
if (_isMaster) {
@@ -949,8 +954,15 @@ void OpenSpaceEngine::postDraw() {
#endif
}
if (_isInShutdownMode)
if (_isInShutdownMode) {
_renderEngine->renderShutdownInformation(_shutdownCountdown, _shutdownWait);
}
if (_isFirstRenderingFirstFrame) {
_windowWrapper->setSynchronization(true);
_isFirstRenderingFirstFrame = false;
}
}
void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction action) {