mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-23 11:04:44 +00:00
SDL: Fix trying to set unsupported pixel format when changing gfx mode
When switching between the SDL and OpenGL graphics managers, trying to restore the state could fail as the two managers do not have the same list of supported formats, so we may not be able to transfer the pixel format from one to the other. This then resulted in an assert. This fixes bug #12079
This commit is contained in:
parent
af6a427027
commit
5412533dec
@ -77,7 +77,15 @@ SdlGraphicsManager::State SdlGraphicsManager::getState() const {
|
||||
bool SdlGraphicsManager::setState(const State &state) {
|
||||
beginGFXTransaction();
|
||||
#ifdef USE_RGB_COLOR
|
||||
initSize(state.screenWidth, state.screenHeight, &state.pixelFormat);
|
||||
// When switching between the SDL and OpenGL graphics manager, the list
|
||||
// of supported format changes. This means that the pixel format in the
|
||||
// state may not be supported. In that case use the preferred supported
|
||||
// pixel format instead.
|
||||
Graphics::PixelFormat format = state.pixelFormat;
|
||||
Common::List<Graphics::PixelFormat> supportedFormats = getSupportedFormats();
|
||||
if (Common::find(supportedFormats.begin(), supportedFormats.end(), format) == supportedFormats.end())
|
||||
format = supportedFormats.front();
|
||||
initSize(state.screenWidth, state.screenHeight, &format);
|
||||
#else
|
||||
initSize(state.screenWidth, state.screenHeight, nullptr);
|
||||
#endif
|
||||
|
@ -789,14 +789,25 @@ bool OSystem_SDL::setGraphicsMode(int mode, uint flags) {
|
||||
_graphicsMode = mode;
|
||||
|
||||
if (switchedManager) {
|
||||
if (sdlGraphicsManager) {
|
||||
if (sdlGraphicsManager)
|
||||
sdlGraphicsManager->activateManager();
|
||||
// This failing will probably have bad consequences...
|
||||
if (!sdlGraphicsManager->setState(_gfxManagerState)) {
|
||||
return false;
|
||||
}
|
||||
} else if (sdlGraphics3dManager) {
|
||||
else if (sdlGraphics3dManager)
|
||||
sdlGraphics3dManager->activateManager();
|
||||
|
||||
// Setup the graphics mode and size first
|
||||
// This is needed so that we can check the supported pixel formats when
|
||||
// restoring the state.
|
||||
_graphicsManager->beginGFXTransaction();
|
||||
if (!_graphicsManager->setGraphicsMode(_graphicsModeIds[mode], flags))
|
||||
return false;
|
||||
_graphicsManager->initSize(_gfxManagerState.screenWidth, _gfxManagerState.screenHeight);
|
||||
_graphicsManager->endGFXTransaction();
|
||||
|
||||
// Restore state
|
||||
if (sdlGraphicsManager) {
|
||||
// This failing will probably have bad consequences...
|
||||
if (!sdlGraphicsManager->setState(_gfxManagerState))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Next setup the cursor again
|
||||
@ -810,8 +821,7 @@ bool OSystem_SDL::setGraphicsMode(int mode, uint flags) {
|
||||
}
|
||||
|
||||
_graphicsManager->beginGFXTransaction();
|
||||
// Oh my god if this failed the client code might just explode.
|
||||
return _graphicsManager->setGraphicsMode(_graphicsModeIds[mode], flags);
|
||||
return true;
|
||||
} else {
|
||||
return _graphicsManager->setGraphicsMode(_graphicsModeIds[mode], flags);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user