From 9dcd4c4075f7c0538e6ca09fc7afa5de2243e5da Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Thu, 14 Jul 2022 19:36:33 +0300 Subject: Allow changing the texture used Drag an image onto the window to replace the default --- main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main.c b/main.c index 38da11a..ca0a70d 100644 --- a/main.c +++ b/main.c @@ -110,6 +110,8 @@ void CheckDifference(); void DrawCodeDisplay(); void DrawOutput(); +void HandleDroppedFiles(); + int main() { InitWindow(screenWidth, screenHeight, "DrawTexturePro Example"); @@ -138,6 +140,8 @@ int main() while (!WindowShouldClose()) { + HandleDroppedFiles(); + BeginDrawing(); ClearBackground(RAYWHITE); @@ -850,3 +854,17 @@ void DrawOutput() { ); }; + +void HandleDroppedFiles() +{ + if (IsFileDropped()) { + FilePathList droppedFiles = LoadDroppedFiles(); + Texture2D tmp = LoadTexture(droppedFiles.paths[0]); + if (tmp.id != 0) { + // Texture loaded successfully + UnloadTexture(sampleSprite); + sampleSprite = tmp; + } + UnloadDroppedFiles(droppedFiles); + } +} -- cgit v1.2.3