[Scummvm-cvs-logs] scummvm master -> 8ab136dafb2cef66e48ae24db6bd994e134f91e3
lordhoto
lordhoto at gmail.com
Thu Mar 17 21:22:23 CET 2011
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
daf6050d7c OPENGL: Make setScale non-virtual.
c9f6136110 OPENGLSDL: Cleanup.
8d87a460b0 OPENGLSDL: Handle active fullscreen mode OPENGLSDL internal.
83b199e921 OPENGL: Move setFullscreenMode to OpenGLGraphicsManager.
f490e6f361 OPENGLSDL: More refactoring to avoid direct access of OpenGlGraphicsManager's members.
8d35d91bdf OPENGL: Cleanup switchDisplayMode.
83c638ad02 OPENGL: Setup the correct header size for BMP screenshots.
8ab136dafb OPENGL: Fix screenshots when the display width is not divisible by 4.
Commit: daf6050d7c5d625bff4516f86cbec205bbd51c80
https://github.com/scummvm/scummvm/commit/daf6050d7c5d625bff4516f86cbec205bbd51c80
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGL: Make setScale non-virtual.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/opengl-graphics.h
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 468c40a..915a686 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1219,6 +1219,8 @@ void OpenGLGraphicsManager::unloadGFXMode() {
}
void OpenGLGraphicsManager::setScale(int newScale) {
+ assert(_transactionMode == kTransactionActive);
+
if (newScale == _videoMode.scaleFactor)
return;
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 3518d07..976524e 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -176,7 +176,14 @@ protected:
virtual bool loadGFXMode();
virtual void unloadGFXMode();
- virtual void setScale(int newScale);
+ /**
+ * Set the scale factor.
+ *
+ * This can only be used in a GFX transaction.
+ *
+ * @param newScale New scale factor.
+ */
+ void setScale(int newScale);
/**
* Query the scale factor.
Commit: c9f61361108a2b07c02be7656d64540fb568843c
https://github.com/scummvm/scummvm/commit/c9f61361108a2b07c02be7656d64540fb568843c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGLSDL: Cleanup.
Changed paths:
backends/graphics/openglsdl/openglsdl-graphics.cpp
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index bdea64b..8fd2514 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) {
Commit: 8d87a460b075793c3a06f5339eb5ee14c7498005
https://github.com/scummvm/scummvm/commit/8d87a460b075793c3a06f5339eb5ee14c7498005
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGLSDL: Handle active fullscreen mode OPENGLSDL internal.
Changed paths:
backends/graphics/opengl/opengl-graphics.h
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/openglsdl/openglsdl-graphics.h
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 976524e..31606cf 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -152,7 +152,6 @@ protected:
bool setup;
bool fullscreen;
- int activeFullscreenMode;
int mode;
int scaleFactor;
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 8fd2514..3eb15bd 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();
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index 309301c..f706fc2 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -78,6 +78,8 @@ protected:
*/
virtual void toggleFullScreen(int loop);
+ int _activeFullscreenMode;
+
/**
* Setup the fullscreen mode.
* @return false if failed finding a mode, true otherwise.
Commit: 83b199e9212092bcc737e36eb3f0cff0666ddeac
https://github.com/scummvm/scummvm/commit/83b199e9212092bcc737e36eb3f0cff0666ddeac
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGL: Move setFullscreenMode to OpenGLGraphicsManager.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/opengl-graphics.h
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/openglsdl/openglsdl-graphics.h
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 915a686..0729ff3 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -98,6 +98,10 @@ bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) {
void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
switch (f) {
+ case OSystem::kFeatureFullscreenMode:
+ setFullscreenMode(enable);
+ break;
+
case OSystem::kFeatureAspectRatioCorrection:
// TODO: If we enable aspect ratio correction, we automatically set
// the video mode to 4/3. That is quity messy, but since we have that
@@ -108,6 +112,7 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
if (enable)
_videoMode.mode = OpenGL::GFX_4_3;
break;
+
default:
break;
}
@@ -115,8 +120,12 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) {
switch (f) {
+ case OSystem::kFeatureFullscreenMode:
+ return _videoMode.fullscreen;
+
case OSystem::kFeatureAspectRatioCorrection:
return _videoMode.mode == OpenGL::GFX_4_3;
+
default:
return false;
}
@@ -677,6 +686,18 @@ void OpenGLGraphicsManager::displayMessageOnOSD(const char *msg) {
// Intern
//
+void OpenGLGraphicsManager::setFullscreenMode(bool enable) {
+ assert(_transactionMode == kTransactionActive);
+
+ if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable)
+ return;
+
+ if (_transactionMode == kTransactionActive) {
+ _videoMode.fullscreen = enable;
+ _transactionDetails.needRefresh = true;
+ }
+}
+
void OpenGLGraphicsManager::refreshGameScreen() {
if (_screenNeedsRedraw)
_screenDirtyRect = Common::Rect(0, 0, _screenData.w, _screenData.h);
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 31606cf..c8b64fa 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -176,6 +176,11 @@ protected:
virtual void unloadGFXMode();
/**
+ * Setup the fullscreen mode state.
+ */
+ void setFullscreenMode(bool enable);
+
+ /**
* Set the scale factor.
*
* This can only be used in a GFX transaction.
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 3eb15bd..e16a517 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 ||
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index f706fc2..e9e5ed8 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -57,9 +57,6 @@ protected:
virtual bool loadGFXMode();
virtual void unloadGFXMode();
-
- virtual void setFullscreenMode(bool enable);
-
virtual bool isHotkey(const Common::Event &event);
#ifdef USE_RGB_COLOR
Commit: f490e6f361e55c2347b51611eb8f03a721630421
https://github.com/scummvm/scummvm/commit/f490e6f361e55c2347b51611eb8f03a721630421
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGLSDL: More refactoring to avoid direct access of OpenGlGraphicsManager's members.
Changed paths:
backends/graphics/opengl/opengl-graphics.h
backends/graphics/openglsdl/openglsdl-graphics.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index c8b64fa..8432d83 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -181,6 +181,11 @@ protected:
void setFullscreenMode(bool enable);
/**
+ * Query the fullscreen state.
+ */
+ inline bool getFullscreenMode() const { return _videoMode.fullscreen; }
+
+ /**
* Set the scale factor.
*
* This can only be used in a GFX transaction.
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index e16a517..de9dba1 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;
Commit: 8d35d91bdf3eab421233c6b971d6dec39b2f45b0
https://github.com/scummvm/scummvm/commit/8d35d91bdf3eab421233c6b971d6dec39b2f45b0
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGL: Cleanup switchDisplayMode.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/opengl-graphics.h
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 0729ff3..e0c65dd 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1376,19 +1376,19 @@ const char *OpenGLGraphicsManager::getCurrentModeName() {
}
void OpenGLGraphicsManager::switchDisplayMode(int mode) {
- if (_oldVideoMode.setup && _oldVideoMode.mode == mode)
+ assert(_transactionMode == kTransactionActive);
+
+ if (_videoMode.mode == mode)
return;
- if (_transactionMode == kTransactionActive) {
- if (mode == -1) // If -1, switch to next mode
- _videoMode.mode = (_videoMode.mode + 1) % 4;
- else if (mode == -2) // If -2, switch to previous mode
- _videoMode.mode = (_videoMode.mode + 3) % 4;
- else
- _videoMode.mode = mode;
+ if (mode == -1) // If -1, switch to next mode
+ _videoMode.mode = (_videoMode.mode + 1) % 4;
+ else if (mode == -2) // If -2, switch to previous mode
+ _videoMode.mode = (_videoMode.mode + 3) % 4;
+ else
+ _videoMode.mode = mode;
- _transactionDetails.needRefresh = true;
- }
+ _transactionDetails.needRefresh = true;
}
#ifdef USE_OSD
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 8432d83..f674015 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -219,7 +219,10 @@ protected:
/**
* Sets the dispaly mode.
- * @mode the dispaly mode, if -1 it will switch to next mode. If -2 to previous mode.
+ *
+ * This can only be used in a GFX transaction.
+ *
+ * @param mode the dispaly mode, if -1 it will switch to next mode. If -2 to previous mode.
*/
virtual void switchDisplayMode(int mode);
Commit: 83c638ad02709b39d72c5c575b3683bfd76dbbaa
https://github.com/scummvm/scummvm/commit/83c638ad02709b39d72c5c575b3683bfd76dbbaa
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGL: Setup the correct header size for BMP screenshots.
This fixes an color bug in the resulting screenshots.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index e0c65dd..f737d49 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1338,9 +1338,9 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {
// Write BMP header
out.writeByte('B');
out.writeByte('M');
- out.writeUint32LE(height * width * 3 + 52);
+ out.writeUint32LE(height * width * 3 + 54);
out.writeUint32LE(0);
- out.writeUint32LE(52);
+ out.writeUint32LE(54);
out.writeUint32LE(40);
out.writeUint32LE(width);
out.writeUint32LE(height);
Commit: 8ab136dafb2cef66e48ae24db6bd994e134f91e3
https://github.com/scummvm/scummvm/commit/8ab136dafb2cef66e48ae24db6bd994e134f91e3
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T13:20:20-07:00
Commit Message:
OPENGL: Fix screenshots when the display width is not divisible by 4.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index f737d49..fd8c2cc 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1207,6 +1207,11 @@ void OpenGLGraphicsManager::loadTextures() {
if (gameScreenBPP)
glPixelStorei(GL_UNPACK_ALIGNMENT, Common::gcd<uint>(gameScreenBPP, 2));
+ // We use a "pack" alignment (when reading from textures) to 4 here,
+ // since the only place where we really use it is the BMP screenshot
+ // code and that requires the same alignment too.
+ glPixelStorei(GL_PACK_ALIGNMENT, 4);
+
#ifdef USE_OSD
if (!_osdTexture)
_osdTexture = new GLTexture(2, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
@@ -1317,8 +1322,16 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {
int width = _videoMode.hardwareWidth;
int height = _videoMode.hardwareHeight;
+ // A line of a BMP image must have a size divisible by 4.
+ // We calculate the padding bytes needed here.
+ // Since we use a 3 byte per pixel mode, we can use width % 4 here, since
+ // it is equal to 4 - (width * 3) % 4. (4 - (width * Bpp) % 4, is the
+ // usual way of computing the padding bytes required).
+ const int linePaddingSize = width % 4;
+ const int lineSize = width * 3 + linePaddingSize;
+
// Allocate memory for screenshot
- uint8 *pixels = new uint8[width * height * 3];
+ uint8 *pixels = new uint8[lineSize * height];
// Get pixel data from OpenGL buffer
#ifdef USE_GLES
@@ -1338,7 +1351,7 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {
// Write BMP header
out.writeByte('B');
out.writeByte('M');
- out.writeUint32LE(height * width * 3 + 54);
+ out.writeUint32LE(height * lineSize + 54);
out.writeUint32LE(0);
out.writeUint32LE(54);
out.writeUint32LE(40);
@@ -1354,7 +1367,7 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {
out.writeUint32LE(0);
// Write pixel data to BMP
- out.write(pixels, width * height * 3);
+ out.write(pixels, lineSize * height);
// Free allocated memory
delete[] pixels;
More information about the Scummvm-git-logs
mailing list