diff options
author | Stijn Buys <ingar@osirion.org> | 2010-11-24 19:50:42 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-11-24 19:50:42 +0000 |
commit | 4f87da2cb4d96cf057bd4202bdf69aa0dae39c0f (patch) | |
tree | 6605f381539c5bb40652f4899b0ca9ca6d503d02 /src/client | |
parent | f71b6b92840a396500aa477a6dba94be4c36d3bb (diff) |
added r_windowheight and r_windowwidth to set window size in windowed mode (defaults to 1024x768)
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/video.cc | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/client/video.cc b/src/client/video.cc index 330ba6b..72b72da 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -28,6 +28,8 @@ namespace client core::Cvar *r_width = 0; core::Cvar *r_height = 0; +core::Cvar *r_windowwidth = 0; +core::Cvar *r_windowheight = 0; core::Cvar *r_fullscreen = 0; core::Cvar *draw_ui = 0; @@ -49,6 +51,7 @@ int height = 0; int width_prev = 0; int height_prev = 0; +// default resolution and window size const int width_default = 1024; const int height_default = 768; @@ -66,6 +69,12 @@ bool init() r_height = core::Cvar::get("r_height", height_default, core::Cvar::Archive); r_height->set_info("[int] video resolution height"); + r_windowwidth = core::Cvar::get("r_windowwidth", width_default, core::Cvar::Archive); + r_windowwidth->set_info("[int] window width in windowed mode"); + + r_windowheight = core::Cvar::get("r_windowheight", height_default, core::Cvar::Archive); + r_windowheight->set_info("[int] window height in windowed mode"); + r_fullscreen = core::Cvar::get("r_fullscreen", "0", core::Cvar::Archive); r_fullscreen->set_info("[bool] enable or disable fullscreen video"); @@ -114,13 +123,7 @@ bool init() return false; } - width_prev = width; - height_prev = height; - width = (int) r_width->value(); - height = (int) r_height->value(); - bpp = sdl_videoinfo->vfmt->BitsPerPixel; - if (bpp == 32) { SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); @@ -142,10 +145,22 @@ bool init() SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + width_prev = width; + height_prev = height; + + width = (int) r_width->value(); + height = (int) r_height->value(); + fullscreen = r_fullscreen->value(); + if (r_fullscreen->value()) { flags = SDL_OPENGL | SDL_FULLSCREEN; } else { + if (r_windowwidth->value() && r_windowheight->value()) { + width = (int) r_windowwidth->value(); + height = (int) r_windowheight->value(); + } flags = SDL_OPENGL; #ifndef _WIN32 flags |= SDL_RESIZABLE; @@ -183,10 +198,15 @@ bool init() // set window caption set_caption(); - // save r_width and r_height variables - (*r_width) = width; - (*r_height) = height; - + // save window width and height + if (fullscreen) { + (*r_width) = width; + (*r_height) = height; + } else { + (*r_windowwidth) = width; + (*r_windowheight) = height; + + } // resize user interface ui::root()->set_size((float) width, (float) height); ui::root()->event_resize(); |