From 879838c9f20d9f166353d4dd5ea486dda6f91921 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 12 Feb 2021 00:29:09 +0100 Subject: enable screenshots with F12 --- src/core/main.cpp | 13 +++++++++++++ src/fakerw/fake.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/skel/glfw/glfw.cpp | 1 + src/skel/win/win.cpp | 1 + vendor/librw | 2 +- 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/core/main.cpp b/src/core/main.cpp index a08a9535..bb94ca5d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1,8 +1,10 @@ #include "common.h" +#include #include "rpmatfx.h" #include "rphanim.h" #include "rpskin.h" #include "rtbmp.h" +#include "rtpng.h" #ifdef ANISOTROPIC_FILTERING #include "rpanisot.h" #endif @@ -331,7 +333,11 @@ RwGrabScreen(RwCamera *camera, RwChar *filename) strcpy(temp, CFileMgr::GetRootDirName()); strcat(temp, filename); +#ifdef THIS_IS_STUPID if (RtBMPImageWrite(pImage, &temp[0]) == nil) +#else + if (RtPNGImageWrite(pImage, &temp[0]) == nil) +#endif result = false; RwImageDestroy(pImage); return result; @@ -350,6 +356,7 @@ DoRWStuffEndOfFrame(void) RsCameraShowRaster(Scene.camera); #ifndef MASTER char s[48]; +#ifdef THIS_IS_STUPID if (CPad::GetPad(1)->GetLeftShockJustDown()) { // try using both controllers for this thing... crazy bastards if (CPad::GetPad(0)->GetRightStickY() > 0) { @@ -361,6 +368,12 @@ DoRWStuffEndOfFrame(void) RwGrabScreen(Scene.camera, s); } } +#else + if (CPad::GetPad(1)->GetLeftShockJustDown() || CPad::GetPad(0)->GetFJustDown(11)) { + sprintf(s, "screen_%11lld.png", time(nil)); + RwGrabScreen(Scene.camera, s); + } +#endif #endif // !MASTER } diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp index 18a27ec1..1faf6ee6 100644 --- a/src/fakerw/fake.cpp +++ b/src/fakerw/fake.cpp @@ -947,6 +947,43 @@ RtBMPImageRead(const RwChar *imageName) #endif } + +RwImage * +RtPNGImageWrite(RwImage *image, const RwChar *imageName) +{ +#ifndef _WIN32 + char *r = casepath(imageName); + if (r) { + rw::writePNG(image, r); + free(r); + } else { + rw::writePNG(image, imageName); + } + +#else + rw::writePNG(image, imageName); +#endif + return image; +} +RwImage * +RtPNGImageRead(const RwChar *imageName) +{ +#ifndef _WIN32 + RwImage *image; + char *r = casepath(imageName); + if (r) { + image = rw::readPNG(r); + free(r); + } else { + image = rw::readPNG(imageName); + } + return image; + +#else + return rw::readPNG(imageName); +#endif +} + #include "rtquat.h" RtQuat *RtQuatRotate(RtQuat * quat, const RwV3d * axis, RwReal angle, RwOpCombineType combineOp) { return (RtQuat*)((rw::Quat*)quat)->rotate(axis, angle/180.0f*3.14159f, (CombineOp)combineOp); } diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 8fe1d93f..db9d101a 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -207,6 +207,7 @@ psGrabScreen(RwCamera *pCamera) } #else rw::Image *image = RwCameraGetRaster(pCamera)->toImage(); + image->removeMask(); if(image) return image; #endif diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 6ed02011..89c901b2 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -262,6 +262,7 @@ psGrabScreen(RwCamera *pCamera) } #else rw::Image *image = RwCameraGetRaster(pCamera)->toImage(); + image->removeMask(); if(image) return image; #endif diff --git a/vendor/librw b/vendor/librw index 5c953008..4c77fb57 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit 5c95300890559c85a2764bc200361f904cd4f9f4 +Subproject commit 4c77fb57546e89da1e6f3bad3c582848de9f5c93 -- cgit v1.2.3