1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00

Merge pull request #2266 from Capostrophic/vsync

Vsync tweaks
This commit is contained in:
Bret Curtis 2019-03-19 09:23:48 +01:00 committed by GitHub
commit 19dcbf2b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -113,7 +113,7 @@ void GraphicsWindowSDL2::init()
return;
}
SDL_GL_SetSwapInterval(_traits->vsync ? 1 : 0);
setSwapInterval(_traits->vsync);
SDL_GL_MakeCurrent(oldWin, oldCtx);
@ -194,11 +194,31 @@ void GraphicsWindowSDL2::setSyncToVBlank(bool on)
SDL_GL_MakeCurrent(mWindow, mContext);
SDL_GL_SetSwapInterval(on ? 1 : 0);
setSwapInterval(on);
SDL_GL_MakeCurrent(oldWin, oldCtx);
}
void GraphicsWindowSDL2::setSwapInterval(bool enable)
{
if (enable)
{
if (SDL_GL_SetSwapInterval(-1) == -1)
{
OSG_NOTICE << "Adaptive vsync unsupported" << std::endl;
if (SDL_GL_SetSwapInterval(1) == -1)
{
OSG_NOTICE << "Vertical synchronization unsupported, disabling" << std::endl;
SDL_GL_SetSwapInterval(0);
}
}
}
else
{
SDL_GL_SetSwapInterval(0);
}
}
void GraphicsWindowSDL2::raiseWindow()
{
SDL_RaiseWindow(mWindow);

View File

@ -80,6 +80,9 @@ public:
SDL_Window *mWindow;
};
private:
void setSwapInterval(bool enable);
};
}