X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fsdl%2FInitScreen.cpp;h=13fb6b620bfef50d4a27bef256626659eefe3f7d;hb=350055a7ff27c74882aff8a4d6af2014782f830b;hp=c9b275fc83ad5d758322743799363151cd343e38;hpb=5ceb9e51fd6768946c4a2d72aac13fa6bc78fa88;p=l2e.git diff --git a/src/sdl/InitScreen.cpp b/src/sdl/InitScreen.cpp index c9b275f..13fb6b6 100644 --- a/src/sdl/InitScreen.cpp +++ b/src/sdl/InitScreen.cpp @@ -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); + } +} + }