Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-05 23:40:20 +0000
committerStijn Buys <ingar@osirion.org>2008-02-05 23:40:20 +0000
commit00a039fffea099eb53d2bbe77d3300b3d7ea768f (patch)
tree2255960b8f4b9c782502e9caa00703ffc134a6db /src/client/video.cc
parent1ed2e8eb1f1909a35f6fc8d5d6065bcac37c27ea (diff)
make keyboard input actually work
Diffstat (limited to 'src/client/video.cc')
-rw-r--r--src/client/video.cc34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/client/video.cc b/src/client/video.cc
index df11b90..f7ae792 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -18,11 +18,15 @@ namespace client {
namespace video {
-const int defaultwidth = 1024;
-const int defaultheight = 768;
-
int width = 0;
int height = 0;
+
+int width_prev = 0;
+int height_prev = 0;
+
+const int width_default = 1024;
+const int height_default = 768;
+
float aspect = 1;
//--- cvars -------------------------------------------------------
@@ -48,8 +52,8 @@ bool init()
con_print << "Initializing video..." << std::endl;
// initialize cvars
- r_width = core::cvar::get("r_width", defaultwidth);
- r_height = core::cvar::get("r_height", defaultheight);
+ r_width = core::cvar::get("r_width", width_default);
+ r_height = core::cvar::get("r_height", height_default);
r_fullscreen = core::cvar::get("r_fullscreen", 1);
int bpp = 0;
@@ -66,8 +70,11 @@ bool init()
return false;
}
- width = 1024;
- height = 768;
+ width_prev = width;
+ height_prev = height;
+ width = (int) r_width->value();
+ height = (int) r_height->value();
+
bpp = sdl_videoinfo->vfmt->BitsPerPixel;
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
@@ -80,10 +87,17 @@ bool init()
flags = SDL_OPENGL | SDL_FULLSCREEN;
if(!SDL_SetVideoMode(width, height, bpp, flags )) {
- std::cerr << "SDL_SetVideoMode() failed: " << SDL_GetError() << std::endl;
- return false;
+ con_warn << "Failed to set video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl;
+ if (width_prev && height_prev) {
+ width = width_prev;
+ height = height_prev;
+ if(!SDL_SetVideoMode(width, height, bpp, flags )) {
+ con_error << "Failed to restore video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl;
+ return false;
+ }
+ } else
+ return false;
}
-
con_print << " video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl;
aspect = (float) width / (float) height;