Support setting vsync in app::app
This commit is contained in:
parent
90165b9b59
commit
fed4da3213
2 changed files with 19 additions and 1 deletions
|
|
@ -30,8 +30,9 @@ namespace psemek::app
|
||||||
scene * set_scene(scene * s);
|
scene * set_scene(scene * s);
|
||||||
|
|
||||||
void show_cursor(bool show);
|
void show_cursor(bool show);
|
||||||
float time() const;
|
void vsync(bool on);
|
||||||
|
|
||||||
|
float time() const;
|
||||||
int width() const;
|
int width() const;
|
||||||
int height() const;
|
int height() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -242,6 +242,23 @@ namespace psemek::app
|
||||||
return std::chrono::duration_cast<std::chrono::duration<float>>(clock::now() - impl().start_time).count();
|
return std::chrono::duration_cast<std::chrono::duration<float>>(clock::now() - impl().start_time).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void app::vsync(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
// try adaptive vsync
|
||||||
|
if (SDL_GL_SetSwapInterval(-1) != 0)
|
||||||
|
{
|
||||||
|
// failed, try usual vsync then
|
||||||
|
SDL_GL_SetSwapInterval(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_GL_SetSwapInterval(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int app::width() const
|
int app::width() const
|
||||||
{
|
{
|
||||||
return impl().width;
|
return impl().width;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue