diff --git a/video.cc b/video.cc index 346e923..0534b56 100644 --- a/video.cc +++ b/video.cc @@ -4,6 +4,9 @@ #include using namespace std; +static int default_width = 0; +static int default_height = 0; + void video_init() { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) @@ -11,4 +14,27 @@ void video_init() cerr << "SDL_Init() returned error!" << endl; exit(3); } + + const SDL_VideoInfo * vidInfo = SDL_GetVideoInfo(); + if (vidInfo != NULL) + { + default_width = vidInfo->current_w; + default_height = vidInfo->current_h; + } + else + { + cerr << "Warning: SDL_GetVideoInfo() returned NULL!" << endl; + default_width = 1024; + default_height = 768; + } +} + +int getDefaultWidth() +{ + return default_width; +} + +int getDefaultHeight() +{ + return default_height; } diff --git a/video.h b/video.h index d8881e1..336621b 100644 --- a/video.h +++ b/video.h @@ -3,5 +3,7 @@ #define SDL_H void video_init(); +int getDefaultWidth(); +int getDefaultHeight(); #endif