mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Compare commits
3 Commits
d7a7eda959
...
ee2999b3e0
| Author | SHA1 | Date | |
|---|---|---|---|
| ee2999b3e0 | |||
| f76e371436 | |||
| 0b4815b8fe |
@ -68,8 +68,8 @@ Examples using raylib[core](../src/rcore.c) platform functionality like window c
|
||||
| [core_input_actions](core/core_input_actions.c) | <img src="core/core_input_actions.png" alt="core_input_actions" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Jett](https://github.com/JettMonstersGoBoom) |
|
||||
| [core_directory_files](core/core_directory_files.c) | <img src="core/core_directory_files.png" alt="core_directory_files" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Hugo ARNAL](https://github.com/hugoarnal) |
|
||||
| [core_highdpi_testbed](core/core_highdpi_testbed.c) | <img src="core/core_highdpi_testbed.png" alt="core_highdpi_testbed" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
| [core_screen_recording](core/core_screen_recording.c) | <img src="core/core_screen_recording.png" alt="core_screen_recording" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
| [core_clipboard_text](core/core_clipboard_text.c) | <img src="core/core_clipboard_text.png" alt="core_clipboard_text" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Robin](https://github.com/RobinsAviary) |
|
||||
| [core_screen_recording](core/core_screen_recording.c) | <img src="core/core_screen_recording.png" alt="core_screen_recording" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
| [core_clipboard_text](core/core_clipboard_text.c) | <img src="core/core_clipboard_text.png" alt="core_clipboard_text" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Ananth S](https://github.com/Ananth1839) |
|
||||
| [core_text_file_loading](core/core_text_file_loading.c) | <img src="core/core_text_file_loading.png" alt="core_text_file_loading" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Aanjishnu Bhattacharyya](https://github.com/NimComPoo-04) |
|
||||
| [core_compute_hash](core/core_compute_hash.c) | <img src="core/core_compute_hash.png" alt="core_compute_hash" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
|
||||
|
||||
@ -2,22 +2,23 @@
|
||||
*
|
||||
* raylib [core] example - clipboard text
|
||||
*
|
||||
* Example complexity rating: [★☆☆☆] 1/4
|
||||
*
|
||||
* Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev
|
||||
*
|
||||
* Example contributed by Robin (@RobinsAviary) and reviewed by Ramon Santamaria (@raysan5)
|
||||
* Example contributed by Ananth S (@Ananth1839) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2025 Robin (@RobinsAviary)
|
||||
* Copyright (c) 2025 Ananth S (@Ananth1839)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "raygui.h"
|
||||
|
||||
#define MAX_TEXT_SAMPLES 5
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
@ -31,30 +32,32 @@ int main(void)
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - clipboard text");
|
||||
|
||||
const char *clipboardText = NULL;
|
||||
// Define some sample texts
|
||||
const char *sampleTexts[MAX_TEXT_SAMPLES] = {
|
||||
"Hello from raylib!",
|
||||
"The quick brown fox jumps over the lazy dog",
|
||||
"Clipboard operations are useful!",
|
||||
"raylib is a simple and easy-to-use library",
|
||||
"Copy and paste me!"
|
||||
};
|
||||
|
||||
// List of text the user can switch through and copy
|
||||
const char *copyableText[] = { "raylib is fun", "hello, clipboard!", "potato chips" };
|
||||
char *clipboardText = NULL;
|
||||
char inputBuffer[256] = "Hello from raylib!"; // Random initial string
|
||||
|
||||
unsigned int textIndex = 0;
|
||||
// UI required variables
|
||||
bool textBoxEditMode = false;
|
||||
|
||||
const char *popupText = NULL;
|
||||
bool btnCutPressed = false;
|
||||
bool btnCopyPressed = false;
|
||||
bool btnPastePressed = false;
|
||||
bool btnClearPressed = false;
|
||||
bool btnRandomPressed = false;
|
||||
|
||||
// Initialize timers
|
||||
// The amount of time the pop-up text is on screen, before fading
|
||||
const float maxTime = 3.0f;
|
||||
float textTimer = 0.0f;
|
||||
// The length of time text is offset
|
||||
const float animMaxTime = 0.1f;
|
||||
float pasteAnim = 0.0f;
|
||||
float copyAnim = 0.0f;
|
||||
int copyAnimMult = 1;
|
||||
float textAnim = 0.0f;
|
||||
float textAlpha = 0.0f;
|
||||
// Offset amount for animations
|
||||
const int offsetAmount = -4;
|
||||
// Set UI style
|
||||
GuiSetStyle(DEFAULT, TEXT_SIZE, 20);
|
||||
GuiSetIconScale(2);
|
||||
|
||||
SetTargetFPS(60);
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
@ -62,83 +65,56 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Check if the user has pressed the copy/paste key combinations
|
||||
bool pastePressed = (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_V));
|
||||
bool copyPressed = (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_C));
|
||||
|
||||
// Update animation timers
|
||||
if (textTimer > 0) textTimer -= GetFrameTime();
|
||||
if (pasteAnim > 0) pasteAnim -= GetFrameTime();
|
||||
if (copyAnim > 0) copyAnim -= GetFrameTime();
|
||||
if (textAnim > 0) textAnim -= GetFrameTime();
|
||||
|
||||
if (pastePressed)
|
||||
// Handle button interactions
|
||||
if (btnCutPressed)
|
||||
{
|
||||
// Most operating systems hide this information until the user presses Ctrl-V on the window.
|
||||
SetClipboardText(inputBuffer);
|
||||
clipboardText = GetClipboardText();
|
||||
inputBuffer[0] = '\0'; // Quick solution to clear text
|
||||
//memset(inputBuffer, 0, 256); // Clear full buffer properly
|
||||
}
|
||||
|
||||
// Check to see if the clipboard contains an image
|
||||
// This function does nothing outside of Windows, as it directly calls the Windows API
|
||||
Image image = GetClipboardImage();
|
||||
if (btnCopyPressed)
|
||||
{
|
||||
SetClipboardText(inputBuffer); // Copy text to clipboard
|
||||
clipboardText = GetClipboardText(); // Get text from clipboard
|
||||
}
|
||||
|
||||
if (IsImageValid(image))
|
||||
if (btnPastePressed)
|
||||
{
|
||||
// Paste text from clipboard
|
||||
clipboardText = GetClipboardText();
|
||||
if (clipboardText != NULL) TextCopy(inputBuffer, clipboardText);
|
||||
}
|
||||
|
||||
if (btnClearPressed)
|
||||
{
|
||||
inputBuffer[0] = '\0'; // Quick solution to clear text
|
||||
//memset(inputBuffer, 0, 256); // Clear full buffer properly
|
||||
}
|
||||
|
||||
if (btnRandomPressed)
|
||||
{
|
||||
// Get random text from sample list
|
||||
TextCopy(inputBuffer, sampleTexts[GetRandomValue(0, MAX_TEXT_SAMPLES - 1)]);
|
||||
}
|
||||
|
||||
// Quick cut/copy/paste with keyboard shortcuts
|
||||
if (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL))
|
||||
{
|
||||
if (IsKeyPressed(KEY_X))
|
||||
{
|
||||
UnloadImage(image);
|
||||
popupText = "clipboard contains image";
|
||||
SetClipboardText(inputBuffer);
|
||||
inputBuffer[0] = '\0'; // Quick solution to clear text
|
||||
}
|
||||
else
|
||||
|
||||
if (IsKeyPressed(KEY_C)) SetClipboardText(inputBuffer);
|
||||
|
||||
if (IsKeyPressed(KEY_V))
|
||||
{
|
||||
clipboardText = GetClipboardText();
|
||||
|
||||
popupText = "text pasted";
|
||||
pasteAnim = animMaxTime;
|
||||
if (clipboardText != NULL) TextCopy(inputBuffer, clipboardText);
|
||||
}
|
||||
|
||||
// Reset animation values
|
||||
textTimer = maxTime;
|
||||
textAnim = animMaxTime;
|
||||
textAlpha = 1;
|
||||
}
|
||||
|
||||
// React to the user pressing copy
|
||||
if (copyPressed)
|
||||
{
|
||||
// Set the text on the user's clipboard
|
||||
SetClipboardText(copyableText[textIndex]);
|
||||
|
||||
// Reset values
|
||||
textTimer = maxTime;
|
||||
textAnim = animMaxTime;
|
||||
copyAnim = animMaxTime;
|
||||
copyAnimMult = 1;
|
||||
textAlpha = 1;
|
||||
popupText = "text copied";
|
||||
}
|
||||
|
||||
// Switch to the next item in the list when the user presses up
|
||||
if (IsKeyPressed(KEY_UP))
|
||||
{
|
||||
// Reset animation
|
||||
copyAnim = animMaxTime;
|
||||
copyAnimMult = 1;
|
||||
|
||||
textIndex += 1;
|
||||
|
||||
if (textIndex >= sizeof(copyableText) / sizeof(const char*)) // Length of array
|
||||
{
|
||||
// Loop back to the other end
|
||||
textIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Switch to the previous item in the list when the user presses down
|
||||
if (IsKeyPressed(KEY_DOWN))
|
||||
{
|
||||
// Reset animation
|
||||
copyAnim = animMaxTime;
|
||||
copyAnimMult = -1;
|
||||
|
||||
if (textIndex == 0) textIndex = (sizeof(copyableText)/sizeof(const char*)) - 1;
|
||||
else textIndex -= 1;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@ -146,40 +122,32 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Draw the user's pasted text, if there is any yet
|
||||
if (clipboardText)
|
||||
{
|
||||
// Offset animation
|
||||
int offset = 0;
|
||||
if (pasteAnim > 0) offset = offsetAmount;
|
||||
// Draw instructions
|
||||
GuiLabel((Rectangle){ 50, 20, 700, 36 }, "Use the BUTTONS or KEY SHORTCUTS:");
|
||||
DrawText("[CTRL+X] - CUT | [CTRL+C] COPY | [CTRL+V] | PASTE", 50, 60, 20, MAROON);
|
||||
|
||||
// Draw the pasted text
|
||||
DrawText("pasted clipboard:", 10, 10 + offset, 20, DARKGREEN);
|
||||
DrawText(clipboardText, 10, 30 + offset, 20, DARKGRAY);
|
||||
}
|
||||
// Draw text box
|
||||
if (GuiTextBox((Rectangle){ 50, 120, 652, 40 }, inputBuffer, 256, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
|
||||
|
||||
// Offset animation
|
||||
int textOffset = 0;
|
||||
if (copyAnim > 0) textOffset = offsetAmount;
|
||||
// Random text button
|
||||
btnRandomPressed = GuiButton((Rectangle){ 50 + 652 + 8, 120, 40, 40 }, "#77#");
|
||||
|
||||
// Draw copyable text and controls
|
||||
DrawText(copyableText[textIndex], 10, 330 + (textOffset * copyAnimMult), 20, MAROON);
|
||||
DrawText("up/down to change string, ctrl-c to copy, ctrl-v to paste", 10, 355, 20, DARKGRAY);
|
||||
// Draw buttons
|
||||
btnCutPressed = GuiButton((Rectangle){ 50, 180, 158, 40 }, "#17#CUT");
|
||||
btnCopyPressed = GuiButton((Rectangle){ 50 + 165, 180, 158, 40 }, "#16#COPY");
|
||||
btnPastePressed = GuiButton((Rectangle){ 50 + 165*2, 180, 158, 40 }, "#18#PASTE");
|
||||
btnClearPressed = GuiButton((Rectangle){ 50 + 165*3, 180, 158, 40 }, "#143#CLEAR");
|
||||
|
||||
// Alpha / Offset animation
|
||||
if (textAlpha > 0)
|
||||
{
|
||||
// Offset animation
|
||||
int offset = 0;
|
||||
if (textAnim > 0) offset = offsetAmount;
|
||||
// Draw pop up text
|
||||
DrawText(popupText, 10, 425 + offset, 20, ColorAlpha(DARKGREEN, textAlpha));
|
||||
|
||||
// Fade-out animation
|
||||
if (textTimer < 0) textAlpha -= GetFrameTime();
|
||||
}
|
||||
// Draw clipboard status
|
||||
GuiSetState(STATE_DISABLED);
|
||||
GuiLabel((Rectangle){ 50, 260, 700, 40 }, "Clipboard current text data:");
|
||||
GuiSetStyle(TEXTBOX, TEXT_READONLY, 1);
|
||||
GuiTextBox((Rectangle){ 50, 300, 700, 40 }, clipboardText, 256, false);
|
||||
GuiSetStyle(TEXTBOX, TEXT_READONLY, 0);
|
||||
GuiLabel((Rectangle){ 50, 360, 700, 40 }, "Try copying text from other applications and pasting here!");
|
||||
GuiSetState(STATE_NORMAL);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
@ -2,12 +2,10 @@
|
||||
*
|
||||
* raylib [core] example - screen recording
|
||||
*
|
||||
* Example complexity rating: [★☆☆☆] 1/4
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
* Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev
|
||||
*
|
||||
* Example contributed by Ramon Santamaria (@raysan5) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
@ -17,6 +15,16 @@
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
// Using msf_gif library to record frames into GIF
|
||||
#define MSF_GIF_IMPL
|
||||
#include "msf_gif.h" // GIF recording functionality
|
||||
|
||||
#include <math.h> // Required for: sinf()
|
||||
|
||||
#define GIF_RECORD_FRAMERATE 5 // Record framerate, we get a frame every N frames
|
||||
|
||||
#define MAX_SINEWAVE_POINTS 256
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -29,7 +37,20 @@ int main(void)
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - screen recording");
|
||||
|
||||
// TODO: Load resources / Initialize variables at this point
|
||||
bool gifRecording = false; // GIF recording state
|
||||
unsigned int gifFrameCounter = 0; // GIF frames counter
|
||||
MsfGifState gifState = { 0 }; // MSGIF context state
|
||||
|
||||
Vector2 circlePosition = { 0.0f, screenHeight/2.0f };
|
||||
float timeCounter = 0.0f;
|
||||
|
||||
// Get sine wave points for line drawing
|
||||
Vector2 sinePoints[MAX_SINEWAVE_POINTS] = { 0 };
|
||||
for (int i = 0; i < MAX_SINEWAVE_POINTS; i++)
|
||||
{
|
||||
sinePoints[i].x = i*GetScreenWidth()/180.0f;
|
||||
sinePoints[i].y = screenHeight/2.0f + 150*sinf((2*PI/1.5f)*(1.0f/60.0f)*(float)i); // Calculate for 60 fps
|
||||
}
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
@ -39,7 +60,59 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update variables / Implement example logic at this point
|
||||
// Update circle sinusoidal movement
|
||||
timeCounter += GetFrameTime();
|
||||
circlePosition.x += GetScreenWidth()/180.0f;
|
||||
circlePosition.y = screenHeight/2.0f + 150*sinf((2*PI/1.5f)*timeCounter);
|
||||
if (circlePosition.x > screenWidth)
|
||||
{
|
||||
circlePosition.x = 0.0f;
|
||||
circlePosition.y = screenHeight/2.0f;
|
||||
timeCounter = 0.0f;
|
||||
}
|
||||
|
||||
// Start-Stop GIF recording on CTRL+R
|
||||
if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_R))
|
||||
{
|
||||
if (gifRecording)
|
||||
{
|
||||
// Stop current recording and save file
|
||||
gifRecording = false;
|
||||
MsfGifResult result = msf_gif_end(&gifState);
|
||||
SaveFileData(TextFormat("%s/screenrecording.gif", GetApplicationDirectory()), result.data, (unsigned int)result.dataSize);
|
||||
msf_gif_free(result);
|
||||
|
||||
TraceLog(LOG_INFO, "Finish animated GIF recording");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start a new recording
|
||||
gifRecording = true;
|
||||
gifFrameCounter = 0;
|
||||
msf_gif_begin(&gifState, GetRenderWidth(), GetRenderHeight());
|
||||
|
||||
TraceLog(LOG_INFO, "Start animated GIF recording");
|
||||
}
|
||||
}
|
||||
|
||||
if (gifRecording)
|
||||
{
|
||||
gifFrameCounter++;
|
||||
|
||||
// NOTE: We record one gif frame depending on the desired gif framerate
|
||||
if (gifFrameCounter > GIF_RECORD_FRAMERATE)
|
||||
{
|
||||
// Get image data for the current frame (from backbuffer)
|
||||
// WARNING: This process is quite slow, it can generate stuttering
|
||||
Image imScreen = LoadImageFromScreen();
|
||||
|
||||
// Add the frame to the gif recording, providing and "estimated" time for display in centiseconds
|
||||
msf_gif_frame(&gifState, imScreen.data, (int)((1.0f/60.0f)*GIF_RECORD_FRAMERATE)/10, 16, imScreen.width*4);
|
||||
gifFrameCounter = 0;
|
||||
|
||||
UnloadImage(imScreen); // Free image data
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
@ -48,20 +121,43 @@ int main(void)
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// TODO: Draw everything that requires to be drawn at this point
|
||||
for (int i = 0; i < (MAX_SINEWAVE_POINTS - 1); i++)
|
||||
{
|
||||
DrawLineV(sinePoints[i], sinePoints[i + 1], MAROON);
|
||||
DrawCircleV(sinePoints[i], 3, MAROON);
|
||||
}
|
||||
|
||||
DrawLineEx((Vector2){ 0, 0 }, (Vector2){ screenWidth, screenHeight }, 2.0f, RED);
|
||||
DrawLineEx((Vector2){ 0, screenHeight }, (Vector2){ screenWidth, 0 }, 2.0f, RED);
|
||||
DrawText("example base code template", 260, 400, 20, LIGHTGRAY);
|
||||
DrawCircleV(circlePosition, 30, RED);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
/*
|
||||
// Draw record indicator
|
||||
// WARNING: If drawn here, it will appear in the recorded image,
|
||||
// use a render texture instead for the recording and LoadImageFromTexture(rt.texture)
|
||||
if (gifRecording)
|
||||
{
|
||||
// Display the recording indicator every half-second
|
||||
if ((int)(GetTime()/0.5)%2 == 1)
|
||||
{
|
||||
DrawCircle(30, GetScreenHeight() - 20, 10, MAROON);
|
||||
DrawText("GIF RECORDING", 50, GetScreenHeight() - 25, 10, RED);
|
||||
}
|
||||
}
|
||||
*/
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// TODO: Unload all loaded resources at this point
|
||||
// If still recording a GIF on close window, just finish
|
||||
if (gifRecording)
|
||||
{
|
||||
MsfGifResult result = msf_gif_end(&gifState);
|
||||
msf_gif_free(result);
|
||||
gifRecording = false;
|
||||
}
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@ -50,8 +50,8 @@ core;core_viewport_scaling;★★☆☆;5.5;5.5;2025;2025;"Agnis Aldins";@nezver
|
||||
core;core_input_actions;★★☆☆;5.5;5.6;2025;2025;"Jett";@JettMonstersGoBoom
|
||||
core;core_directory_files;★☆☆☆;5.5;5.6;2025;2025;"Hugo ARNAL";@hugoarnal
|
||||
core;core_highdpi_testbed;★☆☆☆;5.6-dev;5.6-dev;2025;2025;"Ramon Santamaria";@raysan5
|
||||
core;core_screen_recording;★☆☆☆;5.6-dev;5.6-dev;2025;2025;"Ramon Santamaria";@raysan5
|
||||
core;core_clipboard_text;★☆☆☆;5.6-dev;5.6-dev;2025;2025;"Robin";@RobinsAviary
|
||||
core;core_screen_recording;★★☆☆;5.6-dev;5.6-dev;2025;2025;"Ramon Santamaria";@raysan5
|
||||
core;core_clipboard_text;★☆☆☆;5.6-dev;5.6-dev;2025;2025;"Ananth S";@Ananth1839
|
||||
core;core_text_file_loading;★☆☆☆;5.5;5.6;0;0;"Aanjishnu Bhattacharyya";@NimComPoo-04
|
||||
core;core_compute_hash;★★☆☆;5.6-dev;5.6-dev;2025;2025;"Ramon Santamaria";@raysan5
|
||||
shapes;shapes_basic_shapes;★☆☆☆;1.0;4.2;2014;2025;"Ramon Santamaria";@raysan5
|
||||
|
||||
@ -60,8 +60,6 @@
|
||||
#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1
|
||||
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
||||
#define SUPPORT_SCREEN_CAPTURE 1
|
||||
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
|
||||
#define SUPPORT_GIF_RECORDING 1
|
||||
// Support CompressData() and DecompressData() functions
|
||||
#define SUPPORT_COMPRESSION_API 1
|
||||
// Support automatic generated events, loading and recording of those events when required
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management
|
||||
*
|
||||
* OPTIONAL DEPENDENCIES (included):
|
||||
* [rcore] msf_gif (Miles Fogle) for GIF recording
|
||||
* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm
|
||||
* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm
|
||||
* [rcore] rprand (Ramon Santamaria) for pseudo-random numbers generation
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ Example elements validated:
|
||||
| core_input_actions | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_directory_files | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_highdpi_testbed | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_screen_recording | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_screen_recording | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_clipboard_text | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_text_file_loading | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_compute_hash | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
|
||||
@ -21,7 +21,6 @@ Example elements validated:
|
||||
| **EXAMPLE NAME** | [C] | [CAT]| [INFO]|[PNG]|[WPNG]| [RES]| [MK] |[MKWEB]| [VCX]| [SOL]|[RDME]|[JS] | [WOUT]|[WMETA]|
|
||||
|:---------------------------------|:---:|:----:|:-----:|:---:|:----:|:----:|:----:|:-----:|:----:|:----:|:----:|:---:|:-----:|:-----:|
|
||||
| core_highdpi_testbed | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| core_screen_recording | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| rlgl_standalone | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| rlgl_compute_shader | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
| easings_testbed | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
|
||||
@ -2154,11 +2154,12 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount)
|
||||
int functionIndex01 = TextFindIndex(ptr - 40, "ExportImage"); // Check ExportImage()
|
||||
int functionIndex02 = TextFindIndex(ptr - 10, "TraceLog"); // Check TraceLog()
|
||||
int functionIndex03 = TextFindIndex(ptr - 40, "TakeScreenshot"); // Check TakeScreenshot()
|
||||
|
||||
int functionIndex04 = TextFindIndex(ptr - 40, "SaveFileData"); // Check SaveFileData()
|
||||
|
||||
if (!((functionIndex01 != -1) && (functionIndex01 < 40)) && // Not found ExportImage() before ""
|
||||
!((functionIndex02 != -1) && (functionIndex02 < 10)) && // Not found TraceLog() before ""
|
||||
!((functionIndex03 != -1) && (functionIndex03 < 40))) // Not found TakeScreenshot() before ""
|
||||
!((functionIndex03 != -1) && (functionIndex03 < 40)) && // Not found TakeScreenshot() before ""
|
||||
!((functionIndex04 != -1) && (functionIndex04 < 40))) // Not found SaveFileData() before ""
|
||||
{
|
||||
int len = (int)(end - start);
|
||||
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
|
||||
|
||||
Reference in New Issue
Block a user