From 3a86cc937e9fce68384efc08edb6d6ba101d12eb Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 20 Oct 2012 15:29:09 +0200 Subject: [PATCH] introduced a small delay after flip if the screen is not a hardware surface --- src/sdl/InitScreen.cpp | 9 +++++++++ src/sdl/InitScreen.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sdl/InitScreen.cpp b/src/sdl/InitScreen.cpp index 76030b1..13fb6b6 100644 --- a/src/sdl/InitScreen.cpp +++ b/src/sdl/InitScreen.cpp @@ -27,6 +27,7 @@ InitScreen::~InitScreen(void) { } + SDL_Surface *InitScreen::Resize(int width, int height) { SDL_Surface *newScreen(SDL_SetVideoMode(width, height, bpp, flags)); if (!newScreen) { @@ -35,4 +36,12 @@ SDL_Surface *InitScreen::Resize(int width, int height) { return screen = newScreen; } +void InitScreen::Flip(void) { + SDL_Flip(screen); + if (!(screen->flags & SDL_HWSURFACE)) { + // probably got no vsync, so suspend execution for a while + SDL_Delay(1); + } +} + } diff --git a/src/sdl/InitScreen.h b/src/sdl/InitScreen.h index 5455a17..dd5e245 100644 --- a/src/sdl/InitScreen.h +++ b/src/sdl/InitScreen.h @@ -25,7 +25,7 @@ public: SDL_Surface *Screen(void) { return screen; }; const SDL_Surface *Screen(void) const { return screen; }; - void Flip(void) { SDL_Flip(screen); }; + void Flip(void); SDL_Surface *Resize(int width, int height); private: -- 2.39.2