diff options
| author | Peter0x44 <[email protected]> | 2022-07-14 19:36:33 +0300 |
|---|---|---|
| committer | Peter0x44 <[email protected]> | 2022-07-14 19:36:33 +0300 |
| commit | 9dcd4c4075f7c0538e6ca09fc7afa5de2243e5da (patch) | |
| tree | 874a370ee55c0708ceffd5482e30e1a074daceb1 /main.c | |
| parent | b9eacd472bfbbc736ae69e525468cac1f4cae9d8 (diff) | |
| download | raylib-DrawTexturePro-interactive-demo-9dcd4c4075f7c0538e6ca09fc7afa5de2243e5da.tar.gz raylib-DrawTexturePro-interactive-demo-9dcd4c4075f7c0538e6ca09fc7afa5de2243e5da.zip | |
Allow changing the texture used
Drag an image onto the window to replace the default
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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); + } +} |
