X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fsdl%2FInitScreen.cpp;h=e8f19b7c98d71bb927ea4dd627caf0b0482eea54;hb=acc322b16b5f31cfbc350d4fccb457c7730287fd;hp=c9b275fc83ad5d758322743799363151cd343e38;hpb=5ceb9e51fd6768946c4a2d72aac13fa6bc78fa88;p=l2e.git diff --git a/src/sdl/InitScreen.cpp b/src/sdl/InitScreen.cpp index c9b275f..e8f19b7 100644 --- a/src/sdl/InitScreen.cpp +++ b/src/sdl/InitScreen.cpp @@ -1,10 +1,3 @@ -/* - * InitScreen.cpp - * - * Created on: Apr 22, 2012 - * Author: holy - */ - #include "InitScreen.h" #include @@ -15,7 +8,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 +20,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); + } +} + }