aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/openglsdl
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-20 04:32:31 +0000
committerAlejandro Marzini2010-07-20 04:32:31 +0000
commit302400a701187eba6d0dee2daa253da87b29d83f (patch)
tree14ef4ab769860d534fa56a40949eb4e31e355db9 /backends/graphics/openglsdl
parent014d7b791c03c0c754ebc2d4ef2f2a961420a63a (diff)
downloadscummvm-rg350-302400a701187eba6d0dee2daa253da87b29d83f.tar.gz
scummvm-rg350-302400a701187eba6d0dee2daa253da87b29d83f.tar.bz2
scummvm-rg350-302400a701187eba6d0dee2daa253da87b29d83f.zip
OPENGL: Implement fullscreen mode.
svn-id: r51049
Diffstat (limited to 'backends/graphics/openglsdl')
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp39
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.h1
2 files changed, 35 insertions, 5 deletions
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 1eae7dd9c7..fe3662a520 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -139,6 +139,35 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ if (_videoMode.fullscreen) {
+ SDL_Rect const* const*availableModes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL);
+ const SDL_Rect *bestMode = NULL;
+ uint bestMetric = (uint)-1;
+ while (const SDL_Rect *mode = *availableModes++) {
+ if (mode->w < _videoMode.hardwareWidth)
+ continue;
+ if (mode->h < _videoMode.hardwareHeight)
+ continue;
+
+ uint metric = mode->w * mode->h - _videoMode.hardwareWidth * _videoMode.hardwareHeight;
+ if (metric > bestMetric)
+ continue;
+
+ bestMode = mode;
+ bestMetric = metric;
+ }
+
+ if (bestMode) {
+ _videoMode.hardwareWidth = bestMode->w;
+ _videoMode.hardwareHeight = bestMode->h;
+ } else {
+ _videoMode.fullscreen = false;
+ }
+ }
+
+ if (_oldVideoMode.fullscreen != _videoMode.fullscreen)
+ _transactionDetails.newContext = true;
+
_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
_videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_OPENGL) : (SDL_OPENGL | SDL_RESIZABLE)
);
@@ -164,10 +193,6 @@ void OpenGLSdlGraphicsManager::unloadGFXMode() {
}
}
-bool OpenGLSdlGraphicsManager::hotswapGFXMode() {
- return false;
-}
-
void OpenGLSdlGraphicsManager::internUpdateScreen() {
OpenGLGraphicsManager::internUpdateScreen();
@@ -216,7 +241,13 @@ bool OpenGLSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
}
void OpenGLSdlGraphicsManager::setFullscreenMode(bool enable) {
+ if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable)
+ return;
+ if (_transactionMode == kTransactionActive) {
+ _videoMode.fullscreen = enable;
+ _transactionDetails.needHotswap = true;
+ }
}
bool OpenGLSdlGraphicsManager::isScalerHotkey(const Common::Event &event) {
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index a9ee200ece..b0bf12cd4d 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -55,7 +55,6 @@ protected:
virtual bool loadGFXMode();
virtual void unloadGFXMode();
- virtual bool hotswapGFXMode();
virtual void setFullscreenMode(bool enable);