-/*
- * InitScreen.cpp
- *
- * Created on: Apr 22, 2012
- * Author: holy
- */
-
#include "InitScreen.h"
#include <stdexcept>
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");
}
}
+
+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);
+ }
+}
+
}