]> git.localhorst.tv Git - l2e.git/blob - src/sdl/InitScreen.cpp
made third column hack of menus configurable
[l2e.git] / src / sdl / InitScreen.cpp
1 #include "InitScreen.h"
2
3 #include <stdexcept>
4
5 using std::runtime_error;
6
7
8 namespace sdl {
9
10 InitScreen::InitScreen(int width, int height, int bpp, Sint32 flags)
11 : screen(SDL_SetVideoMode(width, height, bpp, flags))
12 , bpp(bpp)
13 , flags(flags) {
14         if (!screen) {
15                 throw runtime_error("failed to open screen");
16         }
17 }
18
19 InitScreen::~InitScreen(void) {
20
21 }
22
23
24 SDL_Surface *InitScreen::Resize(int width, int height) {
25         SDL_Surface *newScreen(SDL_SetVideoMode(width, height, bpp, flags));
26         if (!newScreen) {
27                 throw runtime_error("failed to resize screen");
28         }
29         return screen = newScreen;
30 }
31
32 void InitScreen::Flip(void) {
33         SDL_Flip(screen);
34         if (!(screen->flags & SDL_HWSURFACE)) {
35                 // probably got no vsync, so suspend execution for a while
36                 SDL_Delay(1);
37         }
38 }
39
40 }