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