change to external/msf_gif.h for rendering to gif
This commit is contained in:
parent
a850246030
commit
88ddbd8782
|
|
@ -55,7 +55,7 @@
|
||||||
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
||||||
#define SUPPORT_SCREEN_CAPTURE 1
|
#define SUPPORT_SCREEN_CAPTURE 1
|
||||||
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
|
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
|
||||||
//#define SUPPORT_GIF_RECORDING 1
|
#define SUPPORT_GIF_RECORDING 1
|
||||||
// Allow scale all the drawn content to match the high-DPI equivalent size (only PLATFORM_DESKTOP)
|
// Allow scale all the drawn content to match the high-DPI equivalent size (only PLATFORM_DESKTOP)
|
||||||
//#define SUPPORT_HIGH_DPI 1
|
//#define SUPPORT_HIGH_DPI 1
|
||||||
// Support CompressData() and DecompressData() functions
|
// Support CompressData() and DecompressData() functions
|
||||||
|
|
|
||||||
22
src/core.c
22
src/core.c
|
|
@ -147,11 +147,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SUPPORT_GIF_RECORDING)
|
#if defined(SUPPORT_GIF_RECORDING)
|
||||||
#define RGIF_MALLOC RL_MALLOC
|
#define MSF_GIF_IMPL
|
||||||
#define RGIF_FREE RL_FREE
|
#include "external/msf_gif.h"
|
||||||
|
|
||||||
#define RGIF_IMPLEMENTATION
|
|
||||||
#include "external/rgif.h" // Support GIF recording
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h> // Required for: srand(), rand(), atexit()
|
#include <stdlib.h> // Required for: srand(), rand(), atexit()
|
||||||
|
|
@ -483,6 +480,7 @@ static int screenshotCounter = 0; // Screenshots counter
|
||||||
#if defined(SUPPORT_GIF_RECORDING)
|
#if defined(SUPPORT_GIF_RECORDING)
|
||||||
static int gifFramesCounter = 0; // GIF frames counter
|
static int gifFramesCounter = 0; // GIF frames counter
|
||||||
static bool gifRecording = false; // GIF recording state
|
static bool gifRecording = false; // GIF recording state
|
||||||
|
static MsfGifState gifState = { 0 };
|
||||||
#endif
|
#endif
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -786,7 +784,7 @@ void CloseWindow(void)
|
||||||
#if defined(SUPPORT_GIF_RECORDING)
|
#if defined(SUPPORT_GIF_RECORDING)
|
||||||
if (gifRecording)
|
if (gifRecording)
|
||||||
{
|
{
|
||||||
GifEnd();
|
msf_gif_end(&gifState);
|
||||||
gifRecording = false;
|
gifRecording = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1502,9 +1500,9 @@ void EndDrawing(void)
|
||||||
// Get image data for the current frame (from backbuffer)
|
// Get image data for the current frame (from backbuffer)
|
||||||
// NOTE: This process is very slow... :(
|
// NOTE: This process is very slow... :(
|
||||||
unsigned char *screenData = rlReadScreenPixels(CORE.Window.screen.width, CORE.Window.screen.height);
|
unsigned char *screenData = rlReadScreenPixels(CORE.Window.screen.width, CORE.Window.screen.height);
|
||||||
GifWriteFrame(screenData, CORE.Window.screen.width, CORE.Window.screen.height, 10, 8, false);
|
msf_gif_frame(&gifState, screenData, GIF_RECORD_FRAMERATE*GetFrameTime(), 16, 4*CORE.Window.screen.width);
|
||||||
|
|
||||||
RL_FREE(screenData); // Free image data
|
RL_FREE(screenData); // Free image data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((gifFramesCounter/15)%2) == 1)
|
if (((gifFramesCounter/15)%2) == 1)
|
||||||
|
|
@ -4170,7 +4168,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||||
{
|
{
|
||||||
if (gifRecording)
|
if (gifRecording)
|
||||||
{
|
{
|
||||||
GifEnd();
|
msf_gif_end(&gifState);
|
||||||
gifRecording = false;
|
gifRecording = false;
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
|
|
@ -4196,7 +4194,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||||
|
|
||||||
// NOTE: delay represents the time between frames in the gif, if we capture a gif frame every
|
// NOTE: delay represents the time between frames in the gif, if we capture a gif frame every
|
||||||
// 10 game frames and each frame trakes 16.6ms (60fps), delay between gif frames should be ~16.6*10.
|
// 10 game frames and each frame trakes 16.6ms (60fps), delay between gif frames should be ~16.6*10.
|
||||||
GifBegin(path, CORE.Window.screen.width, CORE.Window.screen.height, (int)(GetFrameTime()*10.0f), 8, false);
|
msf_gif_begin(&gifState, path, CORE.Window.screen.width, CORE.Window.screen.height);
|
||||||
screenshotCounter++;
|
screenshotCounter++;
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
|
TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
|
||||||
|
|
@ -5536,7 +5534,7 @@ void UWPKeyDownEvent(int key, bool down, bool controlKey)
|
||||||
{
|
{
|
||||||
if (gifRecording)
|
if (gifRecording)
|
||||||
{
|
{
|
||||||
GifEnd();
|
msf_gif_end(&gifState);
|
||||||
gifRecording = false;
|
gifRecording = false;
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
|
|
@ -5557,7 +5555,7 @@ void UWPKeyDownEvent(int key, bool down, bool controlKey)
|
||||||
|
|
||||||
// NOTE: delay represents the time between frames in the gif, if we capture a gif frame every
|
// NOTE: delay represents the time between frames in the gif, if we capture a gif frame every
|
||||||
// 10 game frames and each frame trakes 16.6ms (60fps), delay between gif frames should be ~16.6*10.
|
// 10 game frames and each frame trakes 16.6ms (60fps), delay between gif frames should be ~16.6*10.
|
||||||
GifBegin(path, CORE.Window.screen.width, CORE.Window.screen.height, (int)(GetFrameTime() * 10.0f), 8, false);
|
msf_gif_begin(&gifState, TextFormat("screenrec%03i.gif", screenshotCounter), GetScreenWidth(), GetScreenHeight());
|
||||||
screenshotCounter++;
|
screenshotCounter++;
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
|
TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user