enable screenshots with F12

This commit is contained in:
aap 2021-02-12 00:29:09 +01:00
parent 031195f11d
commit 879838c9f2
5 changed files with 53 additions and 1 deletions

View File

@ -1,8 +1,10 @@
#include "common.h" #include "common.h"
#include <time.h>
#include "rpmatfx.h" #include "rpmatfx.h"
#include "rphanim.h" #include "rphanim.h"
#include "rpskin.h" #include "rpskin.h"
#include "rtbmp.h" #include "rtbmp.h"
#include "rtpng.h"
#ifdef ANISOTROPIC_FILTERING #ifdef ANISOTROPIC_FILTERING
#include "rpanisot.h" #include "rpanisot.h"
#endif #endif
@ -331,7 +333,11 @@ RwGrabScreen(RwCamera *camera, RwChar *filename)
strcpy(temp, CFileMgr::GetRootDirName()); strcpy(temp, CFileMgr::GetRootDirName());
strcat(temp, filename); strcat(temp, filename);
#ifdef THIS_IS_STUPID
if (RtBMPImageWrite(pImage, &temp[0]) == nil) if (RtBMPImageWrite(pImage, &temp[0]) == nil)
#else
if (RtPNGImageWrite(pImage, &temp[0]) == nil)
#endif
result = false; result = false;
RwImageDestroy(pImage); RwImageDestroy(pImage);
return result; return result;
@ -350,6 +356,7 @@ DoRWStuffEndOfFrame(void)
RsCameraShowRaster(Scene.camera); RsCameraShowRaster(Scene.camera);
#ifndef MASTER #ifndef MASTER
char s[48]; char s[48];
#ifdef THIS_IS_STUPID
if (CPad::GetPad(1)->GetLeftShockJustDown()) { if (CPad::GetPad(1)->GetLeftShockJustDown()) {
// try using both controllers for this thing... crazy bastards // try using both controllers for this thing... crazy bastards
if (CPad::GetPad(0)->GetRightStickY() > 0) { if (CPad::GetPad(0)->GetRightStickY() > 0) {
@ -361,6 +368,12 @@ DoRWStuffEndOfFrame(void)
RwGrabScreen(Scene.camera, s); 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 #endif // !MASTER
} }

View File

@ -947,6 +947,43 @@ RtBMPImageRead(const RwChar *imageName)
#endif #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" #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); } 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); }

View File

@ -207,6 +207,7 @@ psGrabScreen(RwCamera *pCamera)
} }
#else #else
rw::Image *image = RwCameraGetRaster(pCamera)->toImage(); rw::Image *image = RwCameraGetRaster(pCamera)->toImage();
image->removeMask();
if(image) if(image)
return image; return image;
#endif #endif

View File

@ -262,6 +262,7 @@ psGrabScreen(RwCamera *pCamera)
} }
#else #else
rw::Image *image = RwCameraGetRaster(pCamera)->toImage(); rw::Image *image = RwCameraGetRaster(pCamera)->toImage();
image->removeMask();
if(image) if(image)
return image; return image;
#endif #endif

2
vendor/librw vendored

@ -1 +1 @@
Subproject commit 5c95300890559c85a2764bc200361f904cd4f9f4 Subproject commit 4c77fb57546e89da1e6f3bad3c582848de9f5c93