Vsync tweaks

Try to use adaptive vsync if available
Don't use vsync if unavailable
pull/2266/head
Capostrophic 6 years ago
parent e2ed90e67b
commit 9b65f0dbca

@ -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);

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

Loading…
Cancel
Save