From 4f3a244f16baeaf06825dbbc7b65f453011fb07c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 25 Feb 2011 03:36:45 +0100 Subject: OPENGLSDL: Add RGB555 to the supported format list. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index c7ce0aa7de..183d0afba2 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -121,6 +121,7 @@ void OpenGLSdlGraphicsManager::detectSupportedFormats() { #endif Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), // RGB565 Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), // RGB5551 + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), // RGB555 Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), // RGBA4444 #ifndef USE_GLES Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) // ARGB4444 -- cgit v1.2.3 From 484107907540bd07a5822bee075b450a1ade817c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 1 Mar 2011 05:32:14 +0100 Subject: OPENGL(SDL): Use the whole window/screen size for the overlay. This makes the overlay looking nicer in fullscreen mode. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 183d0afba2..cbc152a4a3 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -345,13 +345,10 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { if (_aspectRatioCorrection) _videoMode.mode = OpenGL::GFX_4_3; - _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; - _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; - // If the screen was resized, do not change its size if (!_screenResized) { - _videoMode.hardwareWidth = _videoMode.overlayWidth; - _videoMode.hardwareHeight = _videoMode.overlayHeight; + _videoMode.overlayWidth = _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; + _videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * _videoMode.scaleFactor; int screenAspectRatio = _videoMode.screenWidth * 10000 / _videoMode.screenHeight; int desiredAspectRatio = getAspectRatio(); @@ -366,6 +363,9 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { // the width is modified it can break the overlay. if (_videoMode.hardwareHeight > _videoMode.overlayHeight) _videoMode.overlayHeight = _videoMode.hardwareHeight; + } else { + _videoMode.overlayWidth = _videoMode.hardwareWidth; + _videoMode.overlayHeight = _videoMode.hardwareHeight; } _screenResized = false; @@ -377,11 +377,15 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (_videoMode.fullscreen) + if (_videoMode.fullscreen) { if (!setupFullscreenMode()) // Failed setuping a fullscreen mode return false; + _videoMode.overlayWidth = _videoMode.hardwareWidth; + _videoMode.overlayHeight = _videoMode.hardwareHeight; + } + uint32 flags = SDL_OPENGL; if (_videoMode.fullscreen) -- cgit v1.2.3 From e08683d939d621f20b0376f9da561f06c4944e31 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 17:37:42 +0100 Subject: OPENGL: Refactor warpMouse. Now subclasses will not need to worry about the scaling logic themselves, but just need to implement setInternalMousePosition, which should handles setting the system's mouse coordinates. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 48 +--------------------- 1 file changed, 2 insertions(+), 46 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index cbc152a4a3..0c7e53950c 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -192,52 +192,8 @@ void OpenGLSdlGraphicsManager::detectSupportedFormats() { #endif -void OpenGLSdlGraphicsManager::warpMouse(int x, int y) { - int scaledX = x; - int scaledY = y; - - int16 currentX = _cursorState.x; - int16 currentY = _cursorState.y; - - adjustMousePosition(currentX, currentY); - - // Do not adjust the real screen position, when the current game / overlay - // coordinates match the requested coordinates. This avoids a slight - // movement which might occur otherwise when the mouse is at a subpixel - // position. - if (x == currentX && y == currentY) - return; - - if (_videoMode.mode == OpenGL::GFX_NORMAL) { - if (_videoMode.hardwareWidth != _videoMode.overlayWidth) - scaledX = scaledX * _videoMode.hardwareWidth / _videoMode.overlayWidth; - if (_videoMode.hardwareHeight != _videoMode.overlayHeight) - scaledY = scaledY * _videoMode.hardwareHeight / _videoMode.overlayHeight; - - if (!_overlayVisible) { - scaledX *= _videoMode.scaleFactor; - scaledY *= _videoMode.scaleFactor; - } - } else { - if (_overlayVisible) { - if (_displayWidth != _videoMode.overlayWidth) - scaledX = scaledX * _displayWidth / _videoMode.overlayWidth; - if (_displayHeight != _videoMode.overlayHeight) - scaledY = scaledY * _displayHeight / _videoMode.overlayHeight; - } else { - if (_displayWidth != _videoMode.screenWidth) - scaledX = scaledX * _displayWidth / _videoMode.screenWidth; - if (_displayHeight != _videoMode.screenHeight) - scaledY = scaledY * _displayHeight / _videoMode.screenHeight; - } - - scaledX += _displayX; - scaledY += _displayY; - } - - SDL_WarpMouse(scaledX, scaledY); - - setMousePos(scaledX, scaledY); +void OpenGLSdlGraphicsManager::setInternalMousePosition(int x, int y) { + SDL_WarpMouse(x, y); } void OpenGLSdlGraphicsManager::updateScreen() { -- cgit v1.2.3 From 3c656916f169e0428bd62c390a8ccb7b7dbd150f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 18:15:50 +0100 Subject: OPENGL: Always properly set the overlay dimensions in loadGFXMode. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 0c7e53950c..b68b55fef1 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -314,14 +314,6 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { _videoMode.hardwareHeight = (_videoMode.overlayWidth * 10000 + 5000) / desiredAspectRatio; else if (screenAspectRatio < desiredAspectRatio) _videoMode.hardwareWidth = (_videoMode.overlayHeight * desiredAspectRatio + 5000) / 10000; - - // Only adjust the overlay height if it is bigger than original one. If - // the width is modified it can break the overlay. - if (_videoMode.hardwareHeight > _videoMode.overlayHeight) - _videoMode.overlayHeight = _videoMode.hardwareHeight; - } else { - _videoMode.overlayWidth = _videoMode.hardwareWidth; - _videoMode.overlayHeight = _videoMode.hardwareHeight; } _screenResized = false; @@ -337,11 +329,11 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { if (!setupFullscreenMode()) // Failed setuping a fullscreen mode return false; - - _videoMode.overlayWidth = _videoMode.hardwareWidth; - _videoMode.overlayHeight = _videoMode.hardwareHeight; } + _videoMode.overlayWidth = _videoMode.hardwareWidth; + _videoMode.overlayHeight = _videoMode.hardwareHeight; + uint32 flags = SDL_OPENGL; if (_videoMode.fullscreen) -- cgit v1.2.3 From 42d3b8fcbda7793bf3ef8435db5ed78f7350cf4d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 18:34:22 +0100 Subject: OPENGL: Fix compilation when USE_OSD is not defined. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index b68b55fef1..c2ec43b90d 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -565,7 +565,9 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // Ctrl-Alt- will change the GFX mode if (isNormalNumber || isKeypadNumber) { if (sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1) <= 4) { +#ifdef USE_OSD int lastMode = _videoMode.mode; +#endif beginGFXTransaction(); _videoMode.mode = sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1); _transactionDetails.needRefresh = true; -- cgit v1.2.3 From 96979f73fc10679fc0112cfbc55d6b661d744b05 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 19:47:18 +0100 Subject: OPENGL: Slight refactoring. First step into making all state variables of the OpenGL backend private, to help making the backend more maintainable, by disallowing subclasses to just mess with everything... --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index c2ec43b90d..bdea64bb44 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -298,7 +298,7 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() { bool OpenGLSdlGraphicsManager::loadGFXMode() { // Force 4/3 if feature enabled - if (_aspectRatioCorrection) + if (getFeatureState(OSystem::kFeatureAspectRatioCorrection)) _videoMode.mode = OpenGL::GFX_4_3; // If the screen was resized, do not change its size @@ -522,11 +522,14 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // Ctrl-Alt-f toggles antialiasing if (event.kbd.keycode == 'f') { beginGFXTransaction(); - _videoMode.antialiasing = !_videoMode.antialiasing; - _transactionDetails.filterChanged = true; + toggleAntialiasing(); endGFXTransaction(); + #ifdef USE_OSD - if (_videoMode.antialiasing) + // TODO: This makes guesses about what internal antialiasing + // modes we use, we might want to consider a better way of + // displaying information to the user. + if (getAntialiasingState()) displayMessageOnOSD("Active filter mode: Linear"); else displayMessageOnOSD("Active filter mode: Nearest"); @@ -568,10 +571,16 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { #ifdef USE_OSD int lastMode = _videoMode.mode; #endif + // We need to query the scale and set it up, because + // setGraphicsMode sets the default scale to 2 + int oldScale = getScale(); beginGFXTransaction(); - _videoMode.mode = sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1); - _transactionDetails.needRefresh = true; - _aspectRatioCorrection = false; + setGraphicsMode(sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1)); + setScale(oldScale); + // TODO: We disable the aspect ratio correction here, + // we might switch to mode which ignores it... + // We should really fix this mess up. + setFeatureState(OSystem::kFeatureAspectRatioCorrection, false); endGFXTransaction(); #ifdef USE_OSD if (lastMode != _videoMode.mode) -- cgit v1.2.3 From c9f61361108a2b07c02be7656d64540fb568843c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 20:01:54 +0100 Subject: OPENGLSDL: Cleanup. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index bdea64bb44..8fd2514eea 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -303,8 +303,9 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { // If the screen was resized, do not change its size if (!_screenResized) { - _videoMode.overlayWidth = _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; - _videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * _videoMode.scaleFactor; + const int scaleFactor = getScale(); + _videoMode.overlayWidth = _videoMode.hardwareWidth = _videoMode.screenWidth * scaleFactor; + _videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor; int screenAspectRatio = _videoMode.screenWidth * 10000 / _videoMode.screenHeight; int desiredAspectRatio = getAspectRatio(); @@ -392,11 +393,13 @@ void OpenGLSdlGraphicsManager::internUpdateScreen() { void OpenGLSdlGraphicsManager::displayModeChangedMsg() { const char *newModeName = getCurrentModeName(); if (newModeName) { + const int scaleFactor = getScale(); + char buffer[128]; sprintf(buffer, "Current display mode: %s\n%d x %d -> %d x %d", newModeName, - _videoMode.screenWidth * _videoMode.scaleFactor, - _videoMode.screenHeight * _videoMode.scaleFactor, + _videoMode.screenWidth * scaleFactor, + _videoMode.screenHeight * scaleFactor, _hwscreen->w, _hwscreen->h ); displayMessageOnOSD(buffer); @@ -404,8 +407,9 @@ void OpenGLSdlGraphicsManager::displayModeChangedMsg() { } void OpenGLSdlGraphicsManager::displayScaleChangedMsg() { char buffer[128]; + const int scaleFactor = getScale(); sprintf(buffer, "Current scale: x%d\n%d x %d -> %d x %d", - _videoMode.scaleFactor, + scaleFactor, _videoMode.screenWidth, _videoMode.screenHeight, _videoMode.overlayWidth, _videoMode.overlayHeight ); @@ -542,7 +546,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // Ctrl+Alt+Plus/Minus Increase/decrease the scale factor if ((sdlKey == SDLK_EQUALS || sdlKey == SDLK_PLUS || sdlKey == SDLK_MINUS || sdlKey == SDLK_KP_PLUS || sdlKey == SDLK_KP_MINUS)) { - int factor = _videoMode.scaleFactor; + int factor = getScale(); factor += (sdlKey == SDLK_MINUS || sdlKey == SDLK_KP_MINUS) ? -1 : +1; if (0 < factor && factor < 4) { // Check if the desktop resolution has been detected @@ -631,10 +635,11 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { } int scale = MIN(_videoMode.hardwareWidth / _videoMode.screenWidth, - _videoMode.hardwareHeight / _videoMode.screenHeight); - if (_videoMode.scaleFactor != scale) { + _videoMode.hardwareHeight / _videoMode.screenHeight); + + if (getScale() != scale) { scaleChanged = true; - _videoMode.scaleFactor = MAX(MIN(scale, 3), 1); + setScale(MAX(MIN(scale, 3), 1)); } if (_videoMode.mode == OpenGL::GFX_ORIGINAL) { -- cgit v1.2.3 From 8d87a460b075793c3a06f5339eb5ee14c7498005 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 20:17:43 +0100 Subject: OPENGLSDL: Handle active fullscreen mode OPENGLSDL internal. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 8fd2514eea..3eb15bd684 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -35,6 +35,7 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager() : _hwscreen(0), _screenResized(false), + _activeFullscreenMode(-2), _lastFullscreenModeWidth(0), _lastFullscreenModeHeight(0), _desktopWidth(0), @@ -215,7 +216,7 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() { if (availableModes == (void *)-1) { _videoMode.hardwareWidth = _desktopWidth; _videoMode.hardwareHeight = _desktopHeight; - _videoMode.activeFullscreenMode = -2; + _activeFullscreenMode = -2; return true; } @@ -223,7 +224,7 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() { // The last used fullscreen mode will be prioritized, if there is no last fullscreen // mode, the desktop resolution will be used, and in case the desktop resolution // is not available as a fullscreen mode, the one with smallest metric will be selected. - if (_videoMode.activeFullscreenMode == -2) { + if (_activeFullscreenMode == -2) { // Desktop resolution int desktopModeIndex = -1; @@ -238,7 +239,7 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() { if (mode->w == _lastFullscreenModeWidth && mode->h == _lastFullscreenModeHeight) { _videoMode.hardwareWidth = _lastFullscreenModeWidth; _videoMode.hardwareHeight = _lastFullscreenModeHeight; - _videoMode.activeFullscreenMode = i; + _activeFullscreenMode = i; return true; } @@ -262,32 +263,32 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() { _videoMode.hardwareWidth = _desktopWidth; _videoMode.hardwareHeight = _desktopHeight; - _videoMode.activeFullscreenMode = desktopModeIndex; + _activeFullscreenMode = desktopModeIndex; return true; } else if (bestMode) { _videoMode.hardwareWidth = bestMode->w; _videoMode.hardwareHeight = bestMode->h; - _videoMode.activeFullscreenMode = bestModeIndex; + _activeFullscreenMode = bestModeIndex; return true; } } else { // Use last fullscreen mode if looping backwards from the first mode - if (_videoMode.activeFullscreenMode == -1) { + if (_activeFullscreenMode == -1) { do { - _videoMode.activeFullscreenMode++; - } while(availableModes[_videoMode.activeFullscreenMode]); - _videoMode.activeFullscreenMode--; + _activeFullscreenMode++; + } while(availableModes[_activeFullscreenMode]); + _activeFullscreenMode--; } // Use first fullscreen mode if looping from last mode - if (!availableModes[_videoMode.activeFullscreenMode]) - _videoMode.activeFullscreenMode = 0; + if (!availableModes[_activeFullscreenMode]) + _activeFullscreenMode = 0; // Check if the fullscreen mode is valid - if (availableModes[_videoMode.activeFullscreenMode]) { - _videoMode.hardwareWidth = availableModes[_videoMode.activeFullscreenMode]->w; - _videoMode.hardwareHeight = availableModes[_videoMode.activeFullscreenMode]->h; + if (availableModes[_activeFullscreenMode]) { + _videoMode.hardwareWidth = availableModes[_activeFullscreenMode]->w; + _videoMode.hardwareHeight = availableModes[_activeFullscreenMode]->h; return true; } } @@ -326,7 +327,11 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (_videoMode.fullscreen) { + // In case we have an fullscreen mode and we are not in a rollback, detect + // a proper mode to use. In case we are in a rollback, we already detected + // a proper mode when setting up that mode, thus there is no need to run + // the detection again. + if (_videoMode.fullscreen && _transactionMode != kTransactionRollback) { if (!setupFullscreenMode()) // Failed setuping a fullscreen mode return false; @@ -418,8 +423,7 @@ void OpenGLSdlGraphicsManager::displayScaleChangedMsg() { #endif void OpenGLSdlGraphicsManager::setFullscreenMode(bool enable) { - if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable && - _oldVideoMode.activeFullscreenMode == _videoMode.activeFullscreenMode) + if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable) return; if (_transactionMode == kTransactionActive) { @@ -446,10 +450,10 @@ bool OpenGLSdlGraphicsManager::isHotkey(const Common::Event &event) { void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { beginGFXTransaction(); if (_videoMode.fullscreen && loop) { - _videoMode.activeFullscreenMode += loop; + _activeFullscreenMode += loop; setFullscreenMode(true); } else { - _videoMode.activeFullscreenMode = -2; + _activeFullscreenMode = -2; setFullscreenMode(!_videoMode.fullscreen); } endGFXTransaction(); -- cgit v1.2.3 From 83b199e9212092bcc737e36eb3f0cff0666ddeac Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 20:27:00 +0100 Subject: OPENGL: Move setFullscreenMode to OpenGLGraphicsManager. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 3eb15bd684..e16a51762c 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -79,9 +79,6 @@ bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) { void OpenGLSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { switch (f) { - case OSystem::kFeatureFullscreenMode: - setFullscreenMode(enable); - break; case OSystem::kFeatureIconifyWindow: if (enable) SDL_WM_IconifyWindow(); @@ -422,16 +419,6 @@ void OpenGLSdlGraphicsManager::displayScaleChangedMsg() { } #endif -void OpenGLSdlGraphicsManager::setFullscreenMode(bool enable) { - if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable) - return; - - if (_transactionMode == kTransactionActive) { - _videoMode.fullscreen = enable; - _transactionDetails.needRefresh = true; - } -} - bool OpenGLSdlGraphicsManager::isHotkey(const Common::Event &event) { if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { if (event.kbd.keycode == Common::KEYCODE_PLUS || event.kbd.keycode == Common::KEYCODE_MINUS || -- cgit v1.2.3 From f490e6f361e55c2347b51611eb8f03a721630421 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Mar 2011 20:29:48 +0100 Subject: OPENGLSDL: More refactoring to avoid direct access of OpenGlGraphicsManager's members. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index e16a51762c..de9dba1ab1 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -324,11 +324,13 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + const bool isFullscreen = getFullscreenMode(); + // In case we have an fullscreen mode and we are not in a rollback, detect // a proper mode to use. In case we are in a rollback, we already detected // a proper mode when setting up that mode, thus there is no need to run // the detection again. - if (_videoMode.fullscreen && _transactionMode != kTransactionRollback) { + if (isFullscreen && _transactionMode != kTransactionRollback) { if (!setupFullscreenMode()) // Failed setuping a fullscreen mode return false; @@ -339,7 +341,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { uint32 flags = SDL_OPENGL; - if (_videoMode.fullscreen) + if (isFullscreen) flags |= SDL_FULLSCREEN; else flags |= SDL_RESIZABLE; @@ -365,7 +367,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { // Check if the screen is BGR format _formatBGR = _hwscreen->format->Rshift != 0; - if (_videoMode.fullscreen) { + if (isFullscreen) { _lastFullscreenModeWidth = _videoMode.hardwareWidth; _lastFullscreenModeHeight = _videoMode.hardwareHeight; ConfMan.setInt("last_fullscreen_mode_width", _lastFullscreenModeWidth); @@ -436,12 +438,14 @@ bool OpenGLSdlGraphicsManager::isHotkey(const Common::Event &event) { void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { beginGFXTransaction(); - if (_videoMode.fullscreen && loop) { + const bool isFullscreen = getFullscreenMode(); + + if (isFullscreen && loop) { _activeFullscreenMode += loop; setFullscreenMode(true); } else { _activeFullscreenMode = -2; - setFullscreenMode(!_videoMode.fullscreen); + setFullscreenMode(!isFullscreen); } endGFXTransaction(); @@ -450,7 +454,7 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { #ifdef USE_OSD char buffer[128]; - if (_videoMode.fullscreen) + if (getFullscreenMode()) sprintf(buffer, "Fullscreen mode\n%d x %d", _hwscreen->w, _hwscreen->h ); @@ -614,7 +618,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // there is no common resize event. case OSystem_SDL::kSdlEventResize: // Do not resize if ignoring resize events. - if (!_ignoreResizeFrames && !_videoMode.fullscreen) { + if (!_ignoreResizeFrames && !getFullscreenMode()) { bool scaleChanged = false; beginGFXTransaction(); _videoMode.hardwareWidth = event.mouse.x; -- cgit v1.2.3 From 6502e191b939ad836c92dc602a6f0e4e4c75b044 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Mar 2011 17:29:08 +0100 Subject: OPENGL: Handle aspect ratio correction as flag instead of having a special mode for it. This partly fixes the OpenGL mode mess, but now OpenGL Normal and OpenGL Conserve will feature the same semantics when aspect ratio correction is enabled... That is still something to solve. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 39 ++++++++-------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index de9dba1ab1..b9022af120 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -295,10 +295,6 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() { } bool OpenGLSdlGraphicsManager::loadGFXMode() { - // Force 4/3 if feature enabled - if (getFeatureState(OSystem::kFeatureAspectRatioCorrection)) - _videoMode.mode = OpenGL::GFX_4_3; - // If the screen was resized, do not change its size if (!_screenResized) { const int scaleFactor = getScale(); @@ -509,10 +505,19 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // Ctrl-Alt-a switch between display modes if (event.kbd.keycode == 'a') { beginGFXTransaction(); - switchDisplayMode(-1); + setFeatureState(OSystem::kFeatureAspectRatioCorrection, !getFeatureState(OSystem::kFeatureAspectRatioCorrection)); endGFXTransaction(); #ifdef USE_OSD - displayModeChangedMsg(); + char buffer[128]; + if (getFeatureState(OSystem::kFeatureAspectRatioCorrection)) + sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d", + _videoMode.screenWidth, _videoMode.screenHeight, + _hwscreen->w, _hwscreen->h); + else + sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d", + _videoMode.screenWidth, _videoMode.screenHeight, + _hwscreen->w, _hwscreen->h); + displayMessageOnOSD(buffer); #endif internUpdateScreen(); return true; @@ -561,12 +566,12 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { } } - const bool isNormalNumber = (SDLK_1 <= sdlKey && sdlKey <= SDLK_4); - const bool isKeypadNumber = (SDLK_KP1 <= sdlKey && sdlKey <= SDLK_KP4); + const bool isNormalNumber = (SDLK_1 <= sdlKey && sdlKey <= SDLK_3); + const bool isKeypadNumber = (SDLK_KP1 <= sdlKey && sdlKey <= SDLK_KP3); // Ctrl-Alt- will change the GFX mode if (isNormalNumber || isKeypadNumber) { - if (sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1) <= 4) { + if (sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1) <= 3) { #ifdef USE_OSD int lastMode = _videoMode.mode; #endif @@ -576,10 +581,6 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { beginGFXTransaction(); setGraphicsMode(sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1)); setScale(oldScale); - // TODO: We disable the aspect ratio correction here, - // we might switch to mode which ignores it... - // We should really fix this mess up. - setFeatureState(OSystem::kFeatureAspectRatioCorrection, false); endGFXTransaction(); #ifdef USE_OSD if (lastMode != _videoMode.mode) @@ -597,18 +598,6 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { toggleFullScreen(-1); return true; } - - // Ctrl-Shift-a switch backwards between display modes - if (event.kbd.keycode == 'a') { - beginGFXTransaction(); - switchDisplayMode(-2); - endGFXTransaction(); -#ifdef USE_OSD - displayModeChangedMsg(); -#endif - internUpdateScreen(); - return true; - } } break; case Common::EVENT_KEYUP: -- cgit v1.2.3 From 9414d7a6e287ff8abfb5746b564e92c8f0e6de58 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Sun, 24 Apr 2011 11:34:27 +0300 Subject: JANITORIAL: Reduce header dependencies in shared code Some backends may break as I only compiled SDL --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index b9022af120..d5ba6ee1e8 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -30,6 +30,7 @@ #include "backends/graphics/openglsdl/openglsdl-graphics.h" #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" +#include "common/textconsole.h" OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager() : -- cgit v1.2.3 From 59e77ed66779d33a14a5f4d2a5885a70b793f36f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 2 May 2011 14:42:08 +0200 Subject: ALL: Mark printf and various other symbols as forbidden Right now, a few places in the frontend code still use printf and consorts. We mark the affected files with a FIXME for now, and add a dedicated exception for each. To be fixed! Also tweak FORBIDDEN_SYMBOL_REPLACEMENT to hopefully really always enforce a compiler error --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/graphics/openglsdl/openglsdl-graphics.cpp') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index d5ba6ee1e8..fe86dd2098 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -488,9 +488,9 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { SDL_RWclose(file); } if (saveScreenshot(filename)) - printf("Saved '%s'\n", filename); + debug("Saved screenshot '%s'", filename); else - printf("Could not save screenshot!\n"); + warning("Could not save screenshot"); return true; } } -- cgit v1.2.3