feat(captures): captura de pantalla amb F9 (PNG amb shaders, a mida de finestra)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "core/input/mouse.hpp"
|
||||
#include "core/locale/locale.hpp"
|
||||
#include "core/rendering/coordinate_transform.hpp"
|
||||
#include "core/rendering/screenshot.hpp"
|
||||
#include "core/system/notifier.hpp"
|
||||
#include "project.h"
|
||||
|
||||
@@ -360,8 +361,36 @@ auto SDLManager::clear(uint8_t r, uint8_t g, uint8_t b) -> bool {
|
||||
return gpu_renderer_.beginFrame(0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
void SDLManager::requestScreenshot() {
|
||||
// La captura es fa dins del pròxim endFrame (segon composite + readback);
|
||||
// el resultat es recull ací mateix, a present(), un cop el frame ja s'ha
|
||||
// compost. Així el PNG mostra exactament el que es veu en pantalla.
|
||||
gpu_renderer_.requestCapture();
|
||||
}
|
||||
|
||||
void SDLManager::present() {
|
||||
gpu_renderer_.endFrame();
|
||||
|
||||
// Si el frame que s'acaba de presentar portava una captura demanada,
|
||||
// l'escrivim a PNG i notifiquem la ruta. La notificació arriba DESPRÉS de
|
||||
// la captura, així que el toast "guardada" no apareix dins de la imatge.
|
||||
if (gpu_renderer_.hasCapture()) {
|
||||
const auto RESULT = Screenshot::save(
|
||||
gpu_renderer_.captureData(),
|
||||
gpu_renderer_.captureWidth(),
|
||||
gpu_renderer_.captureHeight());
|
||||
gpu_renderer_.clearCapture();
|
||||
if (!RESULT.filename.empty()) {
|
||||
if (auto* notifier = System::Notifier::get(); notifier != nullptr) {
|
||||
std::string msg = localeSubstitute(
|
||||
Locale::get().text("notification.screenshot"),
|
||||
"{file}",
|
||||
RESULT.filename);
|
||||
msg = localeSubstitute(msg, "{folder}", RESULT.folder);
|
||||
notifier->notifyInfo(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SDLManager::toggleVSync() {
|
||||
|
||||
Reference in New Issue
Block a user