summaryrefslogtreecommitdiffhomepage
path: root/src/rcore.c
diff options
context:
space:
mode:
authorRay <[email protected]>2023-10-23 18:32:24 +0200
committerRay <[email protected]>2023-10-23 18:32:24 +0200
commit3ff60269174d0f264c152875be4d1808b7fe0195 (patch)
tree7b004157cee3d9d9964e722ed22c424b595d8ac2 /src/rcore.c
parentdaf227a185808d1e37e4269cf4a5be6b690226f6 (diff)
downloadraylib-3ff60269174d0f264c152875be4d1808b7fe0195.tar.gz
raylib-3ff60269174d0f264c152875be4d1808b7fe0195.zip
REVIEWED: Move screen capture logic to `rcore.c`, available for all platforms
Diffstat (limited to 'src/rcore.c')
-rw-r--r--src/rcore.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/rcore.c b/src/rcore.c
index 9bd47983..0cd3f440 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -739,6 +739,44 @@ void EndDrawing(void)
PollInputEvents(); // Poll user events (before next frame update)
#endif
+#if defined(SUPPORT_SCREEN_CAPTURE)
+ if (IsKeyPressed(KEY_F12))
+ {
+#if defined(SUPPORT_GIF_RECORDING)
+ if (IsKeyDown(KEY_LEFT_CONTROL))
+ {
+ if (gifRecording)
+ {
+ gifRecording = false;
+
+ MsfGifResult result = msf_gif_end(&gifState);
+
+ SaveFileData(TextFormat("%s/screenrec%03i.gif", CORE.Storage.basePath, screenshotCounter), result.data, (unsigned int)result.dataSize);
+ msf_gif_free(result);
+
+ TRACELOG(LOG_INFO, "SYSTEM: Finish animated GIF recording");
+ }
+ else
+ {
+ gifRecording = true;
+ gifFrameCounter = 0;
+
+ Vector2 scale = GetWindowScaleDPI();
+ msf_gif_begin(&gifState, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y));
+ screenshotCounter++;
+
+ TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
+ }
+ }
+ else
+#endif // SUPPORT_GIF_RECORDING
+ {
+ TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
+ screenshotCounter++;
+ }
+ }
+#endif // SUPPORT_SCREEN_CAPTURE
+
#if defined(SUPPORT_EVENTS_AUTOMATION)
// Events recording and playing logic
if (eventsRecording) RecordAutomationEvent(CORE.Time.frameCounter);
@@ -748,7 +786,7 @@ void EndDrawing(void)
if (CORE.Time.frameCounter >= eventCount) eventsPlaying = false;
PlayAutomationEvent(CORE.Time.frameCounter);
}
-#endif
+#endif // SUPPORT_EVENTS_AUTOMATION
CORE.Time.frameCounter++;
}