diff options
Diffstat (limited to 'backends/sdl')
-rw-r--r-- | backends/sdl/sdl-common.cpp | 19 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 2 | ||||
-rw-r--r-- | backends/sdl/sdl.cpp | 8 | ||||
-rw-r--r-- | backends/sdl/sdl_gl.cpp | 13 |
4 files changed, 42 insertions, 0 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index de07498806..a6b1a785aa 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -554,6 +554,25 @@ bool OSystem_SDL_Common::poll_event(Event *event) { break; } + if (b == KBD_ALT && ev.key.keysym.sym == 's') { + char filename[20]; + + for (int n = 0;; n++) { + SDL_RWops *file; + + sprintf(filename, "scummvm%05d.bmp", n); + file = SDL_RWFromFile(filename, "r"); + if (!file) + break; + SDL_RWclose(file); + } + if (save_screenshot(filename)) + printf("Saved '%s'\n", filename); + else + printf("Could not save screenshot!\n"); + break; + } + #ifdef MACOSX // On Macintosh', Cmd-Q quits if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym=='q') { diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index a626858382..9b378e8bb1 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -225,6 +225,8 @@ protected: virtual void load_gfx_mode() = 0; virtual void unload_gfx_mode() = 0; + virtual bool save_screenshot(const char *filename) = 0; + void setup_icon(); void kbd_mouse(); void init_joystick() { _joystick = SDL_JoystickOpen(0); } diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index 24c9cc3f72..af2d30ad5a 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -42,6 +42,7 @@ protected: virtual void load_gfx_mode(); virtual void unload_gfx_mode(); + virtual bool save_screenshot(const char *filename); void hotswap_gfx_mode(); }; @@ -376,3 +377,10 @@ uint32 OSystem_SDL::property(int param, Property *value) { return OSystem_SDL_Common::property(param, value); } +bool OSystem_SDL::save_screenshot(const char *filename) { + assert(_hwscreen != NULL); + + StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends + SDL_SaveBMP(_hwscreen, filename); + return true; +} diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp index 8215672427..15e45c875c 100644 --- a/backends/sdl/sdl_gl.cpp +++ b/backends/sdl/sdl_gl.cpp @@ -64,6 +64,7 @@ protected: virtual void load_gfx_mode(); virtual void unload_gfx_mode(); + virtual bool save_screenshot(const char *filename); void hotswap_gfx_mode(); }; @@ -668,3 +669,15 @@ uint32 OSystem_SDL_OpenGL::property(int param, Property *value) { return OSystem_SDL_Common::property(param, value); } + +bool OSystem_SDL_OpenGL::save_screenshot(const char *filename) { + // FIXME: I don't know how to do this yet. + if (_usingOpenGL) + return false; + + StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends + + assert(_hwscreen != NULL); + SDL_SaveBMP(_hwscreen, filename); + return true; +} |