]> git.localhorst.tv Git - l2e.git/commitdiff
introduced a small delay after flip if the screen is not a hardware surface
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 20 Oct 2012 13:29:09 +0000 (15:29 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 20 Oct 2012 13:29:09 +0000 (15:29 +0200)
src/sdl/InitScreen.cpp
src/sdl/InitScreen.h

index 76030b1df0067aa610428cb93eff3ba7ca168848..13fb6b620bfef50d4a27bef256626659eefe3f7d 100644 (file)
@@ -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);
+       }
+}
+
 }
index 5455a17675da1e87bd0bde032f1b60a952468976..dd5e2456fd0adde7e2aae71081f6f19d0b7acb24 100644 (file)
@@ -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: