diff options
author | Alejandro Marzini | 2010-07-11 04:32:24 +0000 |
---|---|---|
committer | Alejandro Marzini | 2010-07-11 04:32:24 +0000 |
commit | 4dca7c7e02a111a950124ee26a6d46090a0f755c (patch) | |
tree | 0b5a39e1b03a0934392d1e982b4839c08b41daa9 /backends/graphics/opengl/opengl-graphics.cpp | |
parent | 85034dc730148dab3eb85b47be3f3984337e9484 (diff) | |
download | scummvm-rg350-4dca7c7e02a111a950124ee26a6d46090a0f755c.tar.gz scummvm-rg350-4dca7c7e02a111a950124ee26a6d46090a0f755c.tar.bz2 scummvm-rg350-4dca7c7e02a111a950124ee26a6d46090a0f755c.zip |
Moved getGraphicsManager() from OSystem_SDL to ModularBackend. Moved public SDL graphics manager functions to graphics manager (Allowing OpenGLSdlGraphicsMaanger to be used with other SDL managers easily). Removed BaseSdlGraphicsManager. Implemented in the opengl manager basic screen functions.
svn-id: r50796
Diffstat (limited to 'backends/graphics/opengl/opengl-graphics.cpp')
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 146 |
1 files changed, 140 insertions, 6 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index fd3824b394..71f0213a50 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -28,7 +28,19 @@ OpenGLGraphicsManager::OpenGLGraphicsManager() : - _gameTexture(0), _overlayTexture(0), _mouseTexture(0) { + _gameTexture(0), _overlayTexture(0), _mouseTexture(0), + _screenChangeCount(0), + _transactionMode(0) + + { + + memset(&_oldVideoMode, 0, sizeof(_oldVideoMode)); + memset(&_videoMode, 0, sizeof(_videoMode)); + memset(&_transactionDetails, 0, sizeof(_transactionDetails)); + + _videoMode.mode = GFX_NORMAL; + _videoMode.scaleFactor = 1; + _videoMode.fullscreen = false; } OpenGLGraphicsManager::~OpenGLGraphicsManager() { @@ -93,7 +105,33 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats() #endif void OpenGLGraphicsManager::initSize(uint width, uint height, const Graphics::PixelFormat *format) { + assert(_transactionMode == kTransactionActive); + +#ifdef USE_RGB_COLOR + //avoid redundant format changes + Graphics::PixelFormat newFormat; + if (!format) + newFormat = Graphics::PixelFormat::createFormatCLUT8(); + else + newFormat = *format; + + assert(newFormat.bytesPerPixel > 0); + + if (newFormat != _videoMode.format) { + _videoMode.format = newFormat; + _transactionDetails.formatChanged = true; + _screenFormat = newFormat; + } +#endif + + // Avoid redundant res changes + if ((int)width == _videoMode.screenWidth && (int)height == _videoMode.screenHeight) + return; + + _videoMode.screenWidth = width; + _videoMode.screenHeight = height; + _transactionDetails.sizeChanged = true; } int OpenGLGraphicsManager::getScreenChangeID() const { @@ -105,11 +143,107 @@ int OpenGLGraphicsManager::getScreenChangeID() const { // void OpenGLGraphicsManager::beginGFXTransaction() { + assert(_transactionMode == kTransactionNone); + _transactionMode = kTransactionActive; + _transactionDetails.sizeChanged = false; + _transactionDetails.needHotswap = false; + _transactionDetails.needUpdatescreen = false; +#ifdef USE_RGB_COLOR + _transactionDetails.formatChanged = false; +#endif + + _oldVideoMode = _videoMode; } OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() { - return OSystem::kTransactionSuccess; + int errors = OSystem::kTransactionSuccess; + + assert(_transactionMode != kTransactionNone); + + if (_transactionMode == kTransactionRollback) { + if (_videoMode.fullscreen != _oldVideoMode.fullscreen) { + errors |= OSystem::kTransactionFullscreenFailed; + + _videoMode.fullscreen = _oldVideoMode.fullscreen; + /*} else if (_videoMode.aspectRatioCorrection != _oldVideoMode.aspectRatioCorrection) { + errors |= OSystem::kTransactionAspectRatioFailed; + + _videoMode.aspectRatioCorrection = _oldVideoMode.aspectRatioCorrection;*/ + } else if (_videoMode.mode != _oldVideoMode.mode) { + errors |= OSystem::kTransactionModeSwitchFailed; + + _videoMode.mode = _oldVideoMode.mode; + _videoMode.scaleFactor = _oldVideoMode.scaleFactor; +#ifdef USE_RGB_COLOR + } else if (_videoMode.format != _oldVideoMode.format) { + errors |= OSystem::kTransactionFormatNotSupported; + + _videoMode.format = _oldVideoMode.format; + _screenFormat = _videoMode.format; +#endif + } else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) { + errors |= OSystem::kTransactionSizeChangeFailed; + + _videoMode.screenWidth = _oldVideoMode.screenWidth; + _videoMode.screenHeight = _oldVideoMode.screenHeight; + _videoMode.overlayWidth = _oldVideoMode.overlayWidth; + _videoMode.overlayHeight = _oldVideoMode.overlayHeight; + } + + if (_videoMode.fullscreen == _oldVideoMode.fullscreen && + //_videoMode.aspectRatioCorrection == _oldVideoMode.aspectRatioCorrection && + _videoMode.mode == _oldVideoMode.mode && + _videoMode.screenWidth == _oldVideoMode.screenWidth && + _videoMode.screenHeight == _oldVideoMode.screenHeight) { + + // Our new video mode would now be exactly the same as the + // old one. Since we still can not assume SDL_SetVideoMode + // to be working fine, we need to invalidate the old video + // mode, so loadGFXMode would error out properly. + _oldVideoMode.setup = false; + } + } + +#ifdef USE_RGB_COLOR + if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) { +#else + if (_transactionDetails.sizeChanged) { +#endif + unloadGFXMode(); + if (!loadGFXMode()) { + if (_oldVideoMode.setup) { + _transactionMode = kTransactionRollback; + errors |= endGFXTransaction(); + } + } else { + //setGraphicsModeIntern(); + //clearOverlay(); + + _videoMode.setup = true; + _screenChangeCount++; + } + } else if (_transactionDetails.needHotswap) { + //setGraphicsModeIntern(); + if (!hotswapGFXMode()) { + if (_oldVideoMode.setup) { + _transactionMode = kTransactionRollback; + errors |= endGFXTransaction(); + } + } else { + _videoMode.setup = true; + _screenChangeCount++; + + if (_transactionDetails.needUpdatescreen) + internUpdateScreen(); + } + } else if (_transactionDetails.needUpdatescreen) { + //setGraphicsModeIntern(); + internUpdateScreen(); + } + + _transactionMode = kTransactionNone; + return (OSystem::TransactionError)errors; } // @@ -117,11 +251,11 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() { // int16 OpenGLGraphicsManager::getHeight() { - return 0; + return _videoMode.screenHeight; } int16 OpenGLGraphicsManager::getWidth() { - return 0; + return _videoMode.screenWidth; } void OpenGLGraphicsManager::setPalette(const byte *colors, uint start, uint num) { @@ -194,11 +328,11 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch } int16 OpenGLGraphicsManager::getOverlayHeight() { - return 0; + return _videoMode.overlayHeight; } int16 OpenGLGraphicsManager::getOverlayWidth() { - return 0; + return _videoMode.overlayWidth; } // |