mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-18 22:53:08 +00:00
Add "Take Screenshot" to Windows version. Writes to "screenshots" subdirectory. No smart file naming yet.
This commit is contained in:
parent
3034989300
commit
23ee9b8cd5
2
.gitignore
vendored
2
.gitignore
vendored
@ -50,7 +50,7 @@ __testerror.txt
|
||||
__testfinish.txt
|
||||
__testfailure.bmp
|
||||
GameLogNotes.txt
|
||||
|
||||
screenshots
|
||||
android/ui_atlas.zim
|
||||
android/assets/lang
|
||||
android/assets/flash0
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Binary file not shown.
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit ca9301fedf879f28d6f11fda59709a66c5368bec
|
||||
Subproject commit bd78a060158aa7ee12713727164541be29f8355a
|
Loading…
x
Reference in New Issue
Block a user