]> git.localhorst.tv Git - space.git/blob - src/sdl/InitScreen.cpp
adjust cam speed to zoom level
[space.git] / src / sdl / InitScreen.cpp
1 #include "InitScreen.h"
2
3 #include <stdexcept>
4
5 using std::runtime_error;
6
7
8 namespace space {
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() {
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() {
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 }