From 1b568fdf3925b7b0578f9a9fbba79e18f45da0ad Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Fri, 18 May 2012 17:46:00 +0200 Subject: [PATCH] Make setMode get the actual width and height after setting, fixes bug with width and height 0 (aka desktop resolution) --- src/modules/graphics/opengl/Graphics.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 542b5ee34..c6835f24c 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -69,7 +69,7 @@ namespace opengl s.color = getColor(); s.backgroundColor = getBackgroundColor(); - + s.blendMode = getBlendMode(); s.colorMode = getColorMode(); //get line style @@ -113,7 +113,11 @@ namespace opengl // the display mode change. Volatile::unloadAll(); - currentWindow->setWindow(width, height, fullscreen, vsync, fsaa); + bool success = currentWindow->setWindow(width, height, fullscreen, vsync, fsaa); + // Regardless of failure, we'll have to set up OpenGL once again. + + width = currentWindow->getWidth(); + height = currentWindow->getHeight(); // Okay, setup OpenGL. @@ -132,14 +136,14 @@ namespace opengl glEnable(GL_TEXTURE_2D); // Set the viewport to top-left corner - glViewport(0,0, width, height); + glViewport(0, 0, width, height); // Reset the projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Set up orthographic view (no depth) - glOrtho(0.0, width, height,0.0, -1.0, 1.0); + glOrtho(0.0, width, height, 0.0, -1.0, 1.0); // Reset modelview matrix glMatrixMode(GL_MODELVIEW); @@ -160,7 +164,7 @@ namespace opengl glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &matrixLimit); matrixLimit -= 5; - return true; + return success; } void Graphics::getMode(int &width, int &height, bool &fullscreen, bool &vsync, int &fsaa)