mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-14 10:25:29 +00:00
WARNING: REMOVED: GIT recording option, added example
This commit is contained in:
102
src/rcore.c
102
src/rcore.c
@@ -52,9 +52,6 @@
|
||||
* #define SUPPORT_SCREEN_CAPTURE
|
||||
* Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
||||
*
|
||||
* #define SUPPORT_GIF_RECORDING
|
||||
* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
|
||||
*
|
||||
* #define SUPPORT_COMPRESSION_API
|
||||
* Support CompressData() and DecompressData() functions, those functions use zlib implementation
|
||||
* provided by stb_image and stb_image_write libraries, so, those libraries must be enabled on textures module
|
||||
@@ -134,15 +131,6 @@
|
||||
#include "rcamera.h" // Camera system functionality
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
#define MSF_GIF_MALLOC(contextPointer, newSize) RL_MALLOC(newSize)
|
||||
#define MSF_GIF_REALLOC(contextPointer, oldMemory, oldSize, newSize) RL_REALLOC(oldMemory, newSize)
|
||||
#define MSF_GIF_FREE(contextPointer, oldMemory, oldSize) RL_FREE(oldMemory)
|
||||
|
||||
#define MSF_GIF_IMPL
|
||||
#include "external/msf_gif.h" // GIF recording functionality
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_COMPRESSION_API)
|
||||
#define SINFL_IMPLEMENTATION
|
||||
#define SINFL_NO_SIMD
|
||||
@@ -402,12 +390,6 @@ bool isGpuReady = false;
|
||||
static int screenshotCounter = 0; // Screenshots counter
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
static unsigned int gifFrameCounter = 0; // GIF frames counter
|
||||
static bool gifRecording = false; // GIF recording state
|
||||
static MsfGifState gifState = { 0 }; // MSGIF context state
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
// Automation events type
|
||||
typedef enum AutomationEventType {
|
||||
@@ -758,15 +740,6 @@ void InitWindow(int width, int height, const char *title)
|
||||
// Close window and unload OpenGL context
|
||||
void CloseWindow(void)
|
||||
{
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
if (gifRecording)
|
||||
{
|
||||
MsfGifResult result = msf_gif_end(&gifState);
|
||||
msf_gif_free(result);
|
||||
gifRecording = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
|
||||
UnloadFontDefault(); // WARNING: Module required: rtext
|
||||
#endif
|
||||
@@ -929,47 +902,6 @@ void EndDrawing(void)
|
||||
{
|
||||
rlDrawRenderBatchActive(); // Update and draw internal render batch
|
||||
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
// Draw record indicator
|
||||
if (gifRecording)
|
||||
{
|
||||
#ifndef GIF_RECORD_FRAMERATE
|
||||
#define GIF_RECORD_FRAMERATE 10
|
||||
#endif
|
||||
gifFrameCounter += (unsigned int)(GetFrameTime()*1000);
|
||||
|
||||
// NOTE: We record one gif frame depending on the desired gif framerate
|
||||
if (gifFrameCounter > 1000/GIF_RECORD_FRAMERATE)
|
||||
{
|
||||
// Get image data for the current frame (from backbuffer)
|
||||
// NOTE: This process is quite slow... :(
|
||||
Vector2 scale = GetWindowScaleDPI();
|
||||
unsigned char *screenData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y));
|
||||
|
||||
#ifndef GIF_RECORD_BITRATE
|
||||
#define GIF_RECORD_BITRATE 16
|
||||
#endif
|
||||
|
||||
// Add the frame to the gif recording, given how many frames have passed in centiseconds
|
||||
msf_gif_frame(&gifState, screenData, gifFrameCounter/10, GIF_RECORD_BITRATE, (int)((float)CORE.Window.render.width*scale.x)*4);
|
||||
gifFrameCounter -= 1000/GIF_RECORD_FRAMERATE;
|
||||
|
||||
RL_FREE(screenData); // Free image data
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_MODULE_RSHAPES) && defined(SUPPORT_MODULE_RTEXT)
|
||||
// Display the recording indicator every half-second
|
||||
if ((int)(GetTime()/0.5)%2 == 1)
|
||||
{
|
||||
DrawCircle(30, CORE.Window.screen.height - 20, 10, MAROON); // WARNING: Module required: rshapes
|
||||
DrawText("GIF RECORDING", 50, CORE.Window.screen.height - 25, 10, RED); // WARNING: Module required: rtext
|
||||
}
|
||||
#endif
|
||||
|
||||
rlDrawRenderBatchActive(); // Update and draw internal render batch
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
if (automationEventRecording) RecordAutomationEvent(); // Event recording
|
||||
#endif
|
||||
@@ -1002,38 +934,8 @@ void EndDrawing(void)
|
||||
#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++;
|
||||
}
|
||||
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
|
||||
screenshotCounter++;
|
||||
}
|
||||
#endif // SUPPORT_SCREEN_CAPTURE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user