diff options
| author | Max Horn | 2004-11-22 23:25:08 +0000 |
|---|---|---|
| committer | Max Horn | 2004-11-22 23:25:08 +0000 |
| commit | 8ac347fd952a3811e6a948dfca3dec081882c335 (patch) | |
| tree | 001858ccbbc2c37f1957c62c3e5c7c635f386a31 | |
| parent | 96804652a2f310b31ad7dc4799872805d8c95e71 (diff) | |
| download | scummvm-rg350-8ac347fd952a3811e6a948dfca3dec081882c335.tar.gz scummvm-rg350-8ac347fd952a3811e6a948dfca3dec081882c335.tar.bz2 scummvm-rg350-8ac347fd952a3811e6a948dfca3dec081882c335.zip | |
Added OSystem::beginGFXTransaction / endGFXTransaction (not yet implemented, though :-)
svn-id: r15864
| -rw-r--r-- | base/main.cpp | 64 | ||||
| -rw-r--r-- | common/system.h | 34 |
2 files changed, 73 insertions, 25 deletions
diff --git a/base/main.cpp b/base/main.cpp index 24988c50de..15870d7a0b 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -185,15 +185,19 @@ static void do_memory_test(void) { #endif static int launcherDialog(GameDetector &detector, OSystem *system) { - // Set the user specified graphics mode (if any). - system->setGraphicsMode(ConfMan.get("gfx_mode").c_str()); - - // FIXME - we need to call initSize() here so that we can display for example - // the launcher dialog. But the Engine object will also call it again (possibly - // with a different widht/height!9 However, this method is not for all OSystem - // implementations reentrant (it is so now for the SDL backend). Thus we need - // to fix all backends to support it, if they don't already. - system->initSize(320, 200); + + system->beginGFXTransaction(); + // Set the user specified graphics mode (if any). + system->setGraphicsMode(ConfMan.get("gfx_mode").c_str()); + + // FIXME - we need to call initSize() here so that we can display for example + // the launcher dialog. But the Engine object will also call it again (possibly + // with a different widht/height!9 However, this method is not for all OSystem + // implementations reentrant (it is so now for the SDL backend). Thus we need + // to fix all backends to support it, if they don't already. + system->initSize(320, 200); + system->endGFXTransaction(); + // Clear the main screen system->clearScreen(); @@ -252,21 +256,37 @@ static void runGame(GameDetector &detector, OSystem *system) { !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "normal") || !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "default"); - // See if the game should default to 1x scaler - if (useDefaultGraphicsMode && (detector._game.features & GF_DEFAULT_TO_1X_SCALER)) { - system->setGraphicsMode(GFX_NORMAL); - } else { - // Override global scaler with any game-specific define - if (ConfMan.hasKey("gfx_mode")) { - system->setGraphicsMode(ConfMan.get("gfx_mode").c_str()); - } - } + system->beginGFXTransaction(); - // (De)activate aspect-ratio correction as determined by the config settings - system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); + // See if the game should default to 1x scaler + if (useDefaultGraphicsMode && (detector._game.features & GF_DEFAULT_TO_1X_SCALER)) { + system->setGraphicsMode(GFX_NORMAL); + } else { + // Override global scaler with any game-specific define + if (ConfMan.hasKey("gfx_mode")) { + system->setGraphicsMode(ConfMan.get("gfx_mode").c_str()); + } + } - // (De)activate fullscreen mode as determined by the config settings - system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); + // (De)activate aspect-ratio correction as determined by the config settings + system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); + + // (De)activate fullscreen mode as determined by the config settings + system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); + + // TODO / FIXME: this transaction sould also contain the initial call to initSize + // which all engines perform. However, as long as that is contained within + // the "engine->go()", this is not possible. + // Multiple solutions come to mind, including these: + // * Don't let the engine invoke initSize(); rather, add a method to them which we can + // use to query their desired res, then we set it for them + // * Move the setGraphicsMode/setFeatureState calls here to the Engine class, which the + // engines invoke (in other words: move this transaction into the engines + // * Add an explicit Engine::init() method, which all engines have to implement, + // and into which they should put their call to initSize. Then, make sure this transaction + // surrounds the call to engine->init(); + + system->endGFXTransaction(); // Create the game engine Engine *engine = detector.createEngine(system); diff --git a/common/system.h b/common/system.h index fcff39b567..da2c0fde5c 100644 --- a/common/system.h +++ b/common/system.h @@ -219,6 +219,32 @@ public: virtual void initSize(uint width, uint height) = 0; /** + * Begin a new GFX transaction, which is a sequence of GFX mode changes. + * The idea behind GFX transactions is to make it possible to activate + * several different GFX changes at once as a "batch" operation. For + * example, assume we are running in 320x200 with a 2x scaler (thus using + * 640x400 pixels in total). Now, we want to switch to 640x400 with the 1x + * scaler. Without transactions, we have to choose whether we want to first + * switch the scaler mode, or first to 640x400 mode. In either case, + * depending on the backend implementation, some ugliness may result. + * E.g. the window might briefly switch to 320x200 or 1280x800. + * Using transactions, this can be avoided. + * + * @note Transaction support is optional, and the default implementations + * of the relevant methods simply do nothing. + * @see endGFXTransaction + */ + virtual void beginGFXTransaction() {}; + + + /** + * End (and thereby commit) the current GFX transaction. + * @see beginGFXTransaction + */ + virtual void endGFXTransaction() {}; + + + /** * Returns the currently set virtual screen height. * @see initSize * @return the currently set virtual screen height @@ -254,9 +280,6 @@ public: * API are probably going to remove it. */ virtual void setPalette(const byte *colors, uint start, uint num) = 0; - - /** Clear the screen to black */ - virtual void clearScreen() {;} /** * Blit a bitmap to the virtual screen. @@ -267,6 +290,11 @@ public: * @see updateScreen */ virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0; + + /** + * Clear the screen to black. + */ + virtual void clearScreen() {} /** Update the dirty areas of the screen. */ virtual void updateScreen() = 0; |
