diff options
author | James Brown | 2004-11-13 04:33:33 +0000 |
---|---|---|
committer | James Brown | 2004-11-13 04:33:33 +0000 |
commit | 2ae3166f2db47b7beb5225d57b5e271de33ab9cd (patch) | |
tree | 39990f576a436da88699af15d525e942a4a9f02e | |
parent | 628b02a9e8183001279c7ecbf59d38456993aa8c (diff) | |
download | scummvm-rg350-2ae3166f2db47b7beb5225d57b5e271de33ab9cd.tar.gz scummvm-rg350-2ae3166f2db47b7beb5225d57b5e271de33ab9cd.tar.bz2 scummvm-rg350-2ae3166f2db47b7beb5225d57b5e271de33ab9cd.zip |
Add new clearScreen OSystem call. Currently only implemented in SDL backend. This call is currently only used for clearing the launcher screen to remove garbage from the main screen before reentering.
svn-id: r15799
-rw-r--r-- | backends/sdl/graphics.cpp | 14 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 3 | ||||
-rw-r--r-- | base/main.cpp | 3 | ||||
-rw-r--r-- | common/system.h | 3 |
4 files changed, 23 insertions, 0 deletions
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp index f6b981110d..ed4a3cbd1e 100644 --- a/backends/sdl/graphics.cpp +++ b/backends/sdl/graphics.cpp @@ -514,6 +514,20 @@ void OSystem_SDL::setFullscreenMode(bool enable) { } } +void OSystem_SDL::clearScreen() { + // Try to lock the screen surface + if (SDL_LockSurface(_screen) == -1) + error("SDL_LockSurface failed: %s", SDL_GetError()); + + byte *dst = (byte *)_screen->pixels; + + // Clear the screen + memset(dst, 0, _screenWidth * _screenHeight); + + // Unlock the screen surface + SDL_UnlockSurface(_screen); +} + void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) { if (_screen == NULL) return; diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index fde699ae6b..646c9a262e 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -64,6 +64,9 @@ public: // The screen will not be updated to reflect the new bitmap void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h); + // Clear the screen + void clearScreen(); + // Update the dirty areas of the screen void updateScreen(); diff --git a/base/main.cpp b/base/main.cpp index 1844bbdd63..7b6cf30176 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -195,6 +195,9 @@ static int launcherDialog(GameDetector &detector, OSystem *system) { // to fix all backends to support it, if they don't already. system->initSize(320, 200); + // Clear the main screen + system->clearScreen(); + // FIXME - mouse cursors are currently always set via 8 bit data. // Thus for now we need to setup a dummy palette. On the long run, we might // want to add a setMouseCursor_overlay() method to OSystem, which would serve diff --git a/common/system.h b/common/system.h index 2f2aeab7ec..fcff39b567 100644 --- a/common/system.h +++ b/common/system.h @@ -254,6 +254,9 @@ 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. |