diff --git a/.gitignore b/.gitignore index 51767a038d..7e50d2692b 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,7 @@ __testerror.txt __testfinish.txt __testfailure.bmp GameLogNotes.txt - +screenshots android/ui_atlas.zim android/assets/lang android/assets/flash0 diff --git a/GPU/GLES/DisplayListInterpreter.h b/GPU/GLES/DisplayListInterpreter.h index f1da2ea9c0..15225bf3c9 100644 --- a/GPU/GLES/DisplayListInterpreter.h +++ b/GPU/GLES/DisplayListInterpreter.h @@ -52,7 +52,7 @@ public: virtual void DumpNextFrame(); virtual void Flush(); virtual void DoState(PointerWrap &p); - + // Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*. virtual void Resized(); virtual bool DecodeTexture(u8* dest, GPUgstate state) diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 78a6dfa3eb..8abe456b7d 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -104,6 +104,7 @@ public: void CopyDisplayToOutput(); void SetRenderFrameBuffer(); // Uses parameters computed from gstate void UpdateFromMemory(u32 addr, int size); + // TODO: Break out into some form of FBO manager VirtualFramebuffer *GetDisplayFBO(); void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 7b4adda767..26d3bb0760 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -34,6 +34,7 @@ #include "base/NativeApp.h" #include "file/vfs.h" #include "file/zip_read.h" +#include "ext/jpge/jpge.h" #include "gfx_es2/gl_state.h" #include "gfx/gl_lost_manager.h" #include "gfx/texture.h" @@ -64,6 +65,7 @@ #include "UIShader.h" #include "UI/PluginScreen.h" +#include "UI/OnScreenDisplay.h" // The new UI framework, for initialization @@ -87,6 +89,8 @@ std::string game_title; bool isJailed; #endif +// Really need to clean this mess of globals up... but instead I add more :P +bool g_TakeScreenshot; recursive_mutex pendingMutex; static bool isMessagePending; @@ -445,6 +449,45 @@ void NativeInitGraphics() { glstate.viewport.set(0, 0, pixel_xres, pixel_yres); } +void TakeScreenshot() { +#ifdef _WIN32 + g_TakeScreenshot = false; + mkDir("screenshots"); + + // First, find a free filename. + int i = 0; + + char temp[256]; + while (i < 10000) { + sprintf(temp, "screenshots/screen%05d.jpg", i); + FileInfo info; + if (!getFileInfo(temp, &info)) + break; + i++; + } + + // Okay, allocate a buffer. + u8 *buffer = new u8[4 * pixel_xres * pixel_yres]; + // Silly openGL reads upside down, we flip to another buffer for simplicity. + u8 *flipbuffer = new u8[4 * pixel_xres * pixel_yres]; + + glReadPixels(0, 0, pixel_xres, pixel_yres, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + for (int y = 0; y < pixel_yres; y++) { + memcpy(flipbuffer + y * pixel_xres * 4, buffer + (pixel_yres - y - 1) * pixel_xres * 4, pixel_xres * 4); + } + + jpge::params params; + params.m_quality = 90; + compress_image_to_jpeg_file(temp, pixel_xres, pixel_yres, 4, flipbuffer, params); + + delete [] buffer; + delete [] flipbuffer; + + osm.Show(temp); +#endif +} + void NativeRender() { EnableFZ(); @@ -464,6 +507,10 @@ void NativeRender() { glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr()); screenManager->render(); + + if (g_TakeScreenshot) { + TakeScreenshot(); + } } void NativeUpdate(InputState &input) { diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index ee02b7bc89..90ff964f78 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -47,7 +47,7 @@ BOOL g_bFullScreen = FALSE; static RECT g_normalRC = {0}; - +extern bool g_TakeScreenshot; extern InputState input_state; extern const char * getVirtualKeyName(unsigned char key); extern const char * getXinputButtonName(unsigned int button); @@ -771,6 +771,9 @@ namespace MainWindow DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); DialogManager::EnableAll(TRUE); break; + case ID_DEBUG_TAKESCREENSHOT: + g_TakeScreenshot = true; + break; default: MessageBox(hwndMain,"Unimplemented","Sorry",0); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index bd316f4fa5..c2c0f1f9c4 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -73,6 +73,7 @@ BEGIN "4", ID_OPTIONS_SCREEN4X, VIRTKEY, CONTROL, NOINVERT VK_F5, ID_OPTIONS_BUFFEREDRENDERING, VIRTKEY, NOINVERT VK_F6, ID_OPTIONS_HARDWARETRANSFORM, VIRTKEY, NOINVERT + VK_F9, ID_DEBUG_TAKESCREENSHOT, VIRTKEY, NOINVERT VK_F11, ID_OPTIONS_FULLSCREEN, VIRTKEY, NOINVERT END @@ -360,6 +361,7 @@ BEGIN MENUITEM "&Reset Symbol Table", ID_DEBUG_RESETSYMBOLTABLE MENUITEM SEPARATOR MENUITEM "D&ump Next Frame to Log", ID_DEBUG_DUMPNEXTFRAME + MENUITEM "&Take Screenshot\tF9", ID_DEBUG_TAKESCREENSHOT MENUITEM SEPARATOR MENUITEM "&Disassembly\tCtrl+D", ID_DEBUG_DISASSEMBLY MENUITEM "&Log Console\tCtrl+L", ID_DEBUG_LOG diff --git a/Windows/resource.h b/Windows/resource.h index e508cf6a72..ccf442fae0 100644 Binary files a/Windows/resource.h and b/Windows/resource.h differ diff --git a/native b/native index ca9301fedf..bd78a06015 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit ca9301fedf879f28d6f11fda59709a66c5368bec +Subproject commit bd78a060158aa7ee12713727164541be29f8355a