]> git.localhorst.tv Git - l2e.git/blobdiff - src/sdl/InitScreen.cpp
Merge branch 'menus'
[l2e.git] / src / sdl / InitScreen.cpp
index c9b275fc83ad5d758322743799363151cd343e38..13fb6b620bfef50d4a27bef256626659eefe3f7d 100644 (file)
@@ -15,7 +15,9 @@ using std::runtime_error;
 namespace sdl {
 
 InitScreen::InitScreen(int width, int height, int bpp, Sint32 flags)
-: screen(SDL_SetVideoMode(width, height, bpp, flags)) {
+: screen(SDL_SetVideoMode(width, height, bpp, flags))
+, bpp(bpp)
+, flags(flags) {
        if (!screen) {
                throw runtime_error("failed to open screen");
        }
@@ -25,4 +27,21 @@ InitScreen::~InitScreen(void) {
 
 }
 
+
+SDL_Surface *InitScreen::Resize(int width, int height) {
+       SDL_Surface *newScreen(SDL_SetVideoMode(width, height, bpp, flags));
+       if (!newScreen) {
+               throw runtime_error("failed to resize screen");
+       }
+       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);
+       }
+}
+
 }